Computationally inexpensive 7-bit CRC/checksum applied on byte stream?
-
I'm working on an embedded communication protocol where bytes will be transmitted. In my packets, I can only allocate 7 bits for integrity check. If I just sum up the bytes module 256 and then throw out the MSb, then I suspect errors in the first bit in each byte would not be detected. Can someone please recommend a computationally inexpensive method that is a little more robust? It needs to be computationally inexpensive because it could potentially run on small, slow microcontrollers.
-
I'm working on an embedded communication protocol where bytes will be transmitted. In my packets, I can only allocate 7 bits for integrity check. If I just sum up the bytes module 256 and then throw out the MSb, then I suspect errors in the first bit in each byte would not be detected. Can someone please recommend a computationally inexpensive method that is a little more robust? It needs to be computationally inexpensive because it could potentially run on small, slow microcontrollers.
You could XOR the nibbles of each byte together and use aggregate those values as your checksum. It's not perfect, multiple errors in a byte could lead to collisions, but it's better than the alternative and should still be speedy.
"Never attribute to malice that which can be explained by stupidity." - Hanlon's Razor