I have a device that has a checksum that is the addition of the ASCII values and truncated to the rightmost four digits.
I have searched the documentation for a way to read this checksum and generate a similar one, but have so far come up empty handed. Any hints would be appreciated.
Can you give us a little more to go on here?
The device type and model number? Link to the manual perhaps?
Also are you trying to do the checksum calc in PAC Control or Node-RED or something else?
Sorry I should get better at including more information. The device is an LCI-90i ( Featured Products & Solutions | Rugged Controls ). The bits of interest are on pages 79-81. I am planning on using the MTNW1 or MTNW Legacy protocol.
The device generates a checksum by adding up the ASCII values of the string it is about to send then appends it to the end of the string. I am looking to be able to validate the data and recreate this type of checksum.
From the documentation I started to think I could go through it charecterwise, but then wasn’t sure how to go about that on the string.
I have used the PAC Control Checksum function successfully in the past with other devices.
Thank you for this information. I am just trying to understand the function: sDataField is the string to calculate. I am unsure what bitand and 0x7f are.
Yes sDataField would be your payload. The 0x7f is 0111 1111 in binary, it is to look at the last 7 bits of the character only. Since it is an ASCII protocol, the first bit should be 0 for each character - so it is more of a defensive programming thing, you could leave the bitand 0x7f off and it should still work fine.