Logic Machine Forum
KNX - Dali Device Diagnostic telegram Decoding - 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: KNX - Dali Device Diagnostic telegram Decoding (/showthread.php?tid=2074)



KNX - Dali Device Diagnostic telegram Decoding - manos@dynamitec - 08.05.2019

Hello All,

Can anyone please help me decoding a 1 byte object as mentioned below?

1-byte object to transmit and read out the error status of individual DALI operating devices connected to the system. 
The following bit assignment is used:
Bit 0...5: Number of the DALI operating device (0...63)
Bit 6: Lamp error ("0" = No error, "1" = Error)
Bit 7: Electronic ballast error ("0" = No error, "1" = Error)

I could use the following code to get the status of the last two bits but I don't know how to convert the first 6 bits to integer and write the value to a virtual object. 

Code:
function getbit(value, nr)
value = bit.rshift(value, nr)
return bit.band(value, 1) == 1
end

value = event.getvalue()

grp.checkupdate('32/1/1', getbit(value, 6))
grp.checkupdate('32/1/2', getbit(value, 7))

Thank you in andvance.


RE: KNX - Dali Device Diagnostic telegram Decoding - admin - 08.05.2019

You need to apply a bit mask like this:
Code:
addr = bit.band(value, 0x3F)



RE: KNX - Dali Device Diagnostic telegram Decoding - manos@dynamitec - 08.05.2019

(08.05.2019, 13:59)admin Wrote: You need to apply a bit mask like this:
Code:
addr = bit.band(value, 0x3F)

Thank you admin. It works perfectly. So the final code to get the dali device address starting with 1->64 it will be like  this :

Code:
value = event.getvalue()
addr = bit.band(value, 0x3F)

function getbit(value, nr)
value = bit.rshift(value, nr)
return bit.band(value, 1) == 1
end

grp.checkupdate('32/1/50', (addr + 1))
grp.checkupdate('32/1/51', getbit(value, 6))
grp.checkupdate('32/1/52', getbit(value, 7))