plugin_gps

GPS plugin

gps::parse(OPTION-PARAM, DISPLAY-PARAM)return gps information based on your parameter

This plugin has only 1 function (gps::parse) with 2 parameter. Here is a description of the parameter:

PARAMETER 1
#define SHOW_ALTITUDE           0x000000001    alt:500
#define SHOW_SPEED              0x000000010    spd:30
#define SHOW_COURSE             0x000000100    dir:NO
#define SHOW_SATELLITES         0x000001000    sat:4
#define SHOW_QUALITY            0x000010000    qua:1
#define SHOW_STATUS             0x000100000    sta:V (V=VOID, A=Active)
#define SHOW_TIME_UTC           0x001000000    utc:113459
#define SHOW_DATE               0x010000000    dat:190204 (19.02.2004)

PARAMETER 2
#define OPTION_NO_PREFIX        0x000000001     disable prefix (example, instead of "alt:500" it displays "500"
#define OPTION_SPEED_IN_KNOTS   0x000000010     when use the SHOW_SPEED option, display speed in knots instead in km/h
#define OPTION_RAW_NMEA         0x000000100     outputs the parsed nmea string, only valid when EMULATE is not defined!
#define OPTION_GET_BUFFERDATA   0x000001000     when you define more than 1 gps widget
                                                each widget will get updates and cause some ugly side effects, specially when you display the time.
                                                by enabling this option, the widget **will not read any nmea data from the serial port**.
                                                KEEP IN MIND that there must be ONE widget which get buffered data (means read data from the p
#define SHOW_NMEA_STATUS        0x010000000     OK:0033/Error:0002/Incomplete:0002
                                                This is useful for debugging, display the nmea packet counter

you need to specify the numbers and not the option name. Examples

Examples:
  - gps::parse('0x000000011','0') will display the altitude and speed -> alt:500 spd:43
  - gps::parse('0x000001100','0') will display the course and the numbers of satellites -> dir:NO sat:3
  - gps::parse('0x000000001','0x01') will display the speed without prefix -> 50
  - gps::parse('0x000000001','0x01') will display the speed in knots without prefix -> 27

you need to define your SERIAL PORT with the evoriement variable GPS_PORT:

# export GPS_PORT=/dev/ttyUSB1

Here is my (michu / neophob.com) gps widget config:

Widget gps-test1 {
    class  'Text'
    expression gps::parse('0x0000111','0')
    width  20
    update tack
    align  'C'
}

Widget gps-test2 {
    class  'Text'
    expression gps::parse('0x10001000','0x01')
    width  20
    update tack
    align  'C'
}

Widget gps-test3 {
    class  'Text'
    prefix 'GPS/'
    expression gps::parse('0x011111111','0')
    width  20
    update tack
    align  'M'
    speed 250
}

This looks like this when using ncurses as output:

# ./lcd4linux -F -vv -q
┌────────────────────┐
│                    │
│GPS/lt:545 spd:1 dir│ << gps-test3, scrolling all gps information
│alt:545 spd:1 dir:N │ << gps-test1, 3 values
│     8 191194       │ << gps-test2, here is the prefix disbled (2nd parameter)
└────────────────────┘

An overview with all possible GPS options:
┌────────────────────────┐
│                        │
│ utc:165118 dat:190706  │
│  alt:23 spd:0 dir:N    │
│   sat:6 qua:1 sta:A    │
└────────────────────────┘

This plugin tries to connect per default to the gps device at /dev/usb/tts/1. If your GPS device is connected to another device you can use the environment variable GPS_PORT.\
For example export GPS_PORT=/dev/tty/2\
\
There is also an emulator mode, so you dont need a physical GPS device, instead plugin_gps.c uses a nmea string. This is usefull for testing. You may enable the EMULATOR mode by uncommenting the #define EMULATE in the plugin_gps.c file. You may also alter the nmea string.

You need libnmeap to compile this plugin, src: http://www.dmh2000.com/nmea/nmeap.shtml. \
If you want more information about this plugin or a openwrt binary visit http://www.neophob.com/.\
Cheers Michu at neophob dot com\

If you need to find out, why your gps device do not work with this plugin, follow this guide:

1) add a new debug widget:

Widget gps-debug {
        class 'Text'
        expression gps::parse('0x1','0x000011110')
        width 20
        update 1000
        align 'L'
}

and add it to your layout

2) export your device port:

root@OpenWrt:/# export GPS_PORT=/dev/ttyUSB1

3) run lcd4linux in debug mode:

root@OpenWrt:/# lcd4linux -vv -F -q
Version 0.10.2-SVN-796 starting
<...>
plugin_gps.c: [[:GPS]]: v0.31
plugin_gps.c: [[:GPS]]: Using port /dev/ttyUSB1 at 4800 baud
plugin_gps.c: [[:GPS]]: GPS parser prepared...
[[:KVV]] Using station 89
[[:KVV]] Using default port 80
[[:KVV]] Using default refresh interval of 60 seconds
[[:KVV]] Default abbreviation setting: off
plugin_mpd.c: [[:MPD]] v0.5, check env variables MPD_HOST, MPD_PORT
plugin_mpd.c: [[:MPD]] Using host <localhost> and port <6600>

lcd4linux.c: initializing driver Crystalfontz
Crystalfontz: $Rev: 840 $
Crystalfontz: using model '634'
Crystalfontz: using port '/dev/ttyUSB0' at 19200 baud
Crystalfontz: reserving 1 of 8 user-defined characters for icons
Crystalfontz: using 0 GPI's and 0 GPO's
initializing layout 'L20x4'
lcd4linux.c: starting main loop
plugin_gps.c: [[:GPS]] debug: read 78 bytes from GPS device
plugin_gps.c: [[:GPS]] debug: OK:000/Er:000/In:000
plugin_gps.c: [[:GPS]] debug: backBuffer: <
>
plugin_gps.c: [[:GPS]] debug: submit: <$GPGGA,024210.406,0000.0000,N,00000.0000,E,0,00,50.0,0.0,M,0.0,M,0.0,0000*71
>
plugin_gps.c: [[:GPS]] debug: OK:000/Er:000/In:000
plugin_gps.c: [[:GPS]] debug: get gga callout
plugin_gps.c: [[:GPS]] debug: read 42 bytes from GPS device
plugin_gps.c: [[:GPS]] debug: OK:001/Er:000/In:000
plugin_gps.c: [[:GPS]] debug: backBuffer: <
>
plugin_gps.c: [[:GPS]] debug: submit: <$GPGSA,A,1,,,,,,,,,,,,,50.0,50.0,50.0*05
>
plugin_gps.c: [[:GPS]] debug: OK:001/Er:000/In:000
plugin_gps.c: [[:GPS]] debug: read 60 bytes from GPS device
plugin_gps.c: [[:GPS]] debug: OK:002/Er:000/In:000
plugin_gps.c: [[:GPS]] debug: backBuffer: <
>

check the line “plugin_gps.c: GPS debug: OK:000/Er:000/In:000” as this line will print out all the received nmea packets.

  • plugin_gps.txt
  • Last modified: 2020/07/17 18:33
  • (external edit)