mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-01 02:55:07 +08:00
gps: make sure the gps module compiles for POSIX & add it to the posix_sitl_default cmake
- Note that the simulator still uses gpssim by default
- now the gps module can be used in the SITL. this makes it possible to test
the real gps HW under POSIX
additional steps needed to use it:
- in the rcS_jmavsim_iris, make sure to start the gps instead of gpssim:
gps start -d /dev/ttyACM0 -s
- disable the mavlink serial connection in simulator_mavlink.cpp,
openUart(PIXHAWK_DEVICE, 115200);
- this also fixes a memory leak in the gps module
This commit is contained in:
@@ -11,6 +11,7 @@ set(config_module_list
|
||||
platforms/posix/work_queue
|
||||
platforms/posix/drivers/adcsim
|
||||
platforms/posix/drivers/gpssim
|
||||
drivers/gps
|
||||
platforms/posix/drivers/tonealrmsim
|
||||
platforms/posix/drivers/accelsim
|
||||
platforms/posix/drivers/airspeedsim
|
||||
|
||||
@@ -37,8 +37,10 @@
|
||||
*/
|
||||
|
||||
#ifndef __PX4_QURT
|
||||
#ifdef __PX4_NUTTX
|
||||
#include <nuttx/clock.h>
|
||||
#include <nuttx/arch.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
@@ -190,7 +192,7 @@ GPS::GPS(const char *uart_path, bool fake_gps, bool enable_sat_info) :
|
||||
|
||||
/* create satellite info data object if requested */
|
||||
if (enable_sat_info) {
|
||||
_Sat_Info = new(GPS_Sat_Info);
|
||||
_Sat_Info = new GPS_Sat_Info();
|
||||
_p_report_sat_info = &_Sat_Info->_data;
|
||||
memset(_p_report_sat_info, 0, sizeof(*_p_report_sat_info));
|
||||
}
|
||||
@@ -212,6 +214,8 @@ GPS::~GPS()
|
||||
px4_task_delete(_task);
|
||||
}
|
||||
|
||||
if (_Sat_Info) delete (_Sat_Info);
|
||||
|
||||
g_dev = nullptr;
|
||||
|
||||
}
|
||||
@@ -245,13 +249,11 @@ GPS::task_main()
|
||||
_serial_fd = ::open(_port, O_RDWR);
|
||||
|
||||
if (_serial_fd < 0) {
|
||||
while (true) {
|
||||
PX4_WARN("failed to open serial port: %s err: %d", _port, errno);
|
||||
}
|
||||
PX4_ERR("GPS: failed to open serial port: %s err: %d", _port, errno);
|
||||
|
||||
/* tell the dtor that we are exiting, set error code */
|
||||
_task = -1;
|
||||
exit(1);
|
||||
px4_task_exit(1);
|
||||
}
|
||||
|
||||
#ifndef __PX4_QURT
|
||||
@@ -617,12 +619,11 @@ void
|
||||
info()
|
||||
{
|
||||
if (g_dev == nullptr) {
|
||||
errx(1, "not running");
|
||||
PX4_ERR("GPS Not running");
|
||||
return;
|
||||
}
|
||||
|
||||
g_dev->print_info();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user