Integrity check / Checksum ? #46
Replies: 4 comments 4 replies
-
For 1: For 2: The protocol allows to create a CRC checksum for the symbol. For now I enter the value 0 into this field, means there's no checksum check in the plc. Otherwise the plc does check the CRC and you will get a read / write error if the value doesn't match. The CRC is calculated from the complete symbol path, with some specific value as delimiter. The latest version also adds the value for the datatype into the calculation, but that was not always the case as far as I can remember. But I guess that all TLS supporting controllers use the same calculation. For the CRC calculation the same generator polynom as in the Profisafe protocol is used. |
Beta Was this translation helpful? Give feedback.
-
I've made some tests. For simple variables the calculation is: If the datatype is Int, then you need to add a byte with value 5, for word 4 and so on. But if you have a struct or UDT it's different. I think it was 7-8 years ago, when you just needed to add a 0x09 as delimiter between STRUCTNAME and VARNAME, which I just have tried out in a loop until I got the correct CRC -> CRC(CRC(STRUCTNAME + 0x09 + VARNAME + DATATYPE)). But this doesn't work anymore. I've tried some other versions and values but without success. Example: For array I haven't tested this yet. Do you need this feature, or what improvement do you expect from using the checksum? I wasn't aware that the datablock name does not go into the checksum calculation, which feels for me some kind of incomplete. |
Beta Was this translation helpful? Give feedback.
-
We are looking for the best way to detect tag changes on the controller side, to avoid reading / writing the wrong values or getting a device exception. Reading the controller attribute 2479 does the check accurately but requires an extra transaction. The Symbol CRC seems to be a more efficient way to detect changes but appears to be incomplete, this could be the way to go but will require an extensive amount of trial and error testing. Or, do you know how (if possible) to send multiple COTP packets in one request? Can we send the explore request to read the controller attribute in the same transaction as the getMultiVar request? As far as the SymbolCRC goes, I am having trouble getting the initial browse CRC (sumsymbol CRC?) by using the VARNAME and DATATYPE. For instance, my tag myINT1 is an int (0x05) has the Subsymbol CRC: 0x040de366. Using the polynomial 0xF4ACFB13 I am unable to replicate how VARNAME + DATATYPE = 0x040de366. Are we using the right polynomial? |
Beta Was this translation helpful? Give feedback.
-
My base crc method I'm using is:
Then to get the first checksum I use: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Thomas and community, two questions:
UInt32 reqIntegCheck = (UInt32)request.SequenceNumber + request.IntegrityId;
if (response.IntegrityId != reqIntegCheck)
Is the reason simply just to make sure the response is the correct response to the request? Or is there another reason we do this?
Any info or advice is appreciated!
Beta Was this translation helpful? Give feedback.
All reactions