Hello FC community,
at the moment it try to find my way to the CRC checksum operation.
In a RS232 serial byte transmission I have as an example the following byte sequence:
0x7E 0x9F 0x4C 0xA1 0xA8 0x5D 0x55 0x00 0x11 0xE8 0x23 0x21 0x1B 0x00 0xF4
0xF4 the last byte is a CRC checksum made with a polynomial X^8 + X^2 + X + 1 and the underlined byte group. From what I read and learned this polynomial should look like the following bit sequence: 100000111 (9Bits)
In the intranet I found the following CRC-8 checksum calculator: http://smbus.org/faq/crc8Applet.htm
If I drop in the above byte sequence in the CRC-8 calculator ( 4CA1A85D550011E823211B00 ) I get exactly 0xF4 as a result.
If I work with only one byte and the CRC-8 calculator. For example I take the first underlined byte( 0x4C ) and put it in the calculator,
I get 0xE3 as a result. So far so good. From my knowledge this checksum is made with the following math. Starting with 0x4c = 0b01001100 = 0b1001100
100110000000000 “Adding 8 times zero from the a polynomial”
100000111 The polynomial (9Bit)
000110111000000 XOR result
>>>100000111 Again the polynomial
000010111111000 XOR result
>>>>100000111 Again the polynomial
>>>>00111100100 XOR result
>>>>>>100000111 Again the polynomial
>>>>>>011100011 XOR final result 0xE3!! Bingo!!
My problem now is how can I apply / create the above CRC checksum calculation / workflow in Flow Code. I´m using FC4. Every learning help is aprechiated.
Best regards Dirk
CRC-8 checksum calculation
Moderator: Benj
-
- Posts: 99
- Joined: Fri Feb 02, 2007 3:54 pm
- Location: Germany
- Has thanked: 14 times
- Been thanked: 12 times
-
- Posts: 99
- Joined: Fri Feb 02, 2007 3:54 pm
- Location: Germany
- Has thanked: 14 times
- Been thanked: 12 times
Re: CRC-8 checksum calculation
...the underlined Byte Group is:
0x4C 0xA1 0xA8 0x5D 0x55 0x00 0x11 0xE8 0x23 0x21 0x1B 0x00
BR
Dirk
0x4C 0xA1 0xA8 0x5D 0x55 0x00 0x11 0xE8 0x23 0x21 0x1B 0x00
BR
Dirk
-
- Posts: 594
- Joined: Thu Sep 17, 2009 7:52 am
- Location: Belgium
- Has thanked: 63 times
- Been thanked: 102 times
Re: CRC-8 checksum calculation
Code: Select all
// unsigned char rs232_byte, contains value 0x4C from RS232
unsigned long temp = 0;
unsigned long poly = 0x107;// 0001 0000 0111
temp = rs232_byte << 8; // adding 8 zeros
temp = temp ^ (poly << 7); // XOR 1
temp = temp ^ (poly << 4); // XOR 2
temp = temp ^ (poly << 3); // XOR 3
temp = temp ^ poly; // XOR 4
temp = temp & 0xFF; // clear unwanted bits
unsigned char CRC = temp;
- Nicolas
EDIT: Didn't see this post is a month old, sorry.
-
- Posts: 99
- Joined: Fri Feb 02, 2007 3:54 pm
- Location: Germany
- Has thanked: 14 times
- Been thanked: 12 times
Re: CRC-8 checksum calculation
Hello Nicolas,
many thanks for the Input.
Unfortunatly the calculation is giving me always 0xCF as a CRC result.
No matter what start value i have.
BR
Dirk
Note: The FC file is made with FC6
many thanks for the Input.
Unfortunatly the calculation is giving me always 0xCF as a CRC result.
No matter what start value i have.
BR
Dirk
Note: The FC file is made with FC6
- Attachments
-
- FC6 CRC8 calculation.fcfx
- (5.36 KiB) Downloaded 421 times
-
- CRC8 in FC6.jpg
- (177.64 KiB) Downloaded 3559 times