33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/aurora/modbus/slave.rb', line 33
def read_rtu_response(io)
msg = read(io, 2)
function_code = msg.getbyte(1)
case function_code
when 1, 2, 3, 4, 65, 66
msg += read(io, 1)
msg += read(io, msg.getbyte(2) + 2)
when 5, 6, 15, 16
msg += read(io, 6)
when 22
msg += read(io, 8)
when 0x80..0xff
msg += read(io, 3)
else
log "Rx (#{msg.size} bytes): " + logging_bytes(msg)
raise ::ModBus::Errors::IllegalFunction, "Illegal function: #{function_code}"
end
msg
end
|