Ok so now that I can calculate the checksum I'm trying to send it to the end of a string so I can write the data to an EEPROM. The only problem is that when I do it the checksum bytes are inverted for some reason.
Code:
int main(short argc, char **argv)
{
int i;
unsigned char serNum [9] = "DS0008D-";
unsigned char serNum1 [6] = "0111A";
unsigned char ckSum_data [13];
unsigned short checksum[3]={0x00,0x00,0x00};
for (i = 0; i < 5; i++)
{
ckSum_data [i + 8] = serNum1[i];
}
for (i = 0; i < 8; i++)
{
ckSum_data [i] = serNum[i];
}
//ckSum_data[] should hold the entire serial number (DS0008D-0111A)
checksum[0] = CalcChksum(ckSum_data, 13);
memcpy(&ckSum_data[14],&checksum[0],3);
cout << "\n" << checksum[0]; // Checksum output on console is FD 2B
}
So basically the last two bytes (15,16) should contain the checksum FD 2B.
15 >> FD
16 >> 2B
But the freaking thing is putting them reversed.