Class: SerialCanBus::ExtendedFrame

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

Overview

Extended CAN frame with 29-bit identifier.

Instance Method Summary collapse

Instance Method Details

#dataObject

:attr_accessor: data frame data (binary)


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

rest   :data

#dlengthObject

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


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

string :dlength,    1*8, 'data_length'

#errorsObject


98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/serial_can_bus/serial_can_bus.rb', line 98

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 29-bit identifier (String, 8 bytes)


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

string :identifier, 8*8, '29-bit identifier'