When I press the RS485 panel button, I can use the LM resident script to read the command message of the panel. The message received every time I press the button is the same. I want to control the light switch, and my script has implemented the light on action. How can I turn off the light? Can anyone help me? Thank you in advance.
button cmd(hex): 02 20 10 11 00 01 00 80 4E E3 02 20 10 11 00 01 00 FF 0F 03
code:
button cmd(hex): 02 20 10 11 00 01 00 80 4E E3 02 20 10 11 00 01 00 FF 0F 03
code:
Code:
if not port then
require('serial')
port = serial.open('/dev/RS485-1', {
baudrate = 9600,
databits = 8,
stopbits = 1,
parity = 'none',
duplex = 'half'
})
function read()
local buf = {}
while true do
local timeout = #buf > 0 and 0.5 or 19
local char = port:read(1, timeout)
if char then
buf[ #buf + 1 ] = char:byte()
else
return buf
end
end
end
end
res = read()
--log(res)
if #res == 20 then
for key, value in pairs(res) do
if res[4] == 0x11 and ( res[8] == 0x80 or res[18] == 0xFF ) then
if grp.find("13/1/21")["data"] ~= true then
grp.write("13/1/21",true)
log("key1sucessfull")
end
end
end
end