AP_HAL_SITL: move simulated megasquirt to SerialDevice framework

This commit is contained in:
Peter Barker 2021-10-11 12:12:20 +11:00 committed by Peter Barker
parent 2026f7efb8
commit 8c9ade3f7f
2 changed files with 17 additions and 4 deletions

View File

@ -373,6 +373,12 @@ int SITL_State::sim_fd(const char *name, const char *arg)
} }
gyus42v2 = new SITL::RF_GYUS42v2(); gyus42v2 = new SITL::RF_GYUS42v2();
return gyus42v2->fd(); return gyus42v2->fd();
} else if (streq(name, "megasquirt")) {
if (efi_ms != nullptr) {
AP_HAL::panic("Only one megasquirt at a time");
}
efi_ms = new SITL::EFI_MegaSquirt();
return efi_ms->fd();
} else if (streq(name, "VectorNav")) { } else if (streq(name, "VectorNav")) {
if (vectornav != nullptr) { if (vectornav != nullptr) {
AP_HAL::panic("Only one VectorNav at a time"); AP_HAL::panic("Only one VectorNav at a time");
@ -508,6 +514,11 @@ int SITL_State::sim_fd_write(const char *name)
AP_HAL::panic("No gyus42v2 created"); AP_HAL::panic("No gyus42v2 created");
} }
return gyus42v2->write_fd(); return gyus42v2->write_fd();
} else if (streq(name, "megasquirt")) {
if (efi_ms == nullptr) {
AP_HAL::panic("No megasquirt created");
}
return efi_ms->write_fd();
} else if (streq(name, "VectorNav")) { } else if (streq(name, "VectorNav")) {
if (vectornav == nullptr) { if (vectornav == nullptr) {
AP_HAL::panic("No VectorNav created"); AP_HAL::panic("No VectorNav created");
@ -713,6 +724,9 @@ void SITL_State::_fdm_input_local(void)
if (gyus42v2 != nullptr) { if (gyus42v2 != nullptr) {
gyus42v2->update(sitl_model->rangefinder_range()); gyus42v2->update(sitl_model->rangefinder_range());
} }
if (efi_ms != nullptr) {
efi_ms->update();
}
if (frsky_d != nullptr) { if (frsky_d != nullptr) {
frsky_d->update(); frsky_d->update();
@ -751,10 +765,6 @@ void SITL_State::_fdm_input_local(void)
ais->update(); ais->update();
} }
if (_sitl) {
_sitl->efi_ms.update();
}
if (_sitl && _use_fg_view) { if (_sitl && _use_fg_view) {
_output_to_flightgear(); _output_to_flightgear();
} }

View File

@ -320,6 +320,9 @@ private:
// simulated AIS stream // simulated AIS stream
SITL::AIS *ais; SITL::AIS *ais;
// simulated EFI MegaSquirt device:
SITL::EFI_MegaSquirt *efi_ms;
// output socket for flightgear viewing // output socket for flightgear viewing
SocketAPM fg_socket{true}; SocketAPM fg_socket{true};