Checksum Error Serial Port

Active4 years, 5 months ago
Checksum

I am currently working on a project involving a Serial COM from PC ( USB TO SERIAL application coded in C# ) to an embedded platform (STM32F4).I saw that in some cases it's mandatory to have a checksum in a communication frame. The Communication configuration:

I guess i would need to look for A3 and its preceding 1 byte and then byte 3,4,5. Do the checksum calculation, then calculate the decimal value of byte 3,4. Then finally calculate the actual value based on the documentation and store the value in a pre-defined variable (wTemp), based on the channel number of the packet.

Baud-rate = 115200,

No Parity bit,

One StopBit,

No Handshake,

Frame Length : 16 bytes

Is it worth adding a checksum in my application? What are the reasons why i should (not) have this checksum?

Thank you for your answer.

Alexandre M.Alexandre M.

2 Answers

Serial

Hp Cmos Checksum Error

Yes you must have a checksum. The only acceptable non-hobbyist solution is a proper checksum based on CRC. Most common industry standard is 'CRC-16-CCITT' (polynomal 0x1021). This will catch any single-bit error, most double-bit errors and some burst errors.

Even though you'll only use RS-232 in an office environment(?), any EMI caused by crappy consumer electronics could cause glitches and incorrect data. There is a lot of such crappy electronics around: for example it is not all that uncommon for the electronics in your PC to have poor EMC performance. In particular, there are countless of USB-to-serial adapters with downright awful quality.

The UART hardware in itself has no error detection worth mentioning: it is ancient 1960s technology. On the hardware level, it only checks data integrity based on start and stop bits, and will miss out any errors in between. (Parity checking is equally poor).

Alternatively, you could perhaps get an USB to RS-485 adapter instead and use RS-485, which is far more rugged as it has differential signals. But that requires that you have RS-485 transceivers on the target side too.

LundinLundin
121k17 gold badges171 silver badges283 bronze badges

It is customary to have a checksum in order to verify the correctness of the data although serial communication is relatively reliable. You will definitely need a sync made up of at least two bytes that will always be assigned a specific value which you don't expect to appear in your data. The sync is used in the receiving side to find the start of each message sent because it is a stream communication and not a packet based communication.

o_weismano_weisman

Serial Port Cable

Not the answer you're looking for? Browse other questions tagged c#ccommunicationserial-communication or ask your own question.

On the LinkMeter configuration page there is an indicator of how many times the communication between HeaterMeter and LinkMeter has been corrupted, labeled as 'Serial checksum errors'. This counter begs the question, how many errors is too many?

HeaterMeter transmits more than one data packet per second, so unless the number goes up every time you refresh the page, odds are serial errors aren't degrading your performance in any measurable fashion. When linkmeterd starts up, it frequently will get one checksum error as HeaterMeter is already sending data when the server starts. After that, one getting corrupted every hour isn't too bad, that's more than 99.9982% success! The only time you should be worried is if the number is continuously increasing.

What happens to bad data?

The HeaterMeter protocol includes start and stop characters as well as checksums like NMEA structures that come from GPS devices.

Checksum Error Serial Port

How To Fix Checksum Error

When the packet doesn't pass all the tests, it is discarded. For most messages, this is acceptable because new updated data will be along shortly to replace it. In the case of the configuration dump, this could lead to blank boxes showing up in the LinkMeter configuration webui. If this happens, you will not be able to edit any parameter which has a blank value. Simply use the 'reboot avr' button to reset the HeaterMeter microcontroller and re-fetch the configuration.

Comments are closed.