mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-07 10:30:34 +08:00
logger: change message id from uint16_t to uint8_t
256 subscriptions are enough for now. Reduces RAM usage by 300 bytes.
This commit is contained in:
@@ -1752,7 +1752,12 @@ void Logger::write_add_logged_msg(LoggerSubscription &subscription, int instance
|
||||
{
|
||||
ulog_message_add_logged_s msg;
|
||||
|
||||
if (subscription.msg_ids[instance] == (uint16_t) - 1) {
|
||||
if (subscription.msg_ids[instance] == (uint8_t) - 1) {
|
||||
if (_next_topic_id == (uint8_t) - 1) {
|
||||
// if we land here an uint8 is too small -> switch to uint16
|
||||
PX4_ERR("limit for _next_topic_id reached");
|
||||
return;
|
||||
}
|
||||
subscription.msg_ids[instance] = _next_topic_id++;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,8 +75,8 @@ inline bool operator&(SDLogProfileMask a, SDLogProfileMask b)
|
||||
struct LoggerSubscription {
|
||||
int fd[ORB_MULTI_MAX_INSTANCES]; ///< uorb subscription. The first fd is also used to store the interval if
|
||||
/// not subscribed yet (-interval - 1)
|
||||
uint16_t msg_ids[ORB_MULTI_MAX_INSTANCES];
|
||||
const orb_metadata *metadata = nullptr;
|
||||
uint8_t msg_ids[ORB_MULTI_MAX_INSTANCES];
|
||||
|
||||
LoggerSubscription() {}
|
||||
|
||||
@@ -90,7 +90,7 @@ struct LoggerSubscription {
|
||||
}
|
||||
|
||||
for (int i = 0; i < ORB_MULTI_MAX_INSTANCES; i++) {
|
||||
msg_ids[i] = (uint16_t) - 1;
|
||||
msg_ids[i] = (uint8_t) - 1;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -330,7 +330,7 @@ private:
|
||||
uint32_t _log_interval{0};
|
||||
const orb_metadata *_polling_topic_meta{nullptr}; ///< if non-null, poll on this topic instead of sleeping
|
||||
orb_advert_t _mavlink_log_pub{nullptr};
|
||||
uint16_t _next_topic_id{0}; ///< id of next subscribed ulog topic
|
||||
uint8_t _next_topic_id{0}; ///< id of next subscribed ulog topic
|
||||
char *_replay_file_name{nullptr};
|
||||
bool _should_stop_file_log{false}; /**< if true _next_load_print is set and file logging
|
||||
will be stopped after load printing */
|
||||
|
||||
Reference in New Issue
Block a user