Using the straight forward implementation on wikipedia Fletcher's checksum we get the same checksum for data such as "BCA" and "CAB" as well as "BAC" and "ACB".
Is this expected?
Should not the Fletcher16 checksum account for the order of the blocks?
The deficiency can easily be fixed by OR'ing the index with the data as shown in the code below....
uint16_t fletcher16( uint8_t *data, int count )
{
uint16_t sum1 = 0;
uint16_t sum2 = 0;
int index;
for( index = 0; index < count; ++index )
{
//sum1 = (sum1 + data[index]) % 255; // Original
sum1 = (sum1 + index | data[index]) % 255; // The "fix"
sum2 = (sum2 + sum1) % 255;
}
return (sum2 << 8) | sum1;
}