10.01.2020, 09:18
(13.12.2019, 11:59)admin Wrote: Use this script:
Code:hex = event.datahex
bytes = {}
for i = 1, 6 do
pos = 1 + (i - 1) * 2
ch = hex:sub(pos, pos + 1)
bytes[ i ] = tonumber(ch, 16) or 0
end
ltrf = bit.band(bit.rshift(bytes[ 1 ], 4), 0x0F)
ltrd = bit.band(bytes[ 1 ], 0x0F)
ltrp = bit.band(bit.rshift(bytes[ 2 ], 4), 0x0F)
sf = bit.band(bit.rshift(bytes[ 3 ], 6), 0x03)
sd = bit.band(bit.rshift(bytes[ 3 ], 4), 0x03)
sp = bit.band(bit.rshift(bytes[ 3 ], 2), 0x03)
ldtr = bit.bor(bit.lshift(bytes[ 4 ], 8), bytes[ 5 ])
lpdtr = bytes[ 6 ]
log(ltrf, ltrd, ltrp, sf, sd, sp, lpdtr)
The script works and logs the right datasets. What I need now is a way to write out the different parts to different group addresses for BMS purposes. Could you give a hint on how to do this also?
And also thanks for the base script.