mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-31 18:47:21 +08:00
GPS driver update to uORB::Subscription
This commit is contained in:
+5
-15
@@ -75,7 +75,7 @@
|
|||||||
#include <matrix/math.hpp>
|
#include <matrix/math.hpp>
|
||||||
#include <systemlib/err.h>
|
#include <systemlib/err.h>
|
||||||
#include <parameters/param.h>
|
#include <parameters/param.h>
|
||||||
#include <uORB/uORB.h>
|
#include <uORB/Subscription.hpp>
|
||||||
#include <uORB/topics/vehicle_gps_position.h>
|
#include <uORB/topics/vehicle_gps_position.h>
|
||||||
#include <uORB/topics/satellite_info.h>
|
#include <uORB/topics/satellite_info.h>
|
||||||
#include <uORB/topics/gps_inject_data.h>
|
#include <uORB/topics/gps_inject_data.h>
|
||||||
@@ -198,7 +198,7 @@ private:
|
|||||||
|
|
||||||
const Instance _instance;
|
const Instance _instance;
|
||||||
|
|
||||||
int _orb_inject_data_fd{-1};
|
uORB::Subscription _orb_inject_data_sub{ORB_ID(gps_inject_data)};
|
||||||
orb_advert_t _dump_communication_pub{nullptr}; ///< if non-null, dump communication
|
orb_advert_t _dump_communication_pub{nullptr}; ///< if non-null, dump communication
|
||||||
gps_dump_s *_dump_to_device{nullptr};
|
gps_dump_s *_dump_to_device{nullptr};
|
||||||
gps_dump_s *_dump_from_device{nullptr};
|
gps_dump_s *_dump_from_device{nullptr};
|
||||||
@@ -439,18 +439,14 @@ int GPS::pollOrRead(uint8_t *buf, size_t buf_length, int timeout)
|
|||||||
|
|
||||||
void GPS::handleInjectDataTopic()
|
void GPS::handleInjectDataTopic()
|
||||||
{
|
{
|
||||||
if (_orb_inject_data_fd == -1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool updated = false;
|
bool updated = false;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
orb_check(_orb_inject_data_fd, &updated);
|
updated = _orb_inject_data_sub.updated();
|
||||||
|
|
||||||
if (updated) {
|
if (updated) {
|
||||||
struct gps_inject_data_s msg;
|
gps_inject_data_s msg;
|
||||||
orb_copy(ORB_ID(gps_inject_data), _orb_inject_data_fd, &msg);
|
_orb_inject_data_sub.copy(&msg);
|
||||||
|
|
||||||
/* Write the message to the gps device. Note that the message could be fragmented.
|
/* Write the message to the gps device. Note that the message could be fragmented.
|
||||||
* But as we don't write anywhere else to the device during operation, we don't
|
* But as we don't write anywhere else to the device during operation, we don't
|
||||||
@@ -668,8 +664,6 @@ GPS::run()
|
|||||||
param_get(handle, &gps_ubx_dynmodel);
|
param_get(handle, &gps_ubx_dynmodel);
|
||||||
}
|
}
|
||||||
|
|
||||||
_orb_inject_data_fd = orb_subscribe(ORB_ID(gps_inject_data));
|
|
||||||
|
|
||||||
initializeCommunicationDump();
|
initializeCommunicationDump();
|
||||||
|
|
||||||
uint64_t last_rate_measurement = hrt_absolute_time();
|
uint64_t last_rate_measurement = hrt_absolute_time();
|
||||||
@@ -853,8 +847,6 @@ GPS::run()
|
|||||||
|
|
||||||
PX4_INFO("exiting");
|
PX4_INFO("exiting");
|
||||||
|
|
||||||
orb_unsubscribe(_orb_inject_data_fd);
|
|
||||||
|
|
||||||
if (_dump_communication_pub) {
|
if (_dump_communication_pub) {
|
||||||
orb_unadvertise(_dump_communication_pub);
|
orb_unadvertise(_dump_communication_pub);
|
||||||
}
|
}
|
||||||
@@ -867,8 +859,6 @@ GPS::run()
|
|||||||
orb_unadvertise(_report_gps_pos_pub);
|
orb_unadvertise(_report_gps_pos_pub);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
GPS::print_status()
|
GPS::print_status()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user