From 8d17b8dbe7f8b8f691c26018c17df7de59f9b77d Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Mon, 10 Jan 2022 09:38:04 +1100 Subject: [PATCH] AP_GPS: use const structure for saving GPS config --- libraries/AP_GPS/AP_GPS_UBLOX.cpp | 11 ++++++----- libraries/AP_GPS/AP_GPS_UBLOX.h | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/libraries/AP_GPS/AP_GPS_UBLOX.cpp b/libraries/AP_GPS/AP_GPS_UBLOX.cpp index 2c7c74ed24..4ff67aa0f8 100644 --- a/libraries/AP_GPS/AP_GPS_UBLOX.cpp +++ b/libraries/AP_GPS/AP_GPS_UBLOX.cpp @@ -1552,7 +1552,7 @@ AP_GPS_UBLOX::_update_checksum(uint8_t *data, uint16_t len, uint8_t &ck_a, uint8 * send a ublox message */ bool -AP_GPS_UBLOX::_send_message(uint8_t msg_class, uint8_t msg_id, void *msg, uint16_t size) +AP_GPS_UBLOX::_send_message(uint8_t msg_class, uint8_t msg_id, const void *msg, uint16_t size) { if (port->txspace() < (sizeof(struct ubx_header) + 2 + size)) { return false; @@ -1697,10 +1697,11 @@ AP_GPS_UBLOX::_configure_config_set(const config_list *list, uint8_t count, uint void AP_GPS_UBLOX::_save_cfg() { - ubx_cfg_cfg save_cfg; - save_cfg.clearMask = 0; - save_cfg.saveMask = SAVE_CFG_ALL; - save_cfg.loadMask = 0; + static const ubx_cfg_cfg save_cfg { + clearMask: 0, + saveMask: SAVE_CFG_ALL, + loadMask: 0 + }; _send_message(CLASS_CFG, MSG_CFG_CFG, &save_cfg, sizeof(save_cfg)); _last_cfg_sent_time = AP_HAL::millis(); _num_cfg_save_tries++; diff --git a/libraries/AP_GPS/AP_GPS_UBLOX.h b/libraries/AP_GPS/AP_GPS_UBLOX.h index 493a0f3192..ec4f68d3b8 100644 --- a/libraries/AP_GPS/AP_GPS_UBLOX.h +++ b/libraries/AP_GPS/AP_GPS_UBLOX.h @@ -715,7 +715,7 @@ private: void _configure_rate(void); void _configure_sbas(bool enable); void _update_checksum(uint8_t *data, uint16_t len, uint8_t &ck_a, uint8_t &ck_b); - bool _send_message(uint8_t msg_class, uint8_t msg_id, void *msg, uint16_t size); + bool _send_message(uint8_t msg_class, uint8_t msg_id, const void *msg, uint16_t size); void send_next_rate_update(void); bool _request_message_rate(uint8_t msg_class, uint8_t msg_id); void _request_next_config(void);