Class: SerialCanBus::StandardFrame

Inherits:
BitStruct
  • Object
show all
Defined in:
lib/serial_can_bus/serial_can_bus.rb

Overview

Standard CAN frame with 11-bit identifier.

Instance Method Summary collapse

Instance Method Details

#dataObject

:attr_accessor: data frame data (binary)


61
# File 'lib/serial_can_bus/serial_can_bus.rb', line 61

rest   :data

#dlengthObject

:attr_accessor: dlength data length (String, 1 byte)


56
# File 'lib/serial_can_bus/serial_can_bus.rb', line 56

string :dlength,    1*8, 'data_length'

#errorsObject


63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/serial_can_bus/serial_can_bus.rb', line 63

def errors
  errors = []

  unless (0..8).include?(dlength.to_i)
    errors << "invalid length (#{dlength} != 0-8)"
  end

  if data.size > 8 * 2
    errors << "excessive data length (#{data.size / 2} > 8)"
  end

  errors
end

#identifierObject

:attr_accessor: identifier 11-bit identifier (String, 3 bytes)


51
# File 'lib/serial_can_bus/serial_can_bus.rb', line 51

string :identifier, 3*8, '11-bit identifier'