Go Down

Topic: CRC byte assembly and disassembly (Read 815 times) previous topic - next topic

sy kristina


I have a stream of bytes with a final crc byte I would like to compare with to check for errors.

in visual basic, it is written like this:
Code: [Select]
For i=o To (n_rx - 2)
 crc += rxbuf(i)
Next i
crc = crc And HFF
If crc = rxbuf(n_rx -1)Then

How would I translate this to arduinian?


You've no supplied the VB code to declare the variables used so I'm assuming you can do this.

Code: [Select]

crc = 0;
for (i = o; i < n_rx - 2; i++)
 crc += rxbuf[i];

crc = crc & 0xff;
if (crc == rxbuf[n_rx - 1])

sy kristina

Go Up