wiki:OpenWrt/GPS

Version 1 (modified by trac, 7 years ago) ( diff )

--

For a more general overview of our GPS modules, please see our Main GPS Page for more information.

Hardware Mappings

Please see this page for which serial port the GPS is on

OpenWrt GPS configuration and GPSD

OpenWrt supports the popular opensource gpsd application: http://gpsd.berlios.de/

The configuration for gpsd is stored in /etc/config/gpsd and accessible via uci:

uci show gpsd

One must configure the following.

  1. The port is typically 2947 but can be changed if desired
  2. device is where the GPS chip is mapped on the board, please see the Hardware Mappings above
  3. To test gpsd from an external computer, you will need to set the listen_globally variable to true. Modify it using a editor like vi or uci commands.

Example output:

root@OpenWrt:/# uci show gpsd
gpsd.core=gpsd
gpsd.core.device=/dev/ttyUSB0
gpsd.core.port=2947
gpsd.core.listen_globally=false
gpsd.core.enabled=true

gpsd is a service and therefore can be started and stopped with the standard commands.

/etc/init.d/gpsd start

To verify the GPS data output, you can cat the serial port that the GPS is mapped on. For example, on the GW2388, the GPS is mapped to COM2 port (ttyS2): Please view product manual for correct port or Hardware Mappings above

Note: Ventana may spit out binary OSP mode

root@OpenWrt:/# stty -F /dev/ttyS2 4800 ;# set baudrate to 4800bps, also possibly 9600
root@OpenWrt:/# cat /dev/ttyS2

$GPGGA,000113.037,,,,,0,0,,,M,,M,,*4F
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPGSV,1,1,00*79
$GPRMC,000113.037,V,,,,,0.00,0.00,060180,19.9,W,N*0D
$GPGGA,000113.037,,,,,0,0,,,M,,M,,*4F

You can also install a gpsd client such as xgps and test it via an external PC.

Example shown below has a Gateworks board at 192.168.1.78 on the network. A Linux Desktop PC is running at 192.168.1.22 and has xgps installed:

xgps 192.168.1.78

No image "xgps.png" attached to OpenWrt/GPS

For a Windows client, please search on Google and refer to the gpsd page where it lists:

Applications that presently use gpsd include pyGPS, gpsdrive, Kismet, GPSdrive, gpeGPS, position, roadmap, roadnav, navit, viking, tangogps, foxtrot, opencpn, obdgpslogger, geohist, LiveGPS, geoclue, qlandkartegt, gpredict, OpenCPN, gpsd-navigator, gpsd-ais-viewer, and firefox/mozilla.

Hardware-specific init scripts

Some hardware may require configuration each time you boot that you likely want place in an init-script. For example:

  • specific AT commands to enable/configure NMEA mode
  • software controlled USB steering (for boards that route USB to front-panel by default but need to have USB routed to PCIe slot for a PCIe USB modem with GPS support)

Option Globetrotter GTM671WFS

The Option Globetrotter modules combine multiple features into a single device. The GPS module on supported devices has a serial port to control/configure the GPS and another serial port to obtain data from the GPS. By default the data port does not display NMEA messages and must be enabled with the following AT commands:

AT_OGPSMODE=1
AT_OGPS=2

An OpenWrt init script can be created for performing this on bootup. Here we add a UCI configuration ctrl_device to the gpsd configuration to describe the configuration serial port:

  • create and enable a gps init script
    cat << EOF > /etc/init.d/option_gps_init
    #!/bin/sh /etc/rc.common
    # Copyright (C) 2009 OpenWrt.org
    START=85
    
    boot() {
        config_load gpsd
        config_get ctrl_device core ctrl_device
        [ "\$ctrl_device" ] || exit
        logger -t "gps" "Initializing GPS on \$ctrl_device"
        echo -e -n "AT_OGPSMODE=1\015" > \$ctrl_device
        echo -e -n "AT_OGPS=2\015" > \$ctrl_device
    }
    EOF
    chmod +x /etc/init.d/option_gps_init
    /etc/init.d/option_gps_init enable
    
  • specify UCI config used by the init script above:
    uci set gpsd.core.device=/dev/ttyHS1
    uci set gpsd.core.ctrl_device=/dev/ttyHS2
    uci set gpsd.core.enabled=true
    uci commit
    
  • and make sure gpsd is enabled on boot:
    /etc/init.d/gpsd enable
    
Note: See TracWiki for help on using the wiki.