mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-27 04:03:34 +08:00
fix gps: subscribe to topics in the gps thread instead of the shell thread
NuttX does not inherit file descriptors when creating new tasks.
This commit is contained in:
+10
-5
@@ -244,7 +244,7 @@ GPS::GPS(const char *uart_path, bool fake_gps, bool enable_sat_info) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < _orb_inject_data_fd_count; ++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);
|
_orb_inject_data_fd[i] = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,10 +253,6 @@ GPS::~GPS()
|
|||||||
/* tell the task we want it to go away */
|
/* tell the task we want it to go away */
|
||||||
_task_should_exit = true;
|
_task_should_exit = true;
|
||||||
|
|
||||||
for (size_t i = 0; i < _orb_inject_data_fd_count; ++i) {
|
|
||||||
orb_unsubscribe(_orb_inject_data_fd[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* spin waiting for the task to stop */
|
/* spin waiting for the task to stop */
|
||||||
for (unsigned i = 0; (i < 10) && (_task != -1); i++) {
|
for (unsigned i = 0; (i < 10) && (_task != -1); i++) {
|
||||||
/* give it another 100ms */
|
/* give it another 100ms */
|
||||||
@@ -538,6 +534,10 @@ GPS::task_main()
|
|||||||
fcntl(_serial_fd, F_SETFL, flags | O_NONBLOCK);
|
fcntl(_serial_fd, F_SETFL, flags | O_NONBLOCK);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t last_rate_measurement = hrt_absolute_time();
|
uint64_t last_rate_measurement = hrt_absolute_time();
|
||||||
unsigned last_rate_count = 0;
|
unsigned last_rate_count = 0;
|
||||||
|
|
||||||
@@ -733,6 +733,11 @@ GPS::task_main()
|
|||||||
|
|
||||||
PX4_WARN("exiting");
|
PX4_WARN("exiting");
|
||||||
|
|
||||||
|
for (size_t i = 0; i < _orb_inject_data_fd_count; ++i) {
|
||||||
|
orb_unsubscribe(_orb_inject_data_fd[i]);
|
||||||
|
_orb_inject_data_fd[i] = -1;
|
||||||
|
}
|
||||||
|
|
||||||
::close(_serial_fd);
|
::close(_serial_fd);
|
||||||
|
|
||||||
/* tell the dtor that we are exiting */
|
/* tell the dtor that we are exiting */
|
||||||
|
|||||||
Reference in New Issue
Block a user