mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-23 05:23:33 +08:00
mavlink: remove typedef of anonymous struct
Clang doesn't seem to like these.
This commit is contained in:
@@ -87,7 +87,7 @@ int MavlinkCommandSender::handle_vehicle_command(const struct vehicle_command_s
|
|||||||
bool already_existing = false;
|
bool already_existing = false;
|
||||||
_commands.reset_to_start();
|
_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) {
|
if (item->timestamp_us == command.timestamp) {
|
||||||
|
|
||||||
// We should activate the channel by setting num_sent_per_channel from -1 to 0.
|
// 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
|
|||||||
|
|
||||||
if (!already_existing) {
|
if (!already_existing) {
|
||||||
|
|
||||||
command_item_t new_item;
|
command_item_s new_item;
|
||||||
new_item.command = msg;
|
new_item.command = msg;
|
||||||
new_item.timestamp_us = command.timestamp;
|
new_item.timestamp_us = command.timestamp;
|
||||||
new_item.num_sent_per_channel[channel] = 0;
|
new_item.num_sent_per_channel[channel] = 0;
|
||||||
@@ -120,7 +120,7 @@ void MavlinkCommandSender::handle_mavlink_command_ack(const mavlink_command_ack_
|
|||||||
|
|
||||||
_commands.reset_to_start();
|
_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.
|
// Check if the incoming ack matches any of the commands that we have sent.
|
||||||
if (item->command.command == ack.command &&
|
if (item->command.command == ack.command &&
|
||||||
(item->command.target_system == 0 || from_sysid == item->command.target_system) &&
|
(item->command.target_system == 0 || from_sysid == item->command.target_system) &&
|
||||||
@@ -140,7 +140,7 @@ void MavlinkCommandSender::check_timeout(mavlink_channel_t channel)
|
|||||||
|
|
||||||
_commands.reset_to_start();
|
_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) {
|
if (hrt_elapsed_time(&item->last_time_sent_us) <= TIMEOUT_US) {
|
||||||
// We keep waiting for the timeout.
|
// We keep waiting for the timeout.
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -105,14 +105,14 @@ private:
|
|||||||
// There are MAVLINK_COMM_0 to MAVLINK_COMM_3, so it should be 4.
|
// There are MAVLINK_COMM_0 to MAVLINK_COMM_3, so it should be 4.
|
||||||
static const unsigned MAX_MAVLINK_CHANNEL = 4;
|
static const unsigned MAX_MAVLINK_CHANNEL = 4;
|
||||||
|
|
||||||
typedef struct {
|
struct command_item_s {
|
||||||
mavlink_command_long_t command = {};
|
mavlink_command_long_t command = {};
|
||||||
hrt_abstime timestamp_us = 0;
|
hrt_abstime timestamp_us = 0;
|
||||||
hrt_abstime last_time_sent_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
|
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;
|
bool _debug_enabled = false;
|
||||||
static constexpr uint8_t RETRIES = 3;
|
static constexpr uint8_t RETRIES = 3;
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class TimestampedList
|
|||||||
public:
|
public:
|
||||||
TimestampedList(int num_items)
|
TimestampedList(int num_items)
|
||||||
{
|
{
|
||||||
_list = new item_t[num_items];
|
_list = new item_s[num_items];
|
||||||
_list_len = num_items;
|
_list_len = num_items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,12 +148,12 @@ public:
|
|||||||
TimestampedList operator=(const TimestampedList &) = delete;
|
TimestampedList operator=(const TimestampedList &) = delete;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef struct {
|
struct item_s {
|
||||||
hrt_abstime timestamp_us = 0; // 0 signals inactive.
|
hrt_abstime timestamp_us = 0; // 0 signals inactive.
|
||||||
T value;
|
T value;
|
||||||
} item_t;
|
};
|
||||||
|
|
||||||
item_t *_list = nullptr;
|
item_s *_list = nullptr;
|
||||||
int _list_len = 0;
|
int _list_len = 0;
|
||||||
int _current_i = -1;
|
int _current_i = -1;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user