Thursday, 4 October 2012

GiSTEQ USB Dongle in Linux

I ordered a GiSTEQ USB dongle (SKU: C5-GR110-01) a while ago and it finally arrived today! I've been in the mood to play with NTP sync etc from a GPS dongle for a while and ordered one with the SkyTraq chipset instead of the commonly found SiRFstar III. This was mainly due to a reported problem resulting in the NMEA offset drifting and being unreliable...

The main aim being to geek out rather than anything serious as these dongles arn't built with timing as a primary purpose (there are more reliable Stratum 1 time servers available on the net for free...)

I of course immediately started playing around with getting the device working in Linux, the device appears as:


Bus 006 Device 002: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port

Status of the GPS:

Green LED continually on: Location not fixed yet, may take a while
Green LED flashing: Location has been fixed

If you cat /dev/ttyUSB0 and see characters than don't make any sense, ie. lines that don't start with $GP your baud rate might be a problem... You can adjust the baud rate in Linux to 38400 with the following command: stty -F /dev/ttyUSB0 38400

The lines you want to be seeing:

$GPGGA,143830.462,2547.2945,S,02815.8548,E,1,05,1.7,1441.4,M,17.8,M,,0000*74
$GPGSA,A,3,14,31,25,29,06,,,,,,,,2.7,1.7,2.1*3F
$GPRMC,143830.462,A,2547.2945,S,02815.8548,E,000.0,119.8,041012,,,A*78
$GPVTG,119.8,T,,M,000.0,N,000.0,K,A*0C
$GPGSA,A,3,14,31,22,25,29,06,,,,,,,2.6,1.8,1.9*3A

The above lines were the main ones I saw coming through, now to make sense of the important (well to me at least) ones... You can find a nice list of all the codes and analysis of each at: http://aprs.gids.nl/nmea/

$GPGGA,143830.462,2547.2945,S,02815.8548,E,1,05,1.7,1441.4,M,17.8,M,,0000*74:

GPGGA - GPS Location Fix Data
Time (UTC/Zulu): 143830.462 => 14:38:30 462 millisecomds
Latitude: 2547.2945
North/South of Latitude: S
Longitude: 02815.8548
East/West of Longitude: E
Fix Quality: 1 (0 - None, 1 - GPS Fix, 2 - DGPS Fix)
Number of Satellites in Use (not View): 05
Horizontal Dilution of Precision: 1.7
Altitude: 1441.4
Altitude Unit: M - meters
Geoidal separation: 17.8 (WGS-84 Earth ellipsoid - Average sea level)
Geoidal separation Unit: M - meters
Age of Differential GPS data (seconds): blank
Differential reference station ID: 0000
Checksum: *74

$GPVTG,119.8,T,99.1,M,000.0,N,000.0,K,A*0C

GPVTG - Track made good and ground speed
True Track degrees: 119.8
Relative to True North: T => True
Magnetic Track degrees: 99.1
Magnetic Track true: M
Speed over ground: 000.0
Speed in units: N => Knots
Speed over ground: 000.0
Speed in units: K => kilometers/hour
Checksum: A*0C


I'll blog about the Gisteq as a time source soon but in the meantime I wrote a quick BASH script to display the results in a loop:

#!/bin/bash
#
# Gisteq GPS USB Dongle
#

echo "Setting the baud rate to 38400..."
stty -F /dev/ttyUSB0 38400

while read input; do
 line_id=${input:1:5}
 if [ "$line_id" = "GPGGA" ]; then
  value_array=(`echo $input | tr "," "\n"`)
  gps_time=(${value_array[1]})
  gps_time=`echo $gps_time | awk '{for(i=1;i<=length($0)-4;i+=2){printf("%s:",substr($0,i,2))}}'|awk '{sub(/:$/,"")};1'`
  echo "UTC Time: $gps_time"
  latitude=(${value_array[2]})
  latitude_direction=(${value_array[3]})
  echo "Latitude: $latitude $latitude_direction"
  longitude=(${value_array[4]})
  longitude_direction=(${value_array[5]})
  echo "Longitude: $longitude $longitude_direction"
  gps_fix=(${value_array[6]})
  if [ $gps_fix -gt 0 ]; then
   gps_fix="Yes"
  else
   gps_fix="No"
  fi
  echo "GPS Fix: $gps_fix"
  satellites=(${value_array[7]})
  echo "Satellites in use: $satellites"
  altitude=(${value_array[9]})
  echo "Altitude: $altitude meters"
 elif [ "$line_id" = "GPVTG" ]; then
  value_array=(`echo $input | tr "," "\n"`)
  speed=(${value_array[6]})
  echo "Speed: $speed kph"
  echo "######################"
 fi
done < /dev/ttyUSB0

No comments:

Post a Comment