Skip to content

Instantly share code, notes, and snippets.

@shamrin
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save shamrin/8f75b9596bb2ee979cdf to your computer and use it in GitHub Desktop.
Save shamrin/8f75b9596bb2ee979cdf to your computer and use it in GitHub Desktop.
UmTRX GPS NMEA

Getting and parsing GPS NMEA data from UmTRX

Getting NMEA

Running echo . | nc -u 192.168.10.2 49171 is enough to get and print raw NMEA data from UmTRX. Stop here if it's all you need.

Getting and parsing NMEA

Clone this repo and run make (it installs pynmea2 library):

git clone git@gist.github.com:/8f75b9596bb2ee979cdf.git umtrx-gps
cd umtrx-gps
make

Parsing time and coordinates:

echo . | nc -u 192.168.10.2 49171 | ./gpslog

The same, but for remote UmTRX (attached to <hostname>):

echo . | ssh <hostname> nc -u 192.168.10.2 49171 | ./gpslog
#!/bin/sh
. venv/bin/activate && python gpslog.py
#!/usr/bin/env python
# coding: utf-8
import sys
import pynmea2
streamreader = pynmea2.NMEAStreamReader(sys.stdin)
while 1:
try:
for msg in streamreader.next():
if msg.sentence_type == 'GGA':
lat = u'%02d°%07.4f′%s' % \
(abs(msg.latitude), msg.latitude_minutes, msg.lat_dir)
lon = u'%02d°%07.4f′%s' % \
(abs(msg.longitude), msg.longitude_minutes, msg.lon_dir)
print msg.timestamp, lat, lon
except pynmea2.nmea.ParseError:
pass # we don't care
# this makes sure libraries are installed and up-to-date (with requirements.txt)
venv: venv/bin/activate
venv/bin/activate: requirements.txt
test -d venv || virtualenv venv
. venv/bin/activate && pip install -Ur requirements.txt
touch venv/bin/activate
@ati
Copy link

ati commented Feb 21, 2015

echo . | socat - UDP-DATAGRAM:192.168.10.2:49171 | socat - PTY,link=./gps,raw,echo=0
gpsd -b -N -n -D1 ./gps

@shamrin
Copy link
Author

shamrin commented Mar 12, 2015

@ati cool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment