29.09.2017, 06:48
My idea was to have 6-byte objects addressed starting from 3/1/0 and 2-byte object addressed starting from 3/2/0.
Then you can get 2-byte addresses from 6-byte address like this:
And get 2-byte addresses and 6-byte address from 2-byte address like this:
Then you just map different tags to 2-byte and 6-byte objects and use Erwin's conversion script. It can be simplified a bit by using event.datahex instead of using getvalue/strtohex conversion.
Then you can get 2-byte addresses from 6-byte address like this:
Code:
addr = event.dst
last = tonumber(addr:split('/')[3])
off = last * 3
addr1 = '3/2/' .. (off)
addr2 = '3/2/' .. (off + 1)
addr3 = '3/2/' .. (off + 2)
log(addr1, addr2, addr3)
And get 2-byte addresses and 6-byte address from 2-byte address like this:
Code:
addr = event.dst
last = tonumber(addr:split('/')[3])
off = math.floor(last / 3)
addr1 = '3/2/' .. (off * 3)
addr2 = '3/2/' .. (off * 3 + 1)
addr3 = '3/2/' .. (off * 3 + 2)
out = '3/1/' .. off
log(addr1, addr2, addr3, out)
Then you just map different tags to 2-byte and 6-byte objects and use Erwin's conversion script. It can be simplified a bit by using event.datahex instead of using getvalue/strtohex conversion.