Logic Machine Forum
Translate 2byte hex values to 14byte string - 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: Translate 2byte hex values to 14byte string (/showthread.php?tid=1909)



Translate 2byte hex values to 14byte string - manos@dynamitec - 14.02.2019

Hello everyone,

I am looking a way to translate the right column's data (2byte DPT 7) of the attached file to 14byte DPT 16 ASCII characters string in order to get the Daikin error code from the coolmaster and show it on the visualization. I was thinking a code to do something like 'if value (2byte)=0X10 then write a string with the corresponding error characters from daikin A0. There is no need to send this into the KNX so if there is any other way to do it it's ok for me. Any help with a code example is welcomed. 

Thanks in advance


RE: Translate 2byte hex values to 14byte string - admin - 14.02.2019

You can create a table to map hexadecimal error code to text, then attach it to error code object. You should use 250-byte text data type for status output (32/1/3 in this example).

Code:
errors = {
  [0x10] = 'External protection device activated',
  [0x11] = 'Malfunction of indoor unit PCB',
  [0x13] = 'Drain Level Control System Abnormality',
  [0x14] = 'Malfunction of freezing protection',
  [0x15] = 'High pressure control in heating, freeze-up protection control in cooling',
}

value = event.getvalue()
errtext = errors[ value ]

if errtext then
  grp.update('32/1/3', errtext)
end



RE: Translate 2byte hex values to 14byte string - manos@dynamitec - 14.02.2019

(14.02.2019, 10:54)admin Wrote: You can create a table to map hexadecimal error code to text, then attach it to error code object. You should use 250-byte text data type for status output (32/1/3 in this example).

Code:
errors = {
 [0x10] = 'External protection device activated',
 [0x11] = 'Malfunction of indoor unit PCB',
 [0x13] = 'Drain Level Control System Abnormality',
 [0x14] = 'Malfunction of freezing protection',
 [0x15] = 'High pressure control in heating, freeze-up protection control in cooling',
}

value = event.getvalue()
errtext = errors[ value ]

if errtext then
 grp.update('32/1/3', errtext)
end

Perfect. Thank you admin. Smile


RE: Translate 2byte hex values to 14byte string - manos@dynamitec - 10.07.2019

Hello Admin,

I have a small problem with this solution. The data type indicating the error code is 2byte unsigned value. When I am reading the error code via ETS - KNX Group monitor I am getting a value 29 00 for exmple and the error cannot be translated. If then I manually write the value 00 29 then it works fine. Is there a way to check the 1st byte instead of the 2nd so that the maping table then can correctly translate the error code to a 250byte string?

Thank you


RE: Translate 2byte hex values to 14byte string - admin - 10.07.2019

You can specify table keys as two byte values. For example 0x2900

Or you can get one byte like this:
Code:
value = event.getvalue()
value = bit.rshift(value, 8)
errtext = errors[ value ]