NMEA , request for real live sample

Discussion in 'Ruby' started by Bino Oetomo, May 9, 2007.

  1. Bino Oetomo

    Bino Oetomo Guest

    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,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-forum.com/.
     
    Bino Oetomo, May 9, 2007
    #1
    1. Advertising

  2. Bino Oetomo

    Max Lapshin Guest

    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-forum.com/.
     
    Max Lapshin, May 9, 2007
    #2
    1. Advertising

  3. Bino Oetomo

    Max Lapshin Guest

    Max Lapshin, May 9, 2007
    #3
  4. Bino Oetomo

    bino_oetomo Guest

    Dear Max and all
    ----- Original Message -----
    From: "Max Lapshin" <>
    Newsgroups: comp.lang.ruby
    To: "ruby-talk ML" <>
    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/projects/gpsfeed
    From my table, I can not get GPS signal .. thats why i use such "emulator"

    Regards
    -bino-
     
    bino_oetomo, May 9, 2007
    #4
  5. Bino Oetomo

    Max Lapshin Guest

    Max Lapshin, May 9, 2007
    #5
  6. Bino Oetomo

    Bino Oetomo Guest

    Max Lapshin 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-

    --
    Posted via http://www.ruby-forum.com/.
     
    Bino Oetomo, May 10, 2007
    #6
  7. Bino Oetomo

    Max Lapshin Guest

    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-forum.com/.
     
    Max Lapshin, May 10, 2007
    #7
  8. Bino Oetomo

    Bino Oetomo Guest

    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-forum.com/.
     
    Bino Oetomo, May 10, 2007
    #8
  9. Bino Oetomo

    Max Lapshin Guest

    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-forum.com/.
     
    Max Lapshin, May 10, 2007
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. NMEA

    , Feb 5, 2006, in forum: VHDL
    Replies:
    4
    Views:
    1,140
    Mark McDougall
    Feb 6, 2006
  2. jjs0713

    Take UTC time from NMEA format.

    jjs0713, Jul 30, 2003, in forum: C Programming
    Replies:
    0
    Views:
    723
    jjs0713
    Jul 30, 2003
  3. Simon Brooke
    Replies:
    0
    Views:
    538
    Simon Brooke
    Oct 13, 2006
  4. Doug Gray
    Replies:
    4
    Views:
    370
    Doug Gray
    Mar 20, 2007
  5. Max Lapshin

    NMEA (GPS protocol) parser

    Max Lapshin, Apr 11, 2007, in forum: Ruby
    Replies:
    5
    Views:
    451
    Eleanor McHugh
    Apr 12, 2007
Loading...

Share This Page