CRC 16 checksum

Hello everybody,

This is my first request in this forum, as I have been around for a long time with a problem:

Through TCP binding I get a corresponding string; This is evaluated in a rule and an “ACK” message is generated. This is now to be returned to the device. The problem is that the string must contain a checksum (CRC16) for the recipient to accept the message. The checksum is generated from the message length.

Can someone tell me how to create a CRC16 checksum in openHAB2 from a string?

regards
Michael

http://introcs.cs.princeton.edu/java/61data/CRC16.java

Thank you for the informations.

Unfortunately, I’m not the Java Specialist. How is the module to be integrated so that I can use the function in a rule? Can you help me here?

Many Thanks
Michael

Hi Michael.
Do you have any progress with calculation of CRC? Because I also need it. The main problem for writing it on Xtend is missing XOR operator in this language. Do you find any tricks?

Even though it’s not documented, the ^ operator might work.

If not you could write a lambda and implement the XOR using the operators you do have. See https://stackoverflow.com/questions/373262/how-do-you-implement-xor-using for lots of approaches.