Class: SerialCanBus::Request::StandardSetup

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

Overview

Setup predefined CAN bus speeds.

Constant Summary collapse

BITRATE =

Standard values for predefined CAN bit-rates.

{ 1000000 => '8',
                 800000 => '7',
                 500000 => '6',
                 250000 => '5',
                 125000 => '4',
                 100000 => '3',
50000 => '2',
20000 => '1',
10000 => '0' }

Instance Method Summary collapse

Instance Method Details

#bitrate=(bitrate) ⇒ Object


80
81
82
83
84
85
86
# File 'lib/serial_can_bus/request.rb', line 80

def bitrate=(bitrate)
  unless BITRATE[bitrate]
    raise 'unsupported bitrate'
  end

  self.value = BITRATE[bitrate]
end

#valueObject

:attr_accessor: value bitrate (String, 1 bytes), see BITRATE constant and bitrate=() for automatic conversion from Fixnum


78
# File 'lib/serial_can_bus/request.rb', line 78

string :value, 1*8, 'command', :default => BITRATE[125000]