akreel
Member
Here's a question to keep our resident experts entertained.
I've been trying to write a little application that speaks Modbus. I'm starting from scratch, writing code to read/write the message string and calculate the CRC value. To test my program I've been inserting a known message string into it and comparing the CRC generated to the correct value. Guess what... They don't match, and neither to my hand calculations. So, I know I'm not reading the manual correctly.
Those of you who've dealt with the Modbus protocol on this level know that there are a series of binary shifts and XOR statements executed to determine the CRC. Somewhere in there, I must be doing a shift when I should be doing an XOR... What I'd REALLY like to see is a table that demostrates when to shift and when to XOR. Say for example; I want to transmit the hex number 0C (no commands, or anything just ONE byte). The CRC is preset to FFFF and I begin the shifting/XOR business (there should be 8 shifts, right?). What is my CRC going to look like at each step?
I decided to post this question because I thought you guys might enjoy showing off a little. Go nuts!
AK
I've been trying to write a little application that speaks Modbus. I'm starting from scratch, writing code to read/write the message string and calculate the CRC value. To test my program I've been inserting a known message string into it and comparing the CRC generated to the correct value. Guess what... They don't match, and neither to my hand calculations. So, I know I'm not reading the manual correctly.
Those of you who've dealt with the Modbus protocol on this level know that there are a series of binary shifts and XOR statements executed to determine the CRC. Somewhere in there, I must be doing a shift when I should be doing an XOR... What I'd REALLY like to see is a table that demostrates when to shift and when to XOR. Say for example; I want to transmit the hex number 0C (no commands, or anything just ONE byte). The CRC is preset to FFFF and I begin the shifting/XOR business (there should be 8 shifts, right?). What is my CRC going to look like at each step?
I decided to post this question because I thought you guys might enjoy showing off a little. Go nuts!
AK