Class: GPSTool::Devices::RBT2300::DataParser
- Inherits:
-
Object
- Object
- GPSTool::Devices::RBT2300::DataParser
- Defined in:
- lib/gpstool/devices/rbt-2300/data-parser.rb
Instance Attribute Summary collapse
-
#frames ⇒ Object
readonly
Returns the value of attribute frames.
Instance Method Summary collapse
- #append_data(datas) ⇒ Object
-
#initialize(format = 0) ⇒ DataParser
constructor
A new instance of DataParser.
Constructor Details
#initialize(format = 0) ⇒ DataParser
Returns a new instance of DataParser.
22 23 24 25 |
# File 'lib/gpstool/devices/rbt-2300/data-parser.rb', line 22 def initialize(format = 0) @frames = [] @floats = RBT2300::floats_for_format(format) end |
Instance Attribute Details
#frames ⇒ Object (readonly)
Returns the value of attribute frames.
27 28 29 |
# File 'lib/gpstool/devices/rbt-2300/data-parser.rb', line 27 def frames @frames end |
Instance Method Details
#append_data(datas) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/gpstool/devices/rbt-2300/data-parser.rb', line 29 def append_data(datas) sz = 4 + (@floats * 4) while datas.size >= sz # Pop buf off the front buf = datas[0...sz] datas = datas[sz..-1] #puts "Inspecting data: #{buf.inspect}" # Extract Date date = buf.unpack("CCCC") #puts "Extracted date: #{date.inspect}" bufo = buf[4..-1] # We need to extract IEEE floats buf = bufo.unpack("C*").reverse.pack("C*") numbers = buf.unpack("g" * @floats).reverse @frames << [date, numbers] end end |