CRC32: How to validate the message?

CRC32: How to validate the message?

Postby VTW » Mon Jun 27, 2016 6:41 am

I am sending multiple messages from a MCU to my computer and I want to use a 32-bit Cyclic Redundancy Check to verify that the messages are correct. From what I've read, it should be possible to append the last CRC reminder to the last message and run that through the CRC function. If the message was error free, it should then return zero. I have however been unsuccessful in implementing this using the binascii-library [binascii.crc32()].

Let's for example say I want to check the message internally from the example given in python docs (I'm using P 3.5). How would I go ahead checking if this was the correct message?

Code: Select all
crc = binascii.crc32(b"hello")
crc = binascii.crc32(b" world", crc)
Last edited by micseydel on Mon Jun 27, 2016 7:15 am, edited 1 time in total.
Reason: Initial post lock.
VTW
 
Posts: 2
Joined: Mon Jun 27, 2016 6:23 am

Re: CRC32: How to validate the message?

Postby Ofnuts » Mon Jun 27, 2016 7:43 am

VTW wrote:From what I've read, it should be possible to append the last CRC reminder to the last message and run that through the CRC function. If the message was error free, it should then return zero.


Possibly. But you can also recompute the CRC of the actual message, without appending the CRC, and check that this is the same as the CRC that was transmitted wit the message.
This forum has been moved to http://python-forum.io/. See you there.
User avatar
Ofnuts
 
Posts: 2659
Joined: Thu May 14, 2015 9:46 am
Location: Paris, France, EU, Earth, Solar system, Milky Way, Local Cluster, Universe #32987440940987

Re: CRC32: How to validate the message?

Postby VTW » Wed Jun 29, 2016 1:53 pm

I ended up doing just that, thank you :)
VTW
 
Posts: 2
Joined: Mon Jun 27, 2016 6:23 am


Return to Networking

Who is online

Users browsing this forum: No registered users and 2 guests

cron