Class: Rplidar::CurrentStateDataResponse

Inherits:
Response
  • Object
show all
Defined in:
lib/rplidar/current_state_data_response.rb

Overview

Implementation of response to the GET_HEALTH request.

Instance Attribute Summary

Attributes inherited from Response

#raw_response

Instance Method Summary collapse

Methods inherited from Response

#check_header, #check_payload, #check_response, #initialize

Constructor Details

This class inherits a constructor from Rplidar::Response

Instance Method Details

#error_codeObject



12
13
14
# File 'lib/rplidar/current_state_data_response.rb', line 12

def error_code
  (raw_response[2] << 8) + raw_response[1]
end

#responseObject



4
5
6
7
8
9
10
# File 'lib/rplidar/current_state_data_response.rb', line 4

def response
  case raw_response[0]
  when STATE_GOOD    then { state: :good,    error_code: error_code }
  when STATE_WARNING then { state: :warning, error_code: error_code }
  when STATE_ERROR   then { state: :error,   error_code: error_code }
  end
end