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 whether you accept or reject these cookies being set.

KNX - Dali Device Diagnostic telegram Decoding
#1
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.
Reply
#2
You need to apply a bit mask like this:
Code:
addr = bit.band(value, 0x3F)
Reply
#3
(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))
Reply


Forum Jump: