[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

NMEA , request for real live sample

bino_oetomo

5/9/2007 7:10:00 AM

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

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,A*B
$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-

--
Posted via http://www.ruby-....

8 Answers

???? ??????

5/9/2007 8:49:00 AM

0

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,A*B
> $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.

--
Posted via http://www.ruby-....

???? ??????

5/9/2007 9:28:00 AM

0

Look at release 0.2

--
Posted via http://www.ruby-....

bino_oetomo

5/9/2007 9:37:00 AM

0

Dear Max and all
----- Original Message -----
From: "Max Lapshin" <max@maxidoors.ru>
Newsgroups: comp.lang.ruby
To: "ruby-talk ML" <ruby-talk@ruby-lang.org>
Sent: Wednesday, May 09, 2007 3:48 PM
Subject: Re: NMEA , request for real live sample


> 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,A*B
> > $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.
>

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

Regards
-bino-


???? ??????

5/9/2007 10:19:00 AM

0

Bino Oetomo wrote:
>
> It's not "real GPS" ...
> It's a windows pc running gpsfeed software from -->
> http://sourceforge.net/projec...
> 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...., this software
violates standard, that is why it was not parsed.

Now it is parseable, but checksum correction is disabled.

--
Posted via http://www.ruby-....

bino_oetomo

5/10/2007 12:49:00 AM

0

Max Lapshin wrote:
>
> Understand. According to
> http://www.werple.net.au/~gnb/gps/nmea...., 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-

--
Posted via http://www.ruby-....

???? ??????

5/10/2007 4:43:00 AM

0

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.

--
Posted via http://www.ruby-....

bino_oetomo

5/10/2007 6:47:00 AM

0

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-

--
Posted via http://www.ruby-....

???? ??????

5/10/2007 7:49:00 AM

0

Look at the test/mocks.rb

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

thus You can get latitude

--
Posted via http://www.ruby-....