NMEA , request for real live sample


#1

Dear All …
Is there any easier to understand sample of ruby nmea parser (
http://rubyforge.org/projects/nmea/ ) ??

I need to parse NMEA , and re format it to YAML.
I tried to :

—START—
require ‘serialport’
require ‘nmea’
@sp = SerialPort.open("/dev/ttyS1", 4800, 8, 1,
SerialPort::NONE)
@handler = NMEAHandler.new
while(@sentence = @sp.gets) do
puts NMEA.scan(@sentence, @handler)
end
—STOP—

but it only print “nil”

I thought that my system is not well wired, so I make a test using
miniterm.rb from the serialport library, and here is the result
—start—
[root@kannel test]# ruby ./miniterm.rb 1 4800 8 1
$GPRMC,135444,A,3815.4477,N,02349.5804,E,10412.9,243.3,090507,5,E,AB
$GPRMC,135446,A,3810.5221,N,02344.4003,E,11501.1,219.6,090507,5,E,A
B
$GPRMC,135448,A,3803.9503,N,02341.4152,E,12561.9,199.7,090507,5,E,A*B
—stop----

Note : My test system is

  1. GPS Feed : Using a PC running GPSFeed+
  2. Ruby on the other Linux PC
  3. The two PC is connected via a null-modem cable.

Sincerely
-bino-


#2

Look at release 0.2


#3

Dear Max and all
----- Original Message -----
From: “Max L.” removed_email_address@domain.invalid
Newsgroups: comp.lang.ruby
To: “ruby-talk ML” removed_email_address@domain.invalid
Sent: Wednesday, May 09, 2007 3:48 PM
Subject: Re: NMEA , request for real live sample

accept such unnatural sentences, but it is very, very strange for me.
What GPS device do You use? I wish to look at it documentation, perhaps
I’ve missed something in standart.

It’s not “real GPS” …
It’s a windows pc running gpsfeed software from -->
http://sourceforge.net/projects/gpsfeed
From my table, I can not get GPS signal … thats why i use such
“emulator”

Regards
-bino-


#4

Bino Oetomo wrote:

[root@kannel test]# ruby ./miniterm.rb 1 4800 8 1
$GPRMC,135444,A,3815.4477,N,02349.5804,E,10412.9,243.3,090507,5,E,AB
$GPRMC,135446,A,3810.5221,N,02344.4003,E,11501.1,219.6,090507,5,E,A
B
$GPRMC,135448,A,3803.9503,N,02341.4152,E,12561.9,199.7,090507,5,E,A*B

You see, this NMEA sentence differ from what I assumed to be standard.
There is unknown checksum in the end. I can modify parser so, that it
would
accept such unnatural sentences, but it is very, very strange for me.
What GPS device do You use? I wish to look at it documentation, perhaps
I’ve missed something in standart.

Regarding NMEA.scan, it will never return anything. It can only call
method
rmc on NMEAHandler.


#5

Bino Oetomo wrote:

It’s not “real GPS” …
It’s a windows pc running gpsfeed software from -->
http://sourceforge.net/projects/gpsfeed
From my table, I can not get GPS signal … thats why i use such
“emulator”

Understand. According to
http://www.werple.net.au/~gnb/gps/nmea.html#gprmc, this software
violates standard, that is why it was not parsed.

Now it is parseable, but checksum correction is disabled.


#6

require ‘test/mocks’

class NMEAHandler
def rmc(*args)
puts args.inspect
end
end

You will not receive anything, unless NMEA handler locate Latitude
class, so You should include mocks.rb, unless You have anything better.


#7

Max L. wrote:

Understand. According to
http://www.werple.net.au/~gnb/gps/nmea.html#gprmc, this software
violates standard, that is why it was not parsed.

Now it is parseable, but checksum correction is disabled.

Thanks Max.
So … I need to find my GPS … lying somewhere in my workshop

BTW … Can you give me another sample script ?
Maybe a script that print out each variables ?

Thanks in advance

-bino-


#8

Look at the test/mocks.rb

class NMEAHandler
def rmc(time, latitude, longitude, speed, course, magnetic_variation)

thus You can get latitude


#9

Dear Max.
Thanks for the response
First I make a subdirs inside ruby lib , with the name “nmea”
And make a copy of your mocks.rb into it

I try this :
—Start—
require ‘serialport’
require ‘nmea’
require ‘nmea/mocks’
class NMEAHandler
def rmc(*args)
puts args.inspect
end
end
@sp = SerialPort.open("/dev/ttyS1", 4800, 8, 1, SerialPort::NONE)
@handler = NMEAHandler.new
while(@sentence = @sp.gets) do
@handler.rmc(@sentence)
end
—Stop----

And it produced :
["$GPRMC,134632,A,0004.3300,N,00004.3300,W,005.0,315.0,100507,000.0,W*76\r\n"]

Kindly please show me how to … i.e “puts” just a single “latitude”.

Sincerely
-bino-