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:
Beat Küng 2016-04-25 13:08:21 +02:00 committed by Lorenz Meier
parent 58a7db51c3
commit b855d76f28

View File

@ -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) {
_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 */
_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 */
for (unsigned i = 0; (i < 10) && (_task != -1); i++) {
/* give it another 100ms */
@ -538,6 +534,10 @@ GPS::task_main()
fcntl(_serial_fd, F_SETFL, flags | O_NONBLOCK);
#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();
unsigned last_rate_count = 0;
@ -733,6 +733,11 @@ GPS::task_main()
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);
/* tell the dtor that we are exiting */