 # CRC Calculation

I have a sample from 3rd party code which already calculated the checksum. They are using HDLC protocol, I want to figure out how they calculating checksum

Example:

How is msgOut can be calculated automatic or manually
Note: deviceAdress change so it should not be important (I think )

``````msgOut = 0x7E;
msgOut = 0x06;
msgOut = 0xBF;
msgOut = 0x17;
msgOut = cmdCode;
if(cmdCode == 0x00)
msgOut = 0x7B;
else if(cmdCode == 0x04)
msgOut = 0x67;
else if(cmdCode == 0x11)
msgOut = 0x0C;
else if(cmdCode == 0x12)
msgOut = 0x05;
msgOut = 0x7E;
rs485WriteHex(msgOut);
cmdCode = 0;
``````

Note: deviceAdress change so it should not be important (I think )

Then you think incorrectly.

PaulS:
Then you think incorrectly.

So lets assume device address is 0x11 then how we calculate the CRC

Shahreza:
So lets assume device address is 0x11 then how we calculate the CRC

How would you do it manually ?

UKHeliBob:
How would you do it manually ?

This is 3rd party code, with no description, this is all they gave me. I did some research but I could not get anything similar to this.

http://www.zorc.breitbandkatze.de/crc.html

What is "HLC protocol"?

jremington:
What is “HLC protocol”?

I missed “D” HDLC

Hi

I am not able to calculate check sum for below massages, I will be appreciated if you can tell how they get this checksum (I even try crc calculator) and how can we write a code for it .

example 1:
Checksum: 30
7E0511BF07307E

example 2:

Checksum 71
7E0611BF1704717E

Thank you

Tool to reverse engineer CRC algorithms, its dead neat:

http://reveng.sourceforge.net/

If it is indeed HDLC protocol, the algorithm has been published in many places.

However, the HDLC CRC check value is 16 bits, not 8 bits.