Class: GPS_PVT::RTCM3
- Inherits:
-
Object
- Object
- GPS_PVT::RTCM3
- Defined in:
- lib/gps_pvt/rtcm3.rb
Defined Under Namespace
Modules: Packet
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(io) ⇒ RTCM3
constructor
A new instance of RTCM3.
- #read_packet ⇒ Object
Constructor Details
#initialize(io) ⇒ RTCM3
Returns a new instance of RTCM3.
7 8 9 10 |
# File 'lib/gps_pvt/rtcm3.rb', line 7 def initialize(io) @io = io @buf = [] end |
Class Method Details
Instance Method Details
#read_packet ⇒ Object
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 |
# File 'lib/gps_pvt/rtcm3.rb', line 550 def read_packet while !@io.eof? if @buf.size < 6 then @buf += @io.read(6 - @buf.size).unpack('C*') return nil if @buf.size < 6 end if @buf[0] != 0xD3 then @buf.shift next elsif (@buf[1] & 0xFC) != 0x0 then @buf = @buf[2..-1] next end len = ((@buf[1] & 0x3) << 8) + @buf[2] if @buf.size < len + 6 then @buf += @io.read(len + 6 - @buf.size).unpack('C*') return nil if @buf.size < len + 6 end #p (((["%02X"] * 3) + ["%06X"]).join(', '))%[*(@buf[(len + 3)..(len + 5)]) + [RTCM3::checksum(@buf)]] if "\0#{@buf[(len + 3)..(len + 5)].pack('C3')}".unpack('N')[0] != RTCM3::checksum(@buf) then @buf = @buf[2..-1] next end packet = @buf[0..(len + 5)] @buf = @buf[(len + 6)..-1] return packet.extend(Packet) end return nil end |