This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Integration with Satel alarm system via ETHM-1
#9
I have a script for a read the states of inputs. But I have a little problem in my resident script. I cannot use grp.write() or grp.update() because I have this error:

Code:
Line 0: attempt to call field 'rshift' (a nil value)


I've tried send the same in the other script and there was ok.

This is my script:

Code:
-- Integracja z systemem Satelem po TCP cmd = string.char(0xFE,0xFE,0x00,0xD7,0xE2,0xFE,0x0D) bytes = 23 -- function Satel(cmd, bytes) function satel_send(cmd, bytes) ethm_ip = '192.168.2.9' port = 7094 socket = require('socket') client=socket.tcp() success, error = client:connect(ethm_ip, port) if success == 1 and error == nil then client:settimeout(0.3) client:send(cmd) data, error, partial = client:receive(bytes) -- error if not data then data = partial end client:close()     end   return data end   -- Funkcja odpowiedzialna za wyciągniecie poszczególnych bitów i wstawienie ich do tabeli function convert(data)  local res, byte  res = {}  for i = 1, #data do    -- get single byte    byte = data:byte(i, i)    byte = string.char(byte)    bits = hex2bin(byte)    for b = 1, #bits do    -- get single bit    bit = bits:byte(b, b)    bit = string.char(bit)    if bit == '0' then      bin = false    elseif bit =='1' then      bin = true    end    -- add to result    res[i*4-(4-b)] = bin    end  end  return res end data = satel_send(cmd, bytes) -- check if some data is available if data then data = lmcore.strtohex(data, true) -- delete first 4 and last 8 chars data = string.sub(data, 5, (string.len(data) -8)) inputs = convert(data) else log('Satel: zajęty') end -- update the inputs in the LM database for i = 1, #inputs do GA = '0/0/'.. tostring(91+i-1) grp.update(GA , inputs[i]) end
Reply


Messages In This Thread
RE: Integration with Satel alarm system via ETHM-1 - by buuuudzik - 25.10.2016, 14:43

Forum Jump: