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.

Emergency Light, decoding of status
#10
(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. Smile
Reply


Messages In This Thread
RE: Emergency Light, decoding of status - by chriscroko - 10.01.2020, 09:18

Forum Jump: