News:

;) This forum is the property of Proton software developers

Main Menu

Converting a small routine from C

Started by joesaliba, Apr 02, 2023, 08:39 AM

Previous topic - Next topic

joesaliba

Hi,
Is this the correct way I have done this conversion please: -

C++

crc += byte;
crc += crc >> 8; crc &= 0x00ff;

To PDS: -

crc = crc + sensor_val
crc = crc + crc >> 8
crc = crc & 0x00FF

JonW

I think that's correct.  Sometimes parenthesis makes it easier to read

crc = crc + byte
crc = crc + (crc >> 8)
crc = crc & $00FF

joesaliba

Thanks Jon for confirming. I will add the parenthesis as you suggested.

Regards

Joe