Skip to content

Commit 6ae3cc9

Browse files
linguini1jerpelea
authored andcommitted
drivers/sensors/l86xxx: Make some dependency patches and update documentation
This commit removes the termios dependency of the command to set fix rate. It makes the MINMEA dependency present in the Kconfig options for the driver, and it also adds a retry limit to the boot message verification of 3 times. The documentation has been updated to reflect the correct signature for the registration function and fix some formatting. Signed-off-by: Matteo Golin <[email protected]>
1 parent 0d834b0 commit 6ae3cc9

File tree

3 files changed

+96
-61
lines changed

3 files changed

+96
-61
lines changed

Documentation/components/drivers/special/sensors/l86xxx.rst

Lines changed: 53 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,57 +23,76 @@ the path to the UART interface the module is connected to. You will also need to
2323
ensure that the baud rate of the UART interface is set to 9600, which is the default
2424
baud rate of the L86-XXX series of GNSS modules.
2525

26-
The driver supports changing the default baud rate and update rate of the GNSS module.
27-
As a result, you will also need to enable serial TERMIOS support (``CONFIG_SERIAL_TERMIOS``).
28-
The baud rate and update rate of the GNSS module can be configured using the ``L86_XXX_BAUD`` and ``L86_XXX_FIX_INT`` options respectively.
29-
Note that a faster update rate will require a higher baud rate to support it and the supported baud rates for the L86-XXX series of GNSS modules are:
26+
The driver supports changing the default baud rate and update rate of the GNSS
27+
module. As a result, you will also need to enable serial TERMIOS support
28+
(``CONFIG_SERIAL_TERMIOS``). The baud rate and update rate of the GNSS module
29+
can be configured using the ``L86_XXX_BAUD`` and ``L86_XXX_FIX_INT`` options
30+
respectively. Note that a faster update rate will require a higher baud rate to
31+
support it and the supported baud rates for the L86-XXX series of GNSS modules
32+
are:
33+
3034
* 4800
3135
* 9600
3236
* 14400
3337
* 19200
3438
* 38400
3539
* 57600
3640
* 115200
41+
3742
The baud rate and update rates of the module are changed at registration time.
3843

3944
.. code-block:: c
4045
4146
#if defined(CONFIG_SENSORS_L86_XXX)
4247
#include <nuttx/sensors/l86xxx.h>
4348
44-
/* Register L86-M33 on USART3 */
49+
/* Register L86xxx device on USART2 */
4550
46-
ret = l86xxx_register("/dev/l86m33", "/dev/ttyS2", 0);
51+
ret = l86xxx_register("/dev/ttyS2", 0);
4752
if (ret < 0) {
4853
syslog(LOG_ERR, "Failed to register L86-M33: %d\n", ret);
4954
}
5055
#endif
5156
52-
Once the driver is registered, it starts a thread that continuously reads raw output from the specified UART device and
53-
parses the output according to `NMEA <https://en.wikipedia.org/wiki/NMEA_0183>`_ standards using the
54-
`minmea <https://github.com/kosma/minmea>`_ library included in NuttX. The driver populates the ``sensor_gnss`` struct
55-
and pushes it to the appropriate event once all NMEA messages in its sequence have been read.
57+
Once the driver is registered, it starts a thread that continuously reads raw
58+
output from the specified UART device and parses the output according to `NMEA
59+
<https://en.wikipedia.org/wiki/NMEA_0183>`_ standards using the `minmea
60+
<https://github.com/kosma/minmea>`_ library included in NuttX. The driver
61+
populates the ``sensor_gnss`` struct and pushes it to the appropriate event once
62+
all NMEA messages in its sequence have been read.
5663

5764

5865
**uORB commands**
5966
-----------------
60-
The driver implements the ``orb_activate``, ``orb_set_interval`` and, ``orb_ioctl`` operations to interact with the device.
61-
The latter is used to send proprietary 'PMTK' commands which are documented further below.
67+
68+
The driver implements the ``orb_activate``, ``orb_set_interval`` and,
69+
``orb_ioctl`` operations to interact with the device. The latter is used to send
70+
proprietary 'PMTK' commands which are documented further below.
6271

6372
**Activate**
6473

65-
There are 4 modes that the L86-XXX GNSS modules can be in. Those are "Full On Mode", "Standby Mode", "Backup Mode", "Periodic Mode" and, "AlwaysLocateTM Mode".
66-
Calling ``orb_activate`` with ``enable`` set to false will enter the module into "Standby Mode".
67-
In "Standby Mode", the module doesn't output any NMEA messages but the internal core and I/O power domain are still active.
74+
There are 4 modes that the L86-XXX GNSS modules can be in:
75+
76+
* Full On Mode
77+
* Standby Mode
78+
* Backup Mode
79+
* Periodic Mode
80+
* AlwaysLocateTM Mode
6881

69-
The module can be re-enabled by calling ``orb_activate`` with ``enable`` set to true, which will hot start the module OR by
70-
sending any 'PMTK' command.
82+
Calling ``orb_activate`` with ``enable`` set to false will enter the
83+
module into "Standby Mode". In "Standby Mode", the module doesn't output any
84+
NMEA messages but the internal core and I/O power domain are still active.
85+
86+
The module can be re-enabled by calling ``orb_activate`` with ``enable`` set to
87+
true, which will hot start the module OR by sending any 'PMTK' command.
7188

7289
**Set interval**
7390

74-
The L86-XXX GNSS modules support interval rates from 1Hz to 10Hz (100ms - 10000ms). When using ``orb_set_interval``, be aware that
75-
increasing the interval of the module may also require and increase in baud rate. An example of how this is performed can be found in
76-
source code of this driver in the register function.
91+
The L86-XXX GNSS modules support interval rates from 1Hz to 10Hz (100ms -
92+
10000ms). When using ``orb_set_interval``, be aware that increasing the interval
93+
of the module may also require and increase in baud rate. An example of how this
94+
is performed can be found in source code of this driver in the register
95+
function.
7796

7897
Any interval rate outside of the supported range will result in a failed call to this function.
7998

@@ -82,16 +101,17 @@ Any interval rate outside of the supported range will result in a failed call to
82101
The ``orb_ioctl`` interface allows one to send proprietary 'PMTK' commands to the L86-XXX GNSS module. It effectively works
83102
as a wrapper for the command framework outlined by Quectel. The return value of calls to ``orb_ioctl`` follow this pattern:
84103

85-
* -EINVAL - Invalid packet
86-
* -ENOSYS - Unsupported packet type
87-
* -EIO - Valid packet, but action failed
88-
* 0 - Valid packet, action succeeded
89-
* Other - Command failed during writing
104+
* ``EINVAL`` - Invalid packet
105+
* ``ENOSYS`` - Unsupported packet type
106+
* ``EIO`` - Valid packet, but action failed
107+
* ``0`` - Valid packet, action succeeded
108+
* Other - Command failed during writing
90109

91110
The supported commands are their arguments are listed below.
92111

93112
``SNIOC_HOT_START``
94113
-------------------
114+
95115
Used to "Hot start" the GNSS module. Normally hot start means the GNSS module was powered down for less
96116
than 3 hours (RTC must be alive) and its ephemeris is still valid. As there is no need for downloading
97117
ephemeris, it is the fastest startup method.
@@ -102,6 +122,7 @@ ephemeris, it is the fastest startup method.
102122
103123
``SNIOC_WARM_START``
104124
--------------------
125+
105126
Used to "Warm start" the GNSS module. Warm start means the GNSS module has approximate information of time,
106127
position and coarse data on satellite positions, but it needs to download ephemeris until it can get a fix.
107128

@@ -111,6 +132,7 @@ position and coarse data on satellite positions, but it needs to download epheme
111132
112133
``SNIOC_COLD_START``
113134
--------------------
135+
114136
Used to "Cold start" the GNSS module. Using this message will force the GNSS module to be restarted without
115137
any prior location information, including time, position, almanacs and ephemeris data.
116138

@@ -120,6 +142,7 @@ any prior location information, including time, position, almanacs and ephemeris
120142
121143
``SNIOC_FULL_COLD_START``
122144
-------------------------
145+
123146
Used to "Full cold start" the GNSS module. This is effectively the same as a cold restart, but additionally
124147
clears system and user configurations. In other words, this resets the GNSS module to its factory settings.
125148
When full-cold started, the GNSS module has no information on its last location.
@@ -130,7 +153,9 @@ When full-cold started, the GNSS module has no information on its last location.
130153
131154
``SNIOC_SET_INTERVAL``
132155
----------------------
133-
Used to modify the position fix interval of the GNSS module. The argument is an integer between 100 and 10000, default value is 1000.
156+
157+
Used to modify the position fix interval of the GNSS module. The argument is an
158+
integer between 100 and 10000, default value is 1000.
134159

135160
.. code-block:: c
136161
@@ -140,7 +165,7 @@ Used to modify the position fix interval of the GNSS module. The argument is an
140165
------------------
141166
.. note::
142167

143-
This feature requires termios support to be enabled(``CONFIG_SERIAL_TERMIOS``)
168+
This feature requires termios support to be enabled (``CONFIG_SERIAL_TERMIOS``)
144169

145170
Used to modify the baud rate of the GNSS module. The argument is an integer representing a supported baud rate, default value is 9600.
146171
Upon sending this command, the baud rate of the UART interface used to communicate with the module is also modified.
@@ -160,6 +185,7 @@ Supported baud rates for the L86-XXX series of GNSS modules are:
160185
161186
``SNIOC_SET_OPERATIONAL_MODE``
162187
------------------------------
188+
163189
Used to set the navigation mode of the GNSS module. The argument is an ``L86XXX_OPERATIONAL_MODE`` enum:
164190

165191
* NORMAL - For general purpose
@@ -173,5 +199,3 @@ Default mode is NORMAL
173199
.. code-block:: c
174200
175201
orb_ioctl(sensor, SNIOC_SET_OPERATIONAL_MODE, NORMAL);
176-
177-

drivers/sensors/Kconfig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -841,13 +841,13 @@ endif # SENSORS_KXTJ9
841841
config SENSORS_L86_XXX
842842
bool "Quectel L86-XXX GNSS support"
843843
default n
844-
depends on SERIAL && STANDARD_SERIAL && UORB
844+
depends on SERIAL && STANDARD_SERIAL && UORB && GNSSUTILS_MINMEA_LIB
845845
---help---
846846
Enable driver support for the L86-XXX series of GNSS modules.
847847

848848
config SENSORS_L86_XXX_THREAD_STACKSIZE
849849
int "Stack size for L86XXX module collection thread"
850-
default 10000
850+
default 1024
851851
depends on SENSORS_L86_XXX
852852

853853
config L86_XXX_BAUD
@@ -861,7 +861,7 @@ config L86_XXX_BAUD
861861
config L86_XXX_FIX_INT
862862
int "Quectel L86-XXX fix interval rate"
863863
default 1000
864-
depends on SENSORS_L86_XXX && SERIAL_TERMIOS
864+
depends on SENSORS_L86_XXX
865865
range 100 10000
866866
---help---
867867
Rate in ms at which module obtains satellite fix. Supported values

drivers/sensors/l86xxx_uorb.c

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ static int l86xxx_activate(FAR struct sensor_lowerhalf_s *lower,
113113
static int l86xxx_set_interval(FAR struct sensor_lowerhalf_s *lower,
114114
FAR struct file *filep,
115115
FAR uint32_t *period_us);
116+
#ifdef CONFIG_SERIAL_TERMIOS
116117
static int set_baud_rate(l86xxx_dev_s *dev, int br);
118+
#endif
117119
static int send_command(l86xxx_dev_s *dev,
118120
L86XXX_PMTK_COMMAND cmd, unsigned long arg);
119121
static int read_line(l86xxx_dev_s *dev);
@@ -294,9 +296,9 @@ static int send_command(l86xxx_dev_s *dev,
294296
return err;
295297
}
296298

297-
/* These commands do not send ACKs
298-
so just return after they've been written
299-
*/
299+
/* These commands do not send ACKs so just return after they've been
300+
* written
301+
*/
300302

301303
if (cmd == CMD_HOT_START ||
302304
cmd == CMD_WARM_START ||
@@ -308,39 +310,50 @@ static int send_command(l86xxx_dev_s *dev,
308310
}
309311

310312
/* Setting baud rate also doesn't send an ACK but the interface baud rate
311-
needs to be updated
312-
*/
313+
* needs to be updated
314+
*/
313315

314316
if (cmd == SET_NMEA_BAUDRATE)
315317
{
318+
#ifdef CONFIG_SERIAL_TERMIOS
316319
nxsig_usleep(20000); /* Should wait for a bit before changing interface baud rate */
317320
ret = set_baud_rate(dev, (int)arg);
321+
#else
322+
ret = -EINVAL;
323+
#endif
318324
nxmutex_unlock(&dev->devlock);
319325
return ret;
320326
}
321327

322328
/* Some commands will send ACKs,
323-
wait for them here before unlocking the mutex
324-
*/
325-
326-
/* ACK message will be $PMTK001,<cmd num>,<flag>
327-
flag num indicates success of command
328-
0 = Invalid packet
329-
1 = Unsupported packet type
330-
2 = Valid packet, but action failed
331-
3 = Valid packet, action succeeded
332-
*/
329+
* wait for them here before unlocking the mutex
330+
*/
331+
332+
/* ACK message will be $PMTK001,<cmd num>,<flag> flag num indicates success
333+
* of command:
334+
*
335+
* 0 = Invalid packet
336+
* 1 = Unsupported packet type
337+
* 2 = Valid packet, but action failed
338+
* 3 = Valid packet, action succeeded
339+
*/
333340

334341
memset(buf, '\0', 50);
335342
snprintf(buf, 50, "$PMTK001,%d", cmd);
336343
sninfo("Waiting for ACK from L86...\n");
337-
for (; ; )
344+
read_line(dev);
345+
346+
if (strncmp(buf, dev->buffer, strlen(buf)) == 0)
347+
{
348+
sninfo("ACK received!\n");
349+
}
350+
else
338351
{
339-
read_line(dev);
340-
if (strncmp(buf, dev->buffer, strlen(buf)) == 0) break;
352+
snerr("Did not get ACK!\n");
353+
nxmutex_unlock(&dev->devlock);
354+
return -EIO;
341355
}
342356

343-
sninfo("ACK received!\n");
344357
nxmutex_unlock(&dev->devlock);
345358

346359
/* Flag num is always in position 13 of ack, subtract by '0'
@@ -719,6 +732,8 @@ int l86xxx_register(FAR const char *uartpath, int devno)
719732
FAR l86xxx_dev_s *priv = NULL;
720733
int err;
721734
char *buf;
735+
FAR char *argv[2];
736+
char arg1[32];
722737

723738
DEBUGASSERT(uartpath != NULL);
724739

@@ -764,30 +779,28 @@ int l86xxx_register(FAR const char *uartpath, int devno)
764779
/* Setup sensor with configured settings */
765780

766781
sninfo("Waiting for GNSS to start...\n");
782+
767783
buf = "$PMTK010,001*2E";
768-
for (; ; )
784+
read_line(priv);
785+
if (strncmp(buf, priv->buffer, strlen(buf)) == 0)
769786
{
770-
read_line(priv);
771-
if (strncmp(buf, priv->buffer, strlen(buf)) == 0) break;
787+
sninfo("GNSS module started.\n");
772788
}
773789

774-
sninfo("GNSS module started.\n");
775-
776-
#ifdef CONFIG_SERIAL_TERMIOS
790+
#ifdef CONFIG_SERIAL_TERMIOS
777791
err = send_command(priv, SET_NMEA_BAUDRATE, L86_XXX_BAUD_RATE);
778792
if (err < 0)
779793
{
780794
snwarn("Couldn't set baud rate of device: %d\n", err);
781795
}
796+
#endif
782797

783798
err = send_command(priv, SET_POS_FIX, CONFIG_L86_XXX_FIX_INT);
784799
if (err < 0)
785800
{
786801
snwarn("Couldn't set position fix interval, %d\n", err);
787802
}
788803

789-
#endif
790-
791804
/* Register UORB Sensor */
792805

793806
priv->lower.ops = &g_sensor_ops;
@@ -800,8 +813,6 @@ int l86xxx_register(FAR const char *uartpath, int devno)
800813
goto close_file;
801814
}
802815

803-
FAR char *argv[2];
804-
char arg1[32];
805816
snprintf(arg1, 16, "%p", priv);
806817
argv[0] = arg1;
807818
argv[1] = NULL;

0 commit comments

Comments
 (0)