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.

222.100 datatype on 6 bytes
#3
Hi,

Create a 255 byte object (1/1/1 in this sample) and link it to the address of your 6 byte value that you use in the ETS and attached this script to it:

Code:
if event.src ~= 'local' then
 value = event.getvalue()
 value = lmcore.strtohex(value)
 bytestable = {}
 for i = 2, #value, 2 do
   bytevalue = string.sub(value, (i-1), i)
   table.insert(bytestable, bytevalue)
 end
 value1 = knxdatatype.decode(bytestable[1] .. bytestable[2], dt.float16)
 value2 = knxdatatype.decode(bytestable[3] .. bytestable[4], dt.float16)
 value3 = knxdatatype.decode(bytestable[5] .. bytestable[6], dt.float16)
 grp.update('32/1/1', value1)
 grp.update('32/1/2', value2)
 grp.update('32/1/3', value3)
end

That will give you the 3x 2 byte float objects that you can export to BACnet.

Attach a tag to the 3x 2 byte float objects and create a event based script attached to that tag and paste this script in it:

Code:
if event.src == 'local' then
  value1 = grp.find('32/1/1').datahex
  value2 = grp.find('32/1/2').datahex
  value3 = grp.find('32/1/3').datahex
  sixbytevaluestring = lmcore.hextostr(value1 .. value2 .. value3)
  oldvalue = grp.getvalue('1/1/1')
  if oldvalue ~= sixbytevaluestring then
    grp.write('1/1/1', sixbytevaluestring)
  end
end

This will write the (BACnet side) changed value back to your 6 byte object. Because i added event.src you can use the same 255 byte object for incomming and outgoing telegrams and avoid triggering a loop.

BR,

Erwin
Reply


Messages In This Thread
222.100 datatype on 6 bytes - by domotiqa - 27.09.2017, 10:15
RE: 222.100 datatype on 6 bytes - by domotiqa - 27.09.2017, 13:32
RE: 222.100 datatype on 6 bytes - by Erwin van der Zwart - 27.09.2017, 18:02
RE: 222.100 datatype on 6 bytes - by domotiqa - 28.09.2017, 10:36
RE: 222.100 datatype on 6 bytes - by domotiqa - 28.09.2017, 11:20
RE: 222.100 datatype on 6 bytes - by domotiqa - 28.09.2017, 18:09
RE: 222.100 datatype on 6 bytes - by admin - 28.09.2017, 18:12
RE: 222.100 datatype on 6 bytes - by domotiqa - 29.09.2017, 04:47
RE: 222.100 datatype on 6 bytes - by admin - 29.09.2017, 06:48
RE: 222.100 datatype on 6 bytes - by domotiqa - 29.09.2017, 14:32
RE: 222.100 datatype on 6 bytes - by admin - 29.09.2017, 16:46
RE: 222.100 datatype on 6 bytes - by domotiqa - 29.09.2017, 17:04
RE: 222.100 datatype on 6 bytes - by admin - 29.09.2017, 17:34
RE: 222.100 datatype on 6 bytes - by domotiqa - 29.09.2017, 17:39
RE: 222.100 datatype on 6 bytes - by domotiqa - 02.10.2017, 07:10
RE: 222.100 datatype on 6 bytes - by domotiqa - 02.10.2017, 13:46
RE: 222.100 datatype on 6 bytes - by domotiqa - 03.10.2017, 09:24
RE: 222.100 datatype on 6 bytes - by admin - 03.10.2017, 10:29
RE: 222.100 datatype on 6 bytes - by domotiqa - 03.10.2017, 12:22

Forum Jump: