r4400 - developers/alphaone/u-blox

alphaone at docs.openmoko.org alphaone at docs.openmoko.org
Sat Apr 26 03:43:01 CEST 2008


Author: alphaone
Date: 2008-04-26 03:25:41 +0200 (Sat, 26 Apr 2008)
New Revision: 4400

Added:
   developers/alphaone/u-blox/ubx-get.rb
   developers/alphaone/u-blox/ubx-set.rb
Modified:
   developers/alphaone/u-blox/ubx-config.rb
Log:
* Two tools now, ubx-get and ubx-set which will save/load almanac and ephemeris
data to/from a file


Modified: developers/alphaone/u-blox/ubx-config.rb
===================================================================
--- developers/alphaone/u-blox/ubx-config.rb	2008-04-26 01:06:29 UTC (rev 4399)
+++ developers/alphaone/u-blox/ubx-config.rb	2008-04-26 01:25:41 UTC (rev 4400)
@@ -18,8 +18,6 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-gem_original_require 'serialport'
-
 UBX_CLASS = {
 	:NAV => 0x01,
 	:RXM => 0x02,
@@ -47,12 +45,24 @@
 }
 
 UBX_REVSTR = {
+	[:AID, :HUI, 72] =>
+		["VEENnnnnnneeeeeeeeV", [:HEALTH, :UTC_A1, :UTC_A0, :UTC_TOT, :UTC_WNT,
+		 :UTC_LS, :UTC_WNF, :UTC_DN, :UTC_LSF, :UTC_SPARE, :KLOB_A0, :KLOB_A1,
+		 :KLOB_A2, :KLOB_A3, :KLOB_B0, :KLOB_B1, :KLOB_B2, :KLOB_B3, :FLAGS]],
 	[:AID, :ALM, 1] =>
 		["C", [:SVID]],
 	[:AID, :ALM, 8]  =>
 		["VV", [:SVID, :WEEK]],
 	[:AID, :ALM, 40] =>
-		["V"*10, [:SVID, :WEEK, :DWRD0, :DWRD1, :DWRD2, :DWRD3, :DWRD4, :DWRD5, :DWRD6, :DWRD7]]
+		["V"*10, [:SVID, :WEEK, :DWRD0, :DWRD1, :DWRD2, :DWRD3, :DWRD4, :DWRD5, :DWRD6, :DWRD7]],
+	[:AID, :EPH, 1] =>
+		["C", [:SVID]],
+	[:AID, :EPH, 8] =>
+		["VV", [:SVID, :HOW]],
+	[:AID, :EPH, 104] =>
+		["V"*26, [:SVID, :HOW, :SF1D0, :SF1D1, :SF1D2, :SF1D3, :SF1D4,
+			:SF1D5, :SF1D6, :SF1D7, :SF2D0, :SF2D1, :SF2D2, :SF2D3, :SF2D4,
+		 	:SF2D5, :SF2D6, :SF1D7, :SF3D0, :SF3D1, :SF3D2, :SF3D3, :SF3D4, :SF3D5, :SF3D6, :SF3D7]]
 }
 
 UBX_FWDSTR = {}
@@ -61,9 +71,10 @@
 	UBX_FWDSTR[newkey] = value
 }
 
+SYNC1=0xb5
+SYNC2=0x62
+
 class Message
-	SYNC1=0xb5
-	SYNC2=0x62
 	attr_accessor :data
 	def initialize(cl, id, data)
 		@cl = cl
@@ -84,7 +95,10 @@
 	end
 
 	def to_a()
-		return [SYNC1, SYNC2, @cl, @id, @data]
+		field_names = UBX_FWDSTR[[@cl, @id, @data.length]][1]
+		name_hash = {}
+		field_names.zip(@data).each{|name, value| name_hash[name] = value}
+		return [SYNC1, SYNC2, @cl, @id, name_hash]
 	end
 
 	def to_s()
@@ -127,38 +141,3 @@
 		end
 	end
 end
-
-device = SerialPort.new(ARGV[0], baudrate=9600, databits=8, stopbits=1, parity=SerialPort::NONE)
-device.read_timeout=-1
-
-worker = Thread.new() {
-	stream = []
-	while true
-		begin
-			stream << device.getc
-			(msg, len) = Message.parse(stream.map {|i| i.chr}.to_s)
-			if msg
-				puts msg.inspect
-			end
-			stream = stream[len..-1]
-		rescue
-			puts "An error occurred: #{$!}"
-			stream = [ ]
-		end
-	end
-}
-
-sleep(2)
-
-foo = Message.new(:AID, :ALM, [])
-
-while true
-	puts "Submitting Almanach request"
-  device.write(foo.to_s)
-  device.flush()
-	sleep(3)
-	bar = Message.new(:AID, :ALM, [1, 1234, 1, 2, 3, 4, 5, 6, 7, 8])
-	device.write(bar.to_s)
-	device.flush()
-	sleep (2)
-end

Added: developers/alphaone/u-blox/ubx-get.rb
===================================================================
--- developers/alphaone/u-blox/ubx-get.rb	                        (rev 0)
+++ developers/alphaone/u-blox/ubx-get.rb	2008-04-26 01:25:41 UTC (rev 4400)
@@ -0,0 +1,76 @@
+#!/usr/bin/ruby
+# ubx-get.rb - Utility to retrieve Almanac and Ephemeris data from u-blox GPS
+# receivers
+#
+# Copyright 2008 OpenMoko, Inc.
+# Authored by Daniel Willmann <daniel at openmoko.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+gem_original_require 'serialport'
+
+require 'ubx-config'
+
+device = SerialPort.new(ARGV[0], baudrate=9600, databits=8, stopbits=1, parity=SerialPort::NONE)
+device.read_timeout=-1
+if ARGV[1]
+	fd = File.open(ARGV[1], 'w')
+end
+
+worker = Thread.new() {
+	stream = []
+	while true
+		begin
+			stream << device.getc
+			(msg, len) = Message.parse(stream.map {|i| i.chr}.to_s)
+			if msg
+				puts msg.to_a.inspect
+				foo = Marshal.dump(msg)
+				if fd
+					fd.write([foo.length].pack("v"))
+					fd.write(foo)
+				end
+			end
+			stream = stream[len..-1]
+		rescue
+			puts "An error occurred: #{$!}"
+			stream = [ ]
+		end
+	end
+}
+
+sleep(1)
+
+foo = Message.new(:AID, :ALM, [])
+puts "Almanach request"
+device.write(foo.to_s)
+device.flush()
+sleep(2)
+
+foo = Message.new(:AID, :EPH, [])
+puts "Ephimeris request"
+device.write(foo.to_s)
+device.flush()
+sleep(2)
+
+#foo = Message.new(:AID, :HUI, [])
+#puts "Health info request"
+#device.write(foo.to_s)
+#device.flush()
+#sleep(2)
+
+if fd
+	fd.close
+end


Property changes on: developers/alphaone/u-blox/ubx-get.rb
___________________________________________________________________
Name: svn:executable
   + *

Added: developers/alphaone/u-blox/ubx-set.rb
===================================================================
--- developers/alphaone/u-blox/ubx-set.rb	                        (rev 0)
+++ developers/alphaone/u-blox/ubx-set.rb	2008-04-26 01:25:41 UTC (rev 4400)
@@ -0,0 +1,59 @@
+#!/usr/bin/ruby
+# ubx-set.rb - Utility to set Almanac and Ephemeris data for u-blox GPS
+# receivers
+#
+# Copyright 2008 OpenMoko, Inc.
+# Authored by Daniel Willmann <daniel at openmoko.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+gem_original_require 'serialport'
+
+require 'ubx-config'
+
+device = SerialPort.new(ARGV[0], baudrate=9600, databits=8, stopbits=1, parity=SerialPort::NONE)
+device.read_timeout=-1
+fd = File.open(ARGV[1], 'r')
+
+worker = Thread.new() {
+	stream = []
+	while true
+		begin
+			stream << device.getc
+			(msg, len) = Message.parse(stream.map {|i| i.chr}.to_s)
+			if msg
+				puts msg.to_a.inspect
+			end
+			stream = stream[len..-1]
+		rescue
+			puts "An error occurred: #{$!}"
+			stream = [ ]
+		end
+	end
+}
+
+sleep(2)
+
+while !fd.eof?
+	len = fd.read(2).unpack("v")[0]
+	data = fd.read(len)
+	msg = Marshal.load(data)
+	puts msg.to_a.inspect
+	device.write(msg.to_s)
+	device.flush()
+end
+
+fd.close
+


Property changes on: developers/alphaone/u-blox/ubx-set.rb
___________________________________________________________________
Name: svn:executable
   + *





More information about the commitlog mailing list