mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-17 07:43:34 +08:00
gps & mavlink receiver: use C arrays instead of std::array<>
This commit is contained in:
@@ -59,7 +59,6 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <array>
|
||||
#include <poll.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
@@ -131,7 +130,8 @@ private:
|
||||
float _rate; ///< position update rate
|
||||
bool _fake_gps; ///< fake gps output
|
||||
|
||||
std::array<int, 4> _orb_inject_data_fd;
|
||||
static const int _orb_inject_data_fd_count = 4;
|
||||
int _orb_inject_data_fd[_orb_inject_data_fd_count];
|
||||
int _orb_inject_data_next = 0;
|
||||
|
||||
/**
|
||||
@@ -238,7 +238,7 @@ GPS::GPS(const char *uart_path, bool fake_gps, bool enable_sat_info) :
|
||||
memset(_p_report_sat_info, 0, sizeof(*_p_report_sat_info));
|
||||
}
|
||||
|
||||
for (int i = 0; i < _orb_inject_data_fd.size(); ++i) {
|
||||
for (int i = 0; i < _orb_inject_data_fd_count; ++i) {
|
||||
_orb_inject_data_fd[i] = orb_subscribe_multi(ORB_ID(gps_inject_data), i);
|
||||
}
|
||||
}
|
||||
@@ -248,7 +248,7 @@ GPS::~GPS()
|
||||
/* tell the task we want it to go away */
|
||||
_task_should_exit = true;
|
||||
|
||||
for (size_t i = 0; i < _orb_inject_data_fd.size(); ++i) {
|
||||
for (size_t i = 0; i < _orb_inject_data_fd_count; ++i) {
|
||||
orb_unsubscribe(_orb_inject_data_fd[i]);
|
||||
}
|
||||
|
||||
@@ -384,7 +384,7 @@ void GPS::handleInjectDataTopic()
|
||||
orb_copy(ORB_ID(gps_inject_data), orb_inject_data_cur_fd, &msg);
|
||||
injectData(msg.data, msg.len);
|
||||
|
||||
_orb_inject_data_next = (_orb_inject_data_next + 1) % _orb_inject_data_fd.size();
|
||||
_orb_inject_data_next = (_orb_inject_data_next + 1) % _orb_inject_data_fd_count;
|
||||
|
||||
}
|
||||
} while (updated);
|
||||
|
||||
@@ -125,7 +125,6 @@ MavlinkReceiver::MavlinkReceiver(Mavlink *parent) :
|
||||
_time_offset_pub(nullptr),
|
||||
_follow_target_pub(nullptr),
|
||||
_transponder_report_pub(nullptr),
|
||||
_gps_inject_data_pub(),
|
||||
_control_mode_sub(orb_subscribe(ORB_ID(vehicle_control_mode))),
|
||||
_hil_frames(0),
|
||||
_old_timestamp(0),
|
||||
@@ -144,7 +143,9 @@ MavlinkReceiver::MavlinkReceiver(Mavlink *parent) :
|
||||
_mom_switch_pos{},
|
||||
_mom_switch_state(0)
|
||||
{
|
||||
_gps_inject_data_pub.fill(nullptr);
|
||||
for (int i = 0; i < _gps_inject_data_pub_size; ++i) {
|
||||
_gps_inject_data_pub[i] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
MavlinkReceiver::~MavlinkReceiver()
|
||||
@@ -1784,7 +1785,7 @@ void MavlinkReceiver::handle_message_gps_inject_data(mavlink_message_t *msg)
|
||||
orb_publish(ORB_ID(gps_inject_data), pub, &gps_inject_data_topic);
|
||||
}
|
||||
|
||||
_gps_inject_data_next_idx = (_gps_inject_data_next_idx + 1) % _gps_inject_data_pub.size();
|
||||
_gps_inject_data_next_idx = (_gps_inject_data_next_idx + 1) % _gps_inject_data_pub_size;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -78,8 +78,6 @@
|
||||
#include <uORB/topics/transponder_report.h>
|
||||
#include <uORB/topics/gps_inject_data.h>
|
||||
|
||||
#include <array>
|
||||
|
||||
#include "mavlink_ftp.h"
|
||||
|
||||
#define PX4_EPOCH_SECS 1234567890ULL
|
||||
@@ -207,7 +205,8 @@ private:
|
||||
orb_advert_t _time_offset_pub;
|
||||
orb_advert_t _follow_target_pub;
|
||||
orb_advert_t _transponder_report_pub;
|
||||
std::array<orb_advert_t, 4> _gps_inject_data_pub;
|
||||
static const int _gps_inject_data_pub_size = 4;
|
||||
orb_advert_t _gps_inject_data_pub[_gps_inject_data_pub_size];
|
||||
int _gps_inject_data_next_idx = 0;
|
||||
int _control_mode_sub;
|
||||
int _hil_frames;
|
||||
|
||||
Reference in New Issue
Block a user