From 81f0b64ad32ffaf446ad9e3f937986711f353ac2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Mon, 6 Aug 2018 14:02:07 +0200 Subject: [PATCH] gps: add SER_GPS1_BAUD param to configure the baudrate The default is auto-detect, but some GPS devices might not like that, such as the Trimble MB-Two. --- src/drivers/gps/gps.cpp | 10 +++++++++- src/drivers/gps/params.c | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/drivers/gps/gps.cpp b/src/drivers/gps/gps.cpp index da1a8c7379..bde4f48347 100644 --- a/src/drivers/gps/gps.cpp +++ b/src/drivers/gps/gps.cpp @@ -618,6 +618,14 @@ GPS::run() param_get(handle, &gps_ubx_dynmodel); } + int32_t configured_baudrate = 0; // auto-detect + handle = param_find("SER_GPS1_BAUD"); + + if (handle != PARAM_INVALID) { + param_get(handle, &configured_baudrate); + } + + _orb_inject_data_fd = orb_subscribe(ORB_ID(gps_inject_data)); initializeCommunicationDump(); @@ -686,7 +694,7 @@ GPS::run() break; } - _baudrate = 0; // auto-detect + _baudrate = configured_baudrate; if (_helper && _helper->configure(_baudrate, GPSHelper::OutputMode::GPS) == 0) { diff --git a/src/drivers/gps/params.c b/src/drivers/gps/params.c index b6377cacb6..a898e7712d 100644 --- a/src/drivers/gps/params.c +++ b/src/drivers/gps/params.c @@ -85,3 +85,22 @@ PARAM_DEFINE_INT32(GPS_UBX_DYNMODEL, 7); * @group GPS */ PARAM_DEFINE_FLOAT(GPS_YAW_OFFSET, 0.f); + + +/** + * GPS Baudrate + * + * Configure the Baudrate for the GPS Serial Port. In most cases this can be set to Auto. + * + * The Trimble MB-Two GPS does not support auto-detection and uses a baudrate of 115200. + * + * @value 0 Auto + * @value 9600 9600 8N1 + * @value 19200 19200 8N1 + * @value 38400 38400 8N1 + * @value 57600 57600 8N1 + * @value 115200 115200 8N1 + * @reboot_required true + * @group GPS + */ +PARAM_DEFINE_INT32(SER_GPS1_BAUD, 0);