Checksums to verify communication integrity

Hi.

I am doing some communication stuff to swap some data between a Windows desktop computer ans an Arduino Mega using serial port 2, old RS232, 5V of course.

The data coming from the desktop is formatted as 512byte chunks to maximize data storage in a SD card attaches to the Mega (MOSI MISO).

To avoid data losses in wiring link I decided to follow the data by a couple checksums: XOR'ing all bytes and also summing them all (using just the 8 less significant).

This two types of checks running in parallel, do really complement each other? Make sense? Any similar but better choice (not too complicated, please :slight_smile: )

Thanks
Martins

The two operations do not really complement each other and I see no real advantage to using both (the add actually has better performance than XOR on average, but unlike XOR, is data dependent). For either method, 1 out of 256 completely random messages matches any 8 bit checksum.

A 16 bit CRC would be much more reliable, and is just as easy to use. There are several Arduino libraries: this one should be fine and provides several options for the CRC checksum size.

The data coming from the desktop is formatted as 512byte chunks to maximize data storage in a SD card

I doubt that is a useful way of thinking about it. The SD library stores one byte at a time to an internal buffer, and writes out the buffer when full. And where would the check values go?

Thank you

And where would the check values go?

Nowhere. They are just used between desktop and micro-controller. At data arrival checksums are compared and, if they are the same, they aye forgotten.

HMartins:
Thank youNowhere. They are just used between desktop and micro-controller. At data arrival checksums are compared and, if they are the same, they aye forgotten.

If there is no code on either end to NAK a message and get a resend, there is nothing gained by adding a check sum.
Paul

Paul_KD7HB:
If there is no code on either end to NAK a message and get a resend, there is nothing gained by adding a check sum.
Paul

Not necessarily true. While it does not ensure a device always takes a correct action, it can ensure a device does NOT take an incorrect action. In many applications, doing nothing is far better than doing the wrong thing.

RayLivingston:
Not necessarily true. While it does not ensure a device always takes a correct action, it can ensure a device does NOT take an incorrect action. In many applications, doing nothing is far better than doing the wrong thing.

Not if you are running ATM machines in a bank!
Paul

At data arrival checksums are compared and, if they are the same, they aye forgotten.

What is your plan for the case that the checksums don't match?

Paul_KD7HB:
Not if you are running ATM machines in a bank!
Paul

And that is relevant to this conversation..... how? Pretty sure that is not what the OP is doing. And I said "many", not "all".

Windows desktop computer ans an Arduino Mega using serial port 2, old RS232, 5V of course.

What is "old RS232"? Traditional PC RS-232 certainly wasn't 5V.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.