Class: SerialCanBus::Response::StatusFlag

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

Overview

Provides decoding for the ASCII status_flag returned by the respective Request.

Instance Method Summary collapse

Instance Method Details

#arbitration_lostObject

arbitration lost (TrueClass or FalseClass)


84
85
86
# File 'lib/serial_can_bus/response.rb', line 84

def arbitration_lost
  !((status_flag.to_i(16) >> 1) & 1).zero?
end

#bus_errorObject

bus error (TrueClass or FalseClass)


89
90
91
# File 'lib/serial_can_bus/response.rb', line 89

def bus_error
  !((status_flag.to_i(16) >> 0) & 1).zero?
end

#data_overrunObject

data overrun (TrueClass or FalseClass)


74
75
76
# File 'lib/serial_can_bus/response.rb', line 74

def data_overrun
  !((status_flag.to_i(16) >> 4) & 1).zero?
end

#dumpObject

dump a Hash with all available information


94
95
96
97
98
99
100
101
102
103
104
# File 'lib/serial_can_bus/response.rb', line 94

def dump
  { :status_flag => status_flag,
    :rx_queue_full => rx_queue_full,
    :tx_queue_full => tx_queue_full,
    :error_warning => error_warning,
    :data_overrun => data_overrun,
    :error_passive => error_passive,
    :arbitration_lost => arbitration_lost,
    :bus_error => bus_error
  }
end

#error_passiveObject

error passive (TrueClass or FalseClass)


79
80
81
# File 'lib/serial_can_bus/response.rb', line 79

def error_passive
  !((status_flag.to_i(16) >> 2) & 1).zero?
end

#error_warningObject

error warning (TrueClass or FalseClass)


69
70
71
# File 'lib/serial_can_bus/response.rb', line 69

def error_warning
  !((status_flag.to_i(16) >> 5) & 1).zero?
end

#rx_queue_fullObject

CAN receive FIFO queue full (TrueClass or FalseClass)


59
60
61
# File 'lib/serial_can_bus/response.rb', line 59

def rx_queue_full
  !((status_flag.to_i(16) >> 7) & 1).zero?
end

#status_flagObject

:attr_accessor: status_flag status flag (String, 2 bytes)


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

string :status_flag, 2*8

#tx_queue_fullObject

CAN transmit FIFO queue full (TrueClass or FalseClass)


64
65
66
# File 'lib/serial_can_bus/response.rb', line 64

def tx_queue_full
  !((status_flag.to_i(16) >> 6) & 1).zero?
end