Skip to content

Commit

Permalink
SITL: add ASSERT_STORAGE_SIZE macro
Browse files Browse the repository at this point in the history
saves havin gto name the dummy variable yourself
  • Loading branch information
peterbarker committed Jan 22, 2024
1 parent cedcd19 commit bddb9aa
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 21 deletions.
18 changes: 6 additions & 12 deletions libraries/SITL/SIM_ADSB_Sagetech_MXS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Installation, 36> _assert_storage_size_Installation;
(void)_assert_storage_size_Installation;
ASSERT_STORAGE_SIZE(Installation, 36);

if (operating_mode != OperatingMode::OFF &&
operating_mode != OperatingMode::MAINTENANCE) {
Expand Down Expand Up @@ -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<FlightIDMessage, 12> _assert_storage_size_FlightIDMessage;
(void)_assert_storage_size_FlightIDMessage;
ASSERT_STORAGE_SIZE(FlightIDMessage, 12);

// do something!
flight_id_set_time_ms = AP_HAL::millis();
Expand All @@ -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<Operating, 12> _assert_storage_size_Operating;
(void)_assert_storage_size_Operating;
ASSERT_STORAGE_SIZE(Operating, 12);

// do something!

Expand All @@ -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<GPS, 63> _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);
Expand All @@ -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<DataRequest, 4> _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
Expand All @@ -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<TargetRequest, 7> _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

Expand Down
9 changes: 3 additions & 6 deletions libraries/SITL/SIM_EFI_Hirth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,7 @@ void SITL::EFI_Hirth::send_record1()

write_to_autopilot((char*)&packed_record1, sizeof(packed_record1));

assert_storage_size<Record1, 84> _assert_storage_size_Record1;
(void)_assert_storage_size_Record1;
ASSERT_STORAGE_SIZE(Record1, 84);
}

void SITL::EFI_Hirth::send_record2()
Expand All @@ -224,8 +223,7 @@ void SITL::EFI_Hirth::send_record2()

write_to_autopilot((char*)&packed_record2, sizeof(packed_record2));

assert_storage_size<Record2, 98> _assert_storage_size_Record2;
(void)_assert_storage_size_Record2;
ASSERT_STORAGE_SIZE(Record2, 98);
}


Expand All @@ -243,6 +241,5 @@ void SITL::EFI_Hirth::send_record3()

write_to_autopilot((char*)&packed_record3, sizeof(packed_record3));

assert_storage_size<Record3, 100> _assert_storage_size_Record3;
(void)_assert_storage_size_Record3;
ASSERT_STORAGE_SIZE(Record3, 100);
}
3 changes: 1 addition & 2 deletions libraries/SITL/SIM_Invensense_v3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

void SITL::InvensenseV3::update(const class Aircraft &aircraft)
{
assert_storage_size<FIFOData, 16> _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();
Expand Down
2 changes: 2 additions & 0 deletions libraries/SITL/SIM_RichenPower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion libraries/SITL/SIM_RichenPower.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ class RichenPower : public SerialDevice {
uint8_t footermagic1;
uint8_t footermagic2;
};
assert_storage_size<RichenPacket, 70> _assert_storage_size_RichenPacket UNUSED_PRIVATE_MEMBER;

union RichenUnion {
uint8_t parse_buffer[70];
Expand Down

0 comments on commit bddb9aa

Please sign in to comment.