Neo FreeRunner GPS

From Openmoko

Revision as of 22:21, 15 August 2008 by Wonka (Talk | contribs)

Jump to: navigation, search


More information is provided on the GPS page.

Contents

Basic Setup

For basic setup instructions, check the GPS getting started instructions.

Note that there is a known issue between the GPS and SD card slot which is discussed here.

Testing

  • Shell test script for raw data dump:
echo 0 > /sys/class/i2c-adapter/i2c-0/0-0073/neo1973-pm-gps.0/pwron && 
sleep 1s && echo 1 > /sys/class/i2c-adapter/i2c-0/0-0073/neo1973-pm-gps.0/pwron && stty -F /dev/ttySAC1 -echo && cat -u /dev/ttySAC1 | grep -v ^$

GTA02 GPS Hardware Assist Feature

GTA02 is using the u-blox ANTARIS 4 ATR0635 hardware and could use u-blox AssistNow Online GPS (A-GPS) servces. GTA02 hardware design does not comply with official Assist Offline service requirement.

Assist Online/Offline comparsion

The "A"GPS support could cut TTFF time from 40 secs to 10-20 seconds. And the valid time of assist now download is about 4 hours. You could also check the following address:

http://embedded-system.net/assistnow-gps-services-boost-up-gps-receiver-performance-u-blox.html

Due to the u-blox ANTARIS 4 ATR0635 need to have extra flash to storage up to 14 days of offline data (90 KBytes).

Assist Online

Each download package could have up to 4 hours vaild data to assist TTFF. For u-blox Assist Online, you have to provide approximate longitude/latitude and time to get the corresponds "almanac" and "ephemeris" package. This might be base on application design for how to provide the longitude/latitude. User could select the location area from list menu or world map, or better implementation using the GSM/wi-fi location technique/service.

u-blox Assist Online implementation

For GTA02 default shipment image, there is no A-GPS/GPS supported software inside. You could find the u-blox A-GPS online implementation document here:

And implementation code in following address.

Here is a brief script to run this application:

#!/bin/sh

echo 1 >/sys/bus/platform/drivers/neo1973-pm-gps/neo1973-pm-gps.0/pwron

./agps-onlinec -c full -u youraccount -k yourpasswd -la 25.073270 -lo
121.574805 -p 999999.00 

cat /dev/ttySAC1

-la 25.073270 -lo 121.574805 is reference latitude/longtitude

Here is a simple perl skript doing the same:

#!/usr/bin/perl -wT
#
# ublox AssistNow Online almanach downloader for Neo Freerunner
#
# v0.1
#
# Wilfried Klaebe <wk-openmoko@chaos.in-kiel.de>
#
# Usage:
#
# agps-alm.pl > /dev/ttySAC1
#

use strict;
use IO::Socket::INET;
use vars qw(%h);

my $user = 'user@somewhere.invalid';
my $pass = 'pass-from-ublox';

my $s = new IO::Socket::INET(PeerAddr => 'agps.u-blox.com', Proto => 'tcp', PeerPort => 46434);

$s->print('user='.$user.';pwd='.$pass.';cmd=alm;lat=0;lon=0;pacc=40000000;', "\n");

print STDERR $s->getline;

while(my $l = $s->getline) {
        print STDERR $l;

        $l =~ s/(\r\n|\n)+\Z//g;

        if ($l eq "") {
                if ($h{'content-length'} > 0 && $h{'content-type'} eq 'application/ubx') {
                        $s->read($l,$h{'content-length'});
                        print $l;
                }
                exit(0);
        }

        if ($l =~ m/\A(.+): (.+)\Z/) {
                $h{lc($1)} = lc($2);
        }
}

This also works with cmd=full and meaningful lat/lon/pacc values.

Same in python:

#!/usr/bin/python
#
# ublox AssistNow Online almanach downloader for Neo Freerunner
#
# v0.1
#
# Wilfried Klaebe <wk-openmoko@chaos.in-kiel.de>
#
# Usage:
#
# agps-alm.py > /dev/ttySAC1
#

import sys
import socket
import re

user='your@mail.address'
pwd='pwdfromublox'

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('agps.u-blox.com',46434))

s.send('user='+user+';pwd='+pwd+';cmd=alm;lat=0;lon=0;pacc=40000000;\n')

buf = s.recv(4096)
while 1:
        b = s.recv(4096)
        if not b:
                break
        buf += b

h = {}

while 1:
        (l,s,buf) = buf.partition('\n')
        l = l.rstrip('\r\n')
        #
        sys.stderr.write(l+'\n')
        #
        if (l == ""):
                if h.has_key('content-length') and h['content-length'].isdigit() and h.has_key('content-type') and h['content-type'] == 'application/ubx':
                        sys.stdout.write(buf[0:int(h['content-length'])])
                sys.exit(0)
        #
        m = re.search('\\A(.+): (.+)\\Z',l)
        if m:
                h[m.group(1).lower()] = m.group(2).lower();

u-blox Assist Now account application

And account application is send a mail to agps-account@u-blox.com

without content and title. And not all mail account are accepted/could get reply. since the protocol is pretty straight forward, implement an extra proxy to scale up user should be easy.

Assist Offline

u-blox Assist Offline service could provide up to 14 days of valid assist GPS data in single download package. But Assist Offline service need an extra flash to storage Almanac data, and u-blox ANTARIS 4 ATR0635 will automatically use these data while system start up. GTA02 don't support Assist Offline.

u-blox Assist Offline implementation

Due to the u-blox 4 need to have extra flash to storage up to 14 days of offline data (90 KBytes), GTA02 don't have it. I would very interested if there is another way to twist it around, but not likely, so far. Offline sample data you could find in the following addesss:

http://alp.u-blox.com/

And u-blox did provided source code of Assist offline server implementation and ubx header, you could find it here:

http://people.openmoko.org/tony_tu/src/u-blox

Possible implementation mechanism

We can use the same protocol as the online assist to provide the time, last location, almanac and ephemeris data that would be held in the extra flash storage when we power up the GPS. Time is available from the local clock, and we can save location, almanac and ephemeris when the GPS is shut down. We may be able to have a better guess at startup location based on GSM cell ID, WiFi access points, or by the user selecting an area on a map.

Some Ruby tools already exist for downloading and uploading Almanac and Ephemeris. See http://docs.openmoko.org/trac/browser/developers/alphaone/u-blox

UBX protocol

Protocol specification (html-help format): http://www.u-blox.com/customersupport/gps.g3/ANTARIS_Protocol_Specification(GPS.G3-X-03002).chm

Sample header could be found here: ubx.h

Conversion between lat/ln and ECEF xyz coordinates: http://www.u-blox.com/customersupport/docs/GPS.G1-X-00006.pdf

Packet generator:

#!/usr/bin/python
#
# ubx packet generator
#
# v0.1
#
# Wilfried Klaebe <wk-openmoko@chaos.in-kiel.de>
#
# Usage:
#
# ubxgen.py 06 13 04 00 01 00 00 00 > packet.ubx
#
# prepends 0xb5 0x62 header,
# appends checksum,
# outputs binary packet to stdout
#
# you can send the packet to GPS chip like this:
#
# cat packet.ubx > /dev/ttySAC1

import sys
import binascii

cs0=0
cs1=0

sys.stdout.write("\xb5\x62")

for d in sys.argv[1:]:
	c = binascii.unhexlify(d)
	sys.stdout.write(c)
	cs0 += ord(c)
	cs0 &= 255
	cs1 += cs0
	cs1 &= 255

sys.stdout.write(chr(cs0)+chr(cs1))
Personal tools
Key pages on:
Neo FreeRunner


More information is provided on the GPS page.

Basic Setup

For basic setup instructions, check the GPS getting started instructions.

Note that there is a known issue between the GPS and SD card slot which is discussed here.

Testing

  • Shell test script for raw data dump:
echo 0 > /sys/class/i2c-adapter/i2c-0/0-0073/neo1973-pm-gps.0/pwron && 
sleep 1s && echo 1 > /sys/class/i2c-adapter/i2c-0/0-0073/neo1973-pm-gps.0/pwron && stty -F /dev/ttySAC1 -echo && cat -u /dev/ttySAC1 | grep -v ^$

GTA02 GPS Hardware Assist Feature

GTA02 is using the u-blox ANTARIS 4 ATR0635 hardware and could use u-blox AssistNow Online GPS (A-GPS) servces. GTA02 hardware design does not comply with official Assist Offline service requirement.

Assist Online/Offline comparsion

The "A"GPS support could cut TTFF time from 40 secs to 10-20 seconds. And the valid time of assist now download is about 4 hours. You could also check the following address:

http://embedded-system.net/assistnow-gps-services-boost-up-gps-receiver-performance-u-blox.html

Due to the u-blox ANTARIS 4 ATR0635 need to have extra flash to storage up to 14 days of offline data (90 KBytes).

Assist Online

Each download package could have up to 4 hours vaild data to assist TTFF. For u-blox Assist Online, you have to provide approximate longitude/latitude and time to get the corresponds "almanac" and "ephemeris" package. This might be base on application design for how to provide the longitude/latitude. User could select the location area from list menu or world map, or better implementation using the GSM/wi-fi location technique/service.

u-blox Assist Online implementation

For GTA02 default shipment image, there is no A-GPS/GPS supported software inside. You could find the u-blox A-GPS online implementation document here:

And implementation code in following address.

Here is a brief script to run this application:

#!/bin/sh

echo 1 >/sys/bus/platform/drivers/neo1973-pm-gps/neo1973-pm-gps.0/pwron

./agps-onlinec -c full -u youraccount -k yourpasswd -la 25.073270 -lo
121.574805 -p 999999.00 

cat /dev/ttySAC1

-la 25.073270 -lo 121.574805 is reference latitude/longtitude

Here is a simple perl skript doing the same:

#!/usr/bin/perl -wT
#
# ublox AssistNow Online almanach downloader for Neo Freerunner
#
# v0.1
#
# Wilfried Klaebe <wk-openmoko@chaos.in-kiel.de>
#
# Usage:
#
# agps-alm.pl > /dev/ttySAC1
#

use strict;
use IO::Socket::INET;
use vars qw(%h);

my $user = 'user@somewhere.invalid';
my $pass = 'pass-from-ublox';

my $s = new IO::Socket::INET(PeerAddr => 'agps.u-blox.com', Proto => 'tcp', PeerPort => 46434);

$s->print('user='.$user.';pwd='.$pass.';cmd=alm;lat=0;lon=0;pacc=40000000;', "\n");

print STDERR $s->getline;

while(my $l = $s->getline) {
        print STDERR $l;

        $l =~ s/(\r\n|\n)+\Z//g;

        if ($l eq "") {
                if ($h{'content-length'} > 0 && $h{'content-type'} eq 'application/ubx') {
                        $s->read($l,$h{'content-length'});
                        print $l;
                }
                exit(0);
        }

        if ($l =~ m/\A(.+): (.+)\Z/) {
                $h{lc($1)} = lc($2);
        }
}

This also works with cmd=full and meaningful lat/lon/pacc values.

Same in python:

#!/usr/bin/python
#
# ublox AssistNow Online almanach downloader for Neo Freerunner
#
# v0.1
#
# Wilfried Klaebe <wk-openmoko@chaos.in-kiel.de>
#
# Usage:
#
# agps-alm.py > /dev/ttySAC1
#

import sys
import socket
import re

user='your@mail.address'
pwd='pwdfromublox'

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('agps.u-blox.com',46434))

s.send('user='+user+';pwd='+pwd+';cmd=alm;lat=0;lon=0;pacc=40000000;\n')

buf = s.recv(4096)
while 1:
        b = s.recv(4096)
        if not b:
                break
        buf += b

h = {}

while 1:
        (l,s,buf) = buf.partition('\n')
        l = l.rstrip('\r\n')
        #
        sys.stderr.write(l+'\n')
        #
        if (l == ""):
                if h.has_key('content-length') and h['content-length'].isdigit() and h.has_key('content-type') and h['content-type'] == 'application/ubx':
                        sys.stdout.write(buf[0:int(h['content-length'])])
                sys.exit(0)
        #
        m = re.search('\\A(.+): (.+)\\Z',l)
        if m:
                h[m.group(1).lower()] = m.group(2).lower();

u-blox Assist Now account application

And account application is send a mail to agps-account@u-blox.com

without content and title. And not all mail account are accepted/could get reply. since the protocol is pretty straight forward, implement an extra proxy to scale up user should be easy.

Assist Offline

u-blox Assist Offline service could provide up to 14 days of valid assist GPS data in single download package. But Assist Offline service need an extra flash to storage Almanac data, and u-blox ANTARIS 4 ATR0635 will automatically use these data while system start up. GTA02 don't support Assist Offline.

u-blox Assist Offline implementation

Due to the u-blox 4 need to have extra flash to storage up to 14 days of offline data (90 KBytes), GTA02 don't have it. I would very interested if there is another way to twist it around, but not likely, so far. Offline sample data you could find in the following addesss:

http://alp.u-blox.com/

And u-blox did provided source code of Assist offline server implementation and ubx header, you could find it here:

http://people.openmoko.org/tony_tu/src/u-blox

Possible implementation mechanism

We can use the same protocol as the online assist to provide the time, last location, almanac and ephemeris data that would be held in the extra flash storage when we power up the GPS. Time is available from the local clock, and we can save location, almanac and ephemeris when the GPS is shut down. We may be able to have a better guess at startup location based on GSM cell ID, WiFi access points, or by the user selecting an area on a map.

Some Ruby tools already exist for downloading and uploading Almanac and Ephemeris. See http://docs.openmoko.org/trac/browser/developers/alphaone/u-blox

UBX protocol

Protocol specification (html-help format): http://www.u-blox.com/customersupport/gps.g3/ANTARIS_Protocol_Specification(GPS.G3-X-03002).chm

Sample header could be found here: ubx.h

Conversion between lat/ln and ECEF xyz coordinates: http://www.u-blox.com/customersupport/docs/GPS.G1-X-00006.pdf

Packet generator:

#!/usr/bin/python
#
# ubx packet generator
#
# v0.1
#
# Wilfried Klaebe <wk-openmoko@chaos.in-kiel.de>
#
# Usage:
#
# ubxgen.py 06 13 04 00 01 00 00 00 > packet.ubx
#
# prepends 0xb5 0x62 header,
# appends checksum,
# outputs binary packet to stdout
#
# you can send the packet to GPS chip like this:
#
# cat packet.ubx > /dev/ttySAC1

import sys
import binascii

cs0=0
cs1=0

sys.stdout.write("\xb5\x62")

for d in sys.argv[1:]:
	c = binascii.unhexlify(d)
	sys.stdout.write(c)
	cs0 += ord(c)
	cs0 &= 255
	cs1 += cs0
	cs1 &= 255

sys.stdout.write(chr(cs0)+chr(cs1))