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:
Beat Küng
2018-10-17 15:59:50 +02:00
parent d6e820fe67
commit 28ac7679e0
2 changed files with 9 additions and 4 deletions
+6 -1
View File
@@ -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++;
}
+3 -3
View File
@@ -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 */