From ca97b9ba5f1754129177b853963df022bdebc271 Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Thu, 17 Feb 2022 02:30:25 -0500 Subject: [PATCH] drivers/gps: add new GPS_SAT_INFO parameter to enable satelitte_info - this replaces the command line argument -s --- src/drivers/gps/gps.cpp | 22 +++++++++------------- src/drivers/gps/params.c | 12 ++++++++++++ 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/drivers/gps/gps.cpp b/src/drivers/gps/gps.cpp index c2e210a7b0..7f7fac775e 100644 --- a/src/drivers/gps/gps.cpp +++ b/src/drivers/gps/gps.cpp @@ -117,7 +117,7 @@ public: Count }; - GPS(const char *path, gps_driver_mode_t mode, GPSHelper::Interface interface, bool enable_sat_info, Instance instance, + GPS(const char *path, gps_driver_mode_t mode, GPSHelper::Interface interface, Instance instance, unsigned configured_baudrate); ~GPS() override; @@ -279,8 +279,8 @@ px4::atomic GPS::_secondary_instance{nullptr}; extern "C" __EXPORT int gps_main(int argc, char *argv[]); -GPS::GPS(const char *path, gps_driver_mode_t mode, GPSHelper::Interface interface, bool enable_sat_info, - Instance instance, unsigned configured_baudrate) : +GPS::GPS(const char *path, gps_driver_mode_t mode, GPSHelper::Interface interface, Instance instance, + unsigned configured_baudrate) : Device(MODULE_NAME), _configured_baudrate(configured_baudrate), _mode(mode), @@ -295,6 +295,9 @@ GPS::GPS(const char *path, gps_driver_mode_t mode, GPSHelper::Interface interfac _report_gps_pos.heading = NAN; _report_gps_pos.heading_offset = NAN; + int32_t enable_sat_info = 0; + param_get(param_find("GPS_SAT_INFO"), &enable_sat_info); + /* create satellite info data object if requested */ if (enable_sat_info) { _sat_info = new GPS_Sat_Info(); @@ -1254,8 +1257,6 @@ $ gps reset warm PRINT_MODULE_USAGE_PARAM_STRING('e', nullptr, "", "Optional secondary GPS device", true); PRINT_MODULE_USAGE_PARAM_INT('g', 0, 0, 3000000, "Baudrate (secondary GPS, can also be p:)", true); - PRINT_MODULE_USAGE_PARAM_FLAG('s', "Enable publication of satellite info", true); - PRINT_MODULE_USAGE_PARAM_STRING('i', "uart", "spi|uart", "GPS interface", true); PRINT_MODULE_USAGE_PARAM_STRING('j', "uart", "spi|uart", "secondary GPS interface", true); PRINT_MODULE_USAGE_PARAM_STRING('p', nullptr, "ubx|mtk|ash|eml|fem|nmea", "GPS Protocol (default=auto select)", true); @@ -1324,7 +1325,6 @@ GPS *GPS::instantiate(int argc, char *argv[], Instance instance) const char *device_name_secondary = nullptr; int baudrate_main = 0; int baudrate_secondary = 0; - bool enable_sat_info = false; GPSHelper::Interface interface = GPSHelper::Interface::UART; GPSHelper::Interface interface_secondary = GPSHelper::Interface::UART; gps_driver_mode_t mode = gps_driver_mode_t::None; @@ -1334,7 +1334,7 @@ GPS *GPS::instantiate(int argc, char *argv[], Instance instance) int ch; const char *myoptarg = nullptr; - while ((ch = px4_getopt(argc, argv, "b:d:e:g:si:j:p:", &myoptind, &myoptarg)) != EOF) { + while ((ch = px4_getopt(argc, argv, "b:d:e:g:i:j:p:", &myoptind, &myoptarg)) != EOF) { switch (ch) { case 'b': if (px4_get_parameter_value(myoptarg, baudrate_main) != 0) { @@ -1357,10 +1357,6 @@ GPS *GPS::instantiate(int argc, char *argv[], Instance instance) device_name_secondary = myoptarg; break; - case 's': - enable_sat_info = true; - break; - case 'i': if (!strcmp(myoptarg, "spi")) { interface = GPSHelper::Interface::SPI; @@ -1430,7 +1426,7 @@ GPS *GPS::instantiate(int argc, char *argv[], Instance instance) GPS *gps = nullptr; if (instance == Instance::Main) { if (device_name && (access(device_name, R_OK|W_OK) == 0)) { - gps = new GPS(device_name, mode, interface, enable_sat_info, instance, baudrate_main); + gps = new GPS(device_name, mode, interface, instance, baudrate_main); } else { PX4_ERR("invalid device (-d) %s", device_name ? device_name : ""); @@ -1453,7 +1449,7 @@ GPS *GPS::instantiate(int argc, char *argv[], Instance instance) } } else { // secondary instance if (device_name_secondary && (access(device_name_secondary, R_OK|W_OK) == 0)) { - gps = new GPS(device_name_secondary, mode, interface_secondary, enable_sat_info, instance, baudrate_secondary); + gps = new GPS(device_name_secondary, mode, interface_secondary, instance, baudrate_secondary); } else { PX4_ERR("invalid secondary device (-g) %s", device_name_secondary ? device_name_secondary : ""); diff --git a/src/drivers/gps/params.c b/src/drivers/gps/params.c index bc224cfa66..25a0cb2934 100644 --- a/src/drivers/gps/params.c +++ b/src/drivers/gps/params.c @@ -69,6 +69,18 @@ PARAM_DEFINE_INT32(GPS_DUMP_COMM, 0); */ PARAM_DEFINE_INT32(GPS_UBX_DYNMODEL, 7); +/** + * Enable sat info (if available) + * + * Enable publication of satellite info (ORB_ID(satellite_info)) if possible. + * Not available on MTK. + * + * @boolean + * @reboot_required true + * @group GPS + */ +PARAM_DEFINE_INT32(GPS_SAT_INFO, 0); + /** * u-blox GPS Mode *