From f733110af1c4ccb2e0304d89f01135c3645eedda Mon Sep 17 00:00:00 2001 From: BLash Date: Thu, 18 Jul 2024 20:37:18 -0500 Subject: [PATCH] AP_ExternalAHRS_VectorNav: Resolve SITL failures Fix bug causing pointer to stack variable to be maintained --- libraries/AP_ExternalAHRS/AP_ExternalAHRS_VectorNav.cpp | 4 ++-- libraries/AP_ExternalAHRS/AP_ExternalAHRS_VectorNav.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/AP_ExternalAHRS/AP_ExternalAHRS_VectorNav.cpp b/libraries/AP_ExternalAHRS/AP_ExternalAHRS_VectorNav.cpp index 9b8aaf9b670827..3e58710799d031 100644 --- a/libraries/AP_ExternalAHRS/AP_ExternalAHRS_VectorNav.cpp +++ b/libraries/AP_ExternalAHRS/AP_ExternalAHRS_VectorNav.cpp @@ -602,7 +602,7 @@ void AP_ExternalAHRS_VectorNav::process_ins_ekf_packet(const uint8_t *b) { const struct VN_INS_ekf_packet &pkt = *(struct VN_INS_ekf_packet *)b; last_pkt2_ms = AP_HAL::millis(); - latest_ins_ekf_packet = &pkt; + *latest_ins_ekf_packet = pkt; state.quat = Quaternion{pkt.quaternion[3], pkt.quaternion[0], pkt.quaternion[1], pkt.quaternion[2]}; state.have_quaternion = true; @@ -670,7 +670,7 @@ void AP_ExternalAHRS_VectorNav::process_ins_gnss_packet(const uint8_t *b) { last_pkt3_ms = AP_HAL::millis(); - latest_ins_gnss_packet = &pkt; + *latest_ins_gnss_packet = pkt; // get ToW in milliseconds gps.gps_week = pkt.timeGps / (AP_MSEC_PER_WEEK * 1000000ULL); diff --git a/libraries/AP_ExternalAHRS/AP_ExternalAHRS_VectorNav.h b/libraries/AP_ExternalAHRS/AP_ExternalAHRS_VectorNav.h index a70bec210dc29e..456090d205f00a 100644 --- a/libraries/AP_ExternalAHRS/AP_ExternalAHRS_VectorNav.h +++ b/libraries/AP_ExternalAHRS/AP_ExternalAHRS_VectorNav.h @@ -73,9 +73,9 @@ class AP_ExternalAHRS_VectorNav : public AP_ExternalAHRS_backend { uint16_t pktoffset; uint16_t bufsize; - struct VN_imu_packet const *latest_imu_packet = nullptr; - struct VN_INS_ekf_packet const *latest_ins_ekf_packet = nullptr; - struct VN_INS_gnss_packet const *latest_ins_gnss_packet = nullptr; + struct VN_imu_packet *latest_imu_packet = nullptr; + struct VN_INS_ekf_packet *latest_ins_ekf_packet = nullptr; + struct VN_INS_gnss_packet *latest_ins_gnss_packet = nullptr; uint32_t last_pkt1_ms = UINT32_MAX; uint32_t last_pkt2_ms = UINT32_MAX;