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
#1
Hello,

I want prepare the integration with Satel alarm system via ETHM-1 module. Normally it should work when I send the command via TCP.
Code:
123456789
host, port = '192.168.0.15', 7094 socket = require("socket") client = socket.tcp() client:settimeout(1) client:connect(host, port) cmd = string.char(0xFE,0xFE,0x7E,0xD8,0x60,0xFE,0x0D) client:send(cmd) result = client:receive() log(result)

Result is sometimes 'nill' and sometimes "Busy". I know that this should work because I've checked a communication with ETM-1 via some program which was prepared according with this documentation.

According to the documentation to read armed partitions I must send:
Code:
1
cmd = string.char(0xFE,0xFE,0x09,0xD7,0xEB,0xFE,0x0D)

Ethm-1 should answer with
Code:
1
0xFE, 0xFE, 0x09, DATA1, DATA2, DATA3, DATA4, CRC_HIGH, CRC_LOW, 0xFE, 0x0D

but the answer is 'nil' or 'Busy'(this command I can understand)

Attached Files
.pdf   ethm1_op_pl_1.07.pdf (Size: 79.46 KB / Downloads: 26)
Reply
#2
Try increasing the timeout value, the device might need more than 1 second to produce a reply.
Reply
#3
I've tried with timeout 3s and 5s and the situation is the same.

I've also tried send example frame via Packet Sender and it works properly, ETHM-1 answered. So it looks like the command sent by LM is not properly.

Attached Files Thumbnail(s)
   
Reply
#4
Since you are calling receive() without any arguments it will try to receive all data before socket is closed which is probably not the behavior you want. Try specifying the number of bytes that the reply should contain and it should work.
Reply
#5
(25.10.2016, 06:18)admin Wrote: Since you are calling receive() without any arguments it will try to receive all data before socket is closed which is probably not the behavior you want. Try specifying the number of bytes that the reply should contain and it should work.

Good tip, because now I have response but this response is shorter than the query(look at the screenshot). I've tried also '*a' and '*l' arguments but they gave 'nill'. Response should have 15 bytes.
Code:
12345678910111213141516171819202122232425262728293031
function str2hex(str)     raw_len = string.len(str)     i = 1   while i <= raw_len do     current_hexvalue = '0x' .. string.format("%02x", string.byte(str, i))     if value then       value = value .. ', ' .. current_hexvalue     else         value = current_hexvalue     end     i = i + 1   end   return value end socket = require('socket') client=socket.tcp() client:connect('192.168.2.9', 7094) client:settimeout(1) cmd = string.char(0xFE,0xFE,0x18,0xD7,0xFA,0xFE,0x0D) log(cmd) client:send( cmd ) result = client:receive(15) result_str = lmcore.strtohex(result, true) result_str1 = str2hex(result) log(result, result_str, result_str1)

And also unfortunately I've tried use lmcore.strtohex() but it gives me empty string. I've tried also the str2hex() from Erwin example but it gives me the same. I don't know also why the last 2 variables are not logged and there is no error describing this situation?

I've checked another way and it works perfect Smile 

Code:
123456789101112131415161718192021222324252627282930313233
function str2hex(str)    raw_len = string.len(str)    i = 1  while i <= raw_len do    current_hexvalue = '0x' .. string.format("%02x", string.byte(str, i))    if value then      value = value .. ', ' .. current_hexvalue    else        value = current_hexvalue    end    i = i + 1  end  return value end socket = require('socket') client=socket.tcp() client:connect('192.168.2.9', 7094) client:settimeout(1) cmd = string.char(0xFE,0xFE,0x18,0xD7,0xFA,0xFE,0x0D) log(cmd) client:send( cmd ) result = client:receive(15) result_str = lmcore.strtohex(result, true) result_str1 = str2hex(result) log(result) log(result_str) log(result_str1)


I don't know why this works

Code:
123
log(result) log(result_str) log(result_str1)
and this is not working(and there is no error):
Code:
1
log(result, result_str, result_str1)


And maybe there is another way to receive some data because sometimes I will not know what is the data length? Maybe not in this script but in the future.

Attached Files Thumbnail(s)
   
Reply
#6
Correction: default receive pattern is '*l' - a single line, not the whole result. Receive() will return partial result as a third return value when an error occurs (that's why you are getting an empty string). So you can use '*a' pattern to receive everything until timeout occurs. This is not the most efficient way, but it will work Smile

Code:
12345678910111213
data, err, partial = client:receive('*a') -- error if not data then   data = partial end -- do something with data that's available if data then   parsedata(data) end client:close()

As for hex logging, new firmware will have loghex() function to make this easier.
Reply
#7
'new' means 20160927? Smile
Reply
#8
The next release after that, 20160927 with KNX patch will be marked as stable. We will release a preview version sometime next month.

Just got info from our partners that there's a Satel integration app in the works.
Reply
#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:
1
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:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
-- 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
#10
You're overriding global "bit" which is used by other libraries in your convert function, add it to local declaration or rename this variable.
Reply
#11
Interesting to connect to Satels First via ethm card and commands. I havet done this in my home with knx v1 interface from them. That works perfect inn case u need another solution Smile
Reply
#12
(26.10.2016, 20:40)PassivPluss Wrote: Interesting to connect to Satels First via ethm card and commands. I havet done this in my home with knx v1 interface from them. That works perfect inn case u need another solution Smile

I have a project with Integra 256plus so 64group addresses from KNX v1 or v2 is not enough.

But I know some important tip from one Satel integrator that KNX module is much reliable than ethm when you have in your project communication via telephone link with monitoring station(when integra sends some data to the monitoring station all connections via ethm are terminated but KNX still works).

So at this moment ethm is a full option(you can integrate whole installation without loosing any additional inputs/outputs) but you must have good script because sometimes ethm is "Busy!".
KNX module v2 is reliable but you loose inputs/outputs, it has only 64 variables.
Reply
#13
Satel APP for integration Satel Security System and KNX is avalable in store Smile
Reply
#14
Very nice appWink Is this app use the https? What is the price? Is this working with ETHM v1? Can you provide some manual?
Reply
#15
Manual is built in app. Application uses ETHM1 Plus module.
Reply


Forum Jump: