Logic Machine Forum
how to decode 4 byte access control - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: how to decode 4 byte access control (/showthread.php?tid=4376)



how to decode 4 byte access control - Hadeel - 14.11.2022

Hi!

I am trying to decode 4 byte access control value. In my project its group address is 13/3/9, data type is "15. 4byte access control".

The following image shows how the ETS group monitor decoded this value. like "11 11 11 40".
     

However, when I log the event.getvalue() in LM event script, as the second image shows the value does not make sense.
   

Is there a way to decode this value inside event script, like the ETS group monitor does ?

Thank you for your help in advance   Smile


RE: how to decode 4 byte access control - admin - 14.11.2022

Use this:
Code:
value = event.getvalue()

f0 = bit.band(bit.rshift(value, 28), 0x0F)
f1 = bit.band(bit.rshift(value, 24), 0x0F)
f2 = bit.band(bit.rshift(value, 20), 0x0F)
f3 = bit.band(bit.rshift(value, 16), 0x0F)
f4 = bit.band(bit.rshift(value, 12), 0x0F)
f5 = bit.band(bit.rshift(value, 8), 0x0F)

code = f0 .. f1 .. f2 .. f3 .. f4 .. f5
err = bit.band(value, 0x80) == 0x80
permission = bit.band(value, 0x40) == 0x40
direction = bit.band(value, 0x20) == 0x20
encryption = bit.band(value, 0x10) == 0x10
index = bit.band(value, 0x0F)

log(code, err, permission, direction, encryption, index)



RE: how to decode 4 byte access control - Hadeel - 14.11.2022

Dear admin,

Thank you so much for your quick reply!

I just tried the code and it's working perfect Smile

Much appreciated !