Browse Source

mavlink: remove typedef of anonymous struct

Clang doesn't seem to like these.
release/1.12
Julian Oes 4 years ago committed by Daniel Agar
parent
commit
a2ff53b018
  1. 8
      src/modules/mavlink/mavlink_command_sender.cpp
  2. 6
      src/modules/mavlink/mavlink_command_sender.h
  3. 8
      src/modules/mavlink/timestamped_list.h

8
src/modules/mavlink/mavlink_command_sender.cpp

@ -87,7 +87,7 @@ int MavlinkCommandSender::handle_vehicle_command(const struct vehicle_command_s @@ -87,7 +87,7 @@ int MavlinkCommandSender::handle_vehicle_command(const struct vehicle_command_s
bool already_existing = false;
_commands.reset_to_start();
while (command_item_t *item = _commands.get_next()) {
while (command_item_s *item = _commands.get_next()) {
if (item->timestamp_us == command.timestamp) {
// We should activate the channel by setting num_sent_per_channel from -1 to 0.
@ -99,7 +99,7 @@ int MavlinkCommandSender::handle_vehicle_command(const struct vehicle_command_s @@ -99,7 +99,7 @@ int MavlinkCommandSender::handle_vehicle_command(const struct vehicle_command_s
if (!already_existing) {
command_item_t new_item;
command_item_s new_item;
new_item.command = msg;
new_item.timestamp_us = command.timestamp;
new_item.num_sent_per_channel[channel] = 0;
@ -120,7 +120,7 @@ void MavlinkCommandSender::handle_mavlink_command_ack(const mavlink_command_ack_ @@ -120,7 +120,7 @@ void MavlinkCommandSender::handle_mavlink_command_ack(const mavlink_command_ack_
_commands.reset_to_start();
while (command_item_t *item = _commands.get_next()) {
while (command_item_s *item = _commands.get_next()) {
// Check if the incoming ack matches any of the commands that we have sent.
if (item->command.command == ack.command &&
(item->command.target_system == 0 || from_sysid == item->command.target_system) &&
@ -140,7 +140,7 @@ void MavlinkCommandSender::check_timeout(mavlink_channel_t channel) @@ -140,7 +140,7 @@ void MavlinkCommandSender::check_timeout(mavlink_channel_t channel)
_commands.reset_to_start();
while (command_item_t *item = _commands.get_next()) {
while (command_item_s *item = _commands.get_next()) {
if (hrt_elapsed_time(&item->last_time_sent_us) <= TIMEOUT_US) {
// We keep waiting for the timeout.
continue;

6
src/modules/mavlink/mavlink_command_sender.h

@ -105,14 +105,14 @@ private: @@ -105,14 +105,14 @@ private:
// There are MAVLINK_COMM_0 to MAVLINK_COMM_3, so it should be 4.
static const unsigned MAX_MAVLINK_CHANNEL = 4;
typedef struct {
struct command_item_s {
mavlink_command_long_t command = {};
hrt_abstime timestamp_us = 0;
hrt_abstime last_time_sent_us = 0;
int8_t num_sent_per_channel[MAX_MAVLINK_CHANNEL] = {-1, -1, -1, -1}; // -1: channel did not request this command to be sent, -2: channel got an ack for this command
} command_item_t;
};
TimestampedList<command_item_t> _commands{3};
TimestampedList<command_item_s> _commands{3};
bool _debug_enabled = false;
static constexpr uint8_t RETRIES = 3;

8
src/modules/mavlink/timestamped_list.h

@ -55,7 +55,7 @@ class TimestampedList @@ -55,7 +55,7 @@ class TimestampedList
public:
TimestampedList(int num_items)
{
_list = new item_t[num_items];
_list = new item_s[num_items];
_list_len = num_items;
}
@ -148,12 +148,12 @@ public: @@ -148,12 +148,12 @@ public:
TimestampedList operator=(const TimestampedList &) = delete;
private:
typedef struct {
struct item_s {
hrt_abstime timestamp_us = 0; // 0 signals inactive.
T value;
} item_t;
};
item_t *_list = nullptr;
item_s *_list = nullptr;
int _list_len = 0;
int _current_i = -1;
};

Loading…
Cancel
Save