From bddb9aaac73e777317122057df0ee737e69b599d Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Mon, 22 Jan 2024 19:12:33 +1100 Subject: [PATCH] SITL: add ASSERT_STORAGE_SIZE macro saves havin gto name the dummy variable yourself --- libraries/SITL/SIM_ADSB_Sagetech_MXS.cpp | 18 ++++++------------ libraries/SITL/SIM_EFI_Hirth.cpp | 9 +++------ libraries/SITL/SIM_Invensense_v3.cpp | 3 +-- libraries/SITL/SIM_RichenPower.cpp | 2 ++ libraries/SITL/SIM_RichenPower.h | 1 - 5 files changed, 12 insertions(+), 21 deletions(-) diff --git a/libraries/SITL/SIM_ADSB_Sagetech_MXS.cpp b/libraries/SITL/SIM_ADSB_Sagetech_MXS.cpp index 88a76717d2..68ed4470ef 100644 --- a/libraries/SITL/SIM_ADSB_Sagetech_MXS.cpp +++ b/libraries/SITL/SIM_ADSB_Sagetech_MXS.cpp @@ -143,8 +143,7 @@ void ADSB_Sagetech_MXS::handle_message() bool ADSB_Sagetech_MXS::handle_message(const SITL::ADSB_Sagetech_MXS::Installation& opmsg) { - assert_storage_size _assert_storage_size_Installation; - (void)_assert_storage_size_Installation; + ASSERT_STORAGE_SIZE(Installation, 36); if (operating_mode != OperatingMode::OFF && operating_mode != OperatingMode::MAINTENANCE) { @@ -181,8 +180,7 @@ void ADSB_Sagetech_MXS::assert_good_flight_id() bool ADSB_Sagetech_MXS::handle_message(const SITL::ADSB_Sagetech_MXS::FlightIDMessage& _msg) { - assert_storage_size _assert_storage_size_FlightIDMessage; - (void)_assert_storage_size_FlightIDMessage; + ASSERT_STORAGE_SIZE(FlightIDMessage, 12); // do something! flight_id_set_time_ms = AP_HAL::millis(); @@ -194,8 +192,7 @@ bool ADSB_Sagetech_MXS::handle_message(const SITL::ADSB_Sagetech_MXS::FlightIDMe bool ADSB_Sagetech_MXS::handle_message(const SITL::ADSB_Sagetech_MXS::Operating& _msg) { - assert_storage_size _assert_storage_size_Operating; - (void)_assert_storage_size_Operating; + ASSERT_STORAGE_SIZE(Operating, 12); // do something! @@ -222,8 +219,7 @@ double ADSB_Sagetech_MXS::lat_string_to_double(const uint8_t *str) bool ADSB_Sagetech_MXS::handle_message(const SITL::ADSB_Sagetech_MXS::GPS& _msg) { - assert_storage_size _assert_storage_size_GPS; - (void)_assert_storage_size_GPS; + ASSERT_STORAGE_SIZE(GPS, 63); // store data to transmit via ADSB info_from_vehicle.gps.lat = lat_string_to_double(_msg.latitude); @@ -234,8 +230,7 @@ bool ADSB_Sagetech_MXS::handle_message(const SITL::ADSB_Sagetech_MXS::GPS& _msg) bool ADSB_Sagetech_MXS::handle_message(const SITL::ADSB_Sagetech_MXS::DataRequest& _msg) { - assert_storage_size _assert_storage_size_DataRequest; - (void)_assert_storage_size_DataRequest; + ASSERT_STORAGE_SIZE(DataRequest, 4); // handle request to send data to vehicle. Note that the // specification says (on page 32) that the ack is sent before the @@ -246,8 +241,7 @@ bool ADSB_Sagetech_MXS::handle_message(const SITL::ADSB_Sagetech_MXS::DataReques bool ADSB_Sagetech_MXS::handle_message(const SITL::ADSB_Sagetech_MXS::TargetRequest& _msg) { - assert_storage_size _assert_storage_size_TargetRequest; - (void)_assert_storage_size_TargetRequest; + ASSERT_STORAGE_SIZE(TargetRequest, 7); // handle request to send adsb data to vehicle as it is received diff --git a/libraries/SITL/SIM_EFI_Hirth.cpp b/libraries/SITL/SIM_EFI_Hirth.cpp index ba6faece7e..2dbafba610 100644 --- a/libraries/SITL/SIM_EFI_Hirth.cpp +++ b/libraries/SITL/SIM_EFI_Hirth.cpp @@ -206,8 +206,7 @@ void SITL::EFI_Hirth::send_record1() write_to_autopilot((char*)&packed_record1, sizeof(packed_record1)); - assert_storage_size _assert_storage_size_Record1; - (void)_assert_storage_size_Record1; + ASSERT_STORAGE_SIZE(Record1, 84); } void SITL::EFI_Hirth::send_record2() @@ -224,8 +223,7 @@ void SITL::EFI_Hirth::send_record2() write_to_autopilot((char*)&packed_record2, sizeof(packed_record2)); - assert_storage_size _assert_storage_size_Record2; - (void)_assert_storage_size_Record2; + ASSERT_STORAGE_SIZE(Record2, 98); } @@ -243,6 +241,5 @@ void SITL::EFI_Hirth::send_record3() write_to_autopilot((char*)&packed_record3, sizeof(packed_record3)); - assert_storage_size _assert_storage_size_Record3; - (void)_assert_storage_size_Record3; + ASSERT_STORAGE_SIZE(Record3, 100); } diff --git a/libraries/SITL/SIM_Invensense_v3.cpp b/libraries/SITL/SIM_Invensense_v3.cpp index 2724daf90a..a13dfa1348 100644 --- a/libraries/SITL/SIM_Invensense_v3.cpp +++ b/libraries/SITL/SIM_Invensense_v3.cpp @@ -4,8 +4,7 @@ void SITL::InvensenseV3::update(const class Aircraft &aircraft) { - assert_storage_size _assert_fifo_size; - (void)_assert_fifo_size; + ASSERT_STORAGE_SIZE(FIFOData, 16); const SIM *sitl = AP::sitl(); const int16_t xAccel = sitl->state.xAccel / accel_scale(); diff --git a/libraries/SITL/SIM_RichenPower.cpp b/libraries/SITL/SIM_RichenPower.cpp index f5affa7d27..7088daa3e4 100644 --- a/libraries/SITL/SIM_RichenPower.cpp +++ b/libraries/SITL/SIM_RichenPower.cpp @@ -51,6 +51,8 @@ const AP_Param::GroupInfo RichenPower::var_info[] = { RichenPower::RichenPower() : SerialDevice::SerialDevice() { + ASSERT_STORAGE_SIZE(RichenPacket, 70); + AP_Param::setup_object_defaults(this, var_info); u.packet.magic1 = 0xAA; diff --git a/libraries/SITL/SIM_RichenPower.h b/libraries/SITL/SIM_RichenPower.h index 1fa763fcf2..885c549238 100644 --- a/libraries/SITL/SIM_RichenPower.h +++ b/libraries/SITL/SIM_RichenPower.h @@ -124,7 +124,6 @@ private: uint8_t footermagic1; uint8_t footermagic2; }; - assert_storage_size _assert_storage_size_RichenPacket UNUSED_PRIVATE_MEMBER; union RichenUnion { uint8_t parse_buffer[70];