Browse Source

AP_HAL_SITL: support for virtual hardware safety switch

c415-sdk
Peter Barker 5 years ago committed by Andrew Tridgell
parent
commit
907977b2f2
  1. 18
      libraries/AP_HAL_SITL/RCOutput.cpp
  2. 9
      libraries/AP_HAL_SITL/RCOutput.h
  3. 9
      libraries/AP_HAL_SITL/Util.cpp
  4. 4
      libraries/AP_HAL_SITL/Util.h

18
libraries/AP_HAL_SITL/RCOutput.cpp

@ -126,3 +126,21 @@ void RCOutput::neopixel_send(void) @@ -126,3 +126,21 @@ void RCOutput::neopixel_send(void)
}
#endif
void RCOutput::force_safety_off(void)
{
SITL::SITL *sitl = AP::sitl();
if (sitl == nullptr) {
return;
}
sitl->force_safety_off();
}
bool RCOutput::force_safety_on(void)
{
SITL::SITL *sitl = AP::sitl();
if (sitl == nullptr) {
return false;
}
return sitl->force_safety_on();
}

9
libraries/AP_HAL_SITL/RCOutput.h

@ -18,6 +18,15 @@ public: @@ -18,6 +18,15 @@ public:
void cork(void) override;
void push(void) override;
/*
force the safety switch on, disabling PWM output from the IO board
*/
bool force_safety_on(void) override;
/*
force the safety switch off, enabling PWM output from the IO board
*/
void force_safety_off(void) override;
/*
Serial LED emulation
*/

9
libraries/AP_HAL_SITL/Util.cpp

@ -124,3 +124,12 @@ void *HALSITL::Util::heap_realloc(void *heap_ptr, void *ptr, size_t new_size) @@ -124,3 +124,12 @@ void *HALSITL::Util::heap_realloc(void *heap_ptr, void *ptr, size_t new_size)
}
#endif // ENABLE_HEAP
enum AP_HAL::Util::safety_state HALSITL::Util::safety_switch_state(void)
{
const SITL::SITL *sitl = AP::sitl();
if (sitl == nullptr) {
return AP_HAL::Util::SAFETY_NONE;
}
return sitl->safety_switch_state();
}

4
libraries/AP_HAL_SITL/Util.h

@ -49,7 +49,9 @@ public: @@ -49,7 +49,9 @@ public:
// return true if the reason for the reboot was a watchdog reset
bool was_watchdog_reset() const override { return getenv("SITL_WATCHDOG_RESET") != nullptr; }
enum safety_state safety_switch_state(void) override;
private:
SITL_State *sitlState;

Loading…
Cancel
Save