SS-68BB USB USER MANUAL
DOC. NO: SS-68BB USB-14 (REV 04)
Page
16
of
16
The process has been automated and the code can be set and tested using the 'Buffer
Lock' tool.
Challenging the buffer
The command to challenge the buffer is: 'CODErrr..rrr<enter>' where 'CODE' is the
command, 'rrr..rrr' is the random challenge string up to 10 characters in length and
<enter> is the Carriage Return character 0x0D.
Buffer response
The buffer will respond with the following:
CODE: hhhh<enter>
Where 'CODE: ' is the response text and 'hhhh' is a 16 bit CRC for the submitted
challenge and the secret key.
Response validation
In the code below the variable CRC is a 16 bit unsigned integer and char is 8 bit. CmdBuf
is the input buffer where the string starting with 'CODE: ' is stored and CmdPtr indexes the
1st 'h'.
void CalcCrc(unsigned char ser_data)
{
crc = (unsigned char)(crc >> 8) | (crc << 8);
crc ^= ser_data;
crc ^= (unsigned char)(crc & 0xff) >> 4;
crc ^= (crc << 8) << 4;
crc ^= ((crc & 0xff) << 4) << 1;
crc &= 0xFFFF;
}
void mfCode(void)
{
char * p = &CmdBuf[CmdPtr];
int retCrc = HexToInt(p,4);
//convert the hex data to int
crc = 0xFFFF;
//initialise the crc
//======== do the calculation on the challenge =============
for (unsigned int i = 0; i < strlen(test); i++)
{
CalcCrc(test[i]);
}
//======== do the calculation on the UserKey =============
for (int i = 0; i < strlen(SecretKey); i++)
{
CalcCrc(SecretKry[i]);
}
//==== crc should be equal to retCrc if all is well ==========
}