Class: Orion6Rep::Command
- Inherits:
-
Object
- Object
- Orion6Rep::Command
show all
- Defined in:
- lib/orion6_rep/command.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.convert_to_integer_as_big_endian(integer_array) ⇒ Object
This method is the same of the little-endian one above, just with the input data reversed.
166
167
168
|
# File 'lib/orion6_rep/command.rb', line 166
def convert_to_integer_as_big_endian(integer_array)
convert_to_integer_as_little_endian(integer_array.reverse)
end
|
.convert_to_integer_as_little_endian(integer_array) ⇒ Object
156
157
158
159
160
161
162
|
# File 'lib/orion6_rep/command.rb', line 156
def convert_to_integer_as_little_endian(integer_array)
value = 0
integer_array.each_with_index do |byte, index|
value += (byte.to_i << 8*index)
end
value
end
|
.xor(data) ⇒ Object
147
148
149
150
151
152
153
154
|
# File 'lib/orion6_rep/command.rb', line 147
def xor(data)
value = 0;
data = data.unpack("C*") if data.is_a?(String)
data.each do |integer|
value ^= integer
end
value
end
|
Instance Method Details
#execute ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/orion6_rep/command.rb', line 25
def execute
command_data =
command_data += generate_command_data
response = Communication.communicate(get_host_address, get_tcp_port, command_data, get_expected_response_size, get_timeout_time, get_max_attempts)
(response)
check_response_payload(response)
payload = get_response_payload(response)
return get_data_from_response(payload)
end
|