wiki:plugin_gps

Version 12 (modified by michu-at-neophob-com, 12 years ago) (diff)

--

GPS plugin

Functions

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

example config

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    │
└────────────────────────┘

Additional info

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.

Dev

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