TCP Socket DataAvailable CheckSum bytes help

Greetings,

I’m trying to interact with a control access device and according to their protocol documentation they say that in order to send the data I do have to make a checksum of some fields and to put the result in the last byte .

Based on this data

09030000005000010050000EE30546F0210546F00000001700004E20322E33322E303000000000000000000002000000000000000202020202020202000000000000000000000000000000000000

I get the checksum as

1F

Any Idea how to do that in Xojo ? Apparently it’s like a data validation when you want to send a tcp command and it has to match in order to process the data.

All the code is fetched from the controller , encoded into Hex to be readable and then processed. So far I managed to identify most of the data but still the checksum part is something new for me.

Thanks in advance.

Is the algorithm documented? Looking at that will be easier than reverse engineering it.

Well I honestly don’t see the point of reverse engineer something that I don’t have access to and the point of that checksum is to validate that the data that reaches there is not corrupt and the device once it matches the checksum it know that the package is valid and it starts processing it. so The point of this was to create the method to generate the checksum, the rest is simple I guess once you know the details. As for the Protocol documentation it does have 124 pages for the whole process but I wait for confirmation from the manufacturer as some parts don’t quite match so I guess I have an old protocol for a newer firmware.

I did tried to use this Example but it seems that once I do that the result I get is 182 which in Hex is B6 so not even Close to 1F, I guess I will have to ask them to see how they get to that point.

That example probably isn’t using the correct checksum algorithm. “Checksum” is a generic term that doesn’t refer to a specific algorithm, which is why I suggested looking at the docs.

Indeed, you are right, I asked the same question to them and I’m waiting for them to provide me the right answer .

Thanks.

Which device is it you try to use?

Hi Derk , it’s a Biosense .

So after little digging I found this site and after imputing the string to be checked 09030000005000010050000EE30546F0210546F00000001700004E20322E33322E303000000000000000000002000000000000000202020202020202000000000000000000000000000000000000 In HEX format I discovered that the site give me the right answer , now the funny part is applying the formulas to get that correct answer, unfortunately I’m not very good on this and it seems that the following type got the right answer.

CheckSum8 Modulo 256 Sum of Bytes % 256 Normal 1F

Any ideas on how to get this type of checksum work on my code ?

Thanks in advance.

It’s the sum of the bytes modulo 256:

Dim sum As Integer Dim data As MemoryBlock = DecodeHex("09030000005000...") For i As Integer = 0 To data.Size - 1 sum = sum + mb.Int8Value(i) Next sum = sum Mod 256

[quote=445432:@Andrew Lambert]It’s the sum of the bytes modulo 256:

Dim sum As Integer Dim data As MemoryBlock = DecodeHex("09030000005000...") For i As Integer = 0 To data.Size - 1 sum = sum + mb.Int8Value(i) Next sum = sum Mod 256[/quote]
Thanks a lot, I guess mb.Int8Value(i) is actually data.Int8Value(i) but it worked as expected after fixing the typo .