RS-232 CommunicationΒΆ
Note
The RS-232 interface requires a common ground connection between the USBoard-USS4 and the computer.
The RS-232-interface runs at 19200 Baud. Communication via RS-232 uses the same format as the CAN Communication except for the following addition:
Every message from the USBoard-USS4 begins with a start byte which must have the value 0xFF
.
After each message, made up of eight data bytes, a 16 bit checksum is sent.
Because of this a complete message is 11 bytes long.
Byte 1 | Bytes 2-9 | Byte 10 | Byte 11 |
---|---|---|---|
0xFF |
data bytes | checksum high byte | checksum low byte |
The checksum is calculated with an CRC-CCITT algorithm using 8 databytes.
Messages to the USBoard-USS4 only contain the data bytes.
Example implementation of the checksum calulation (C code):
unsigned int getCheckSum(unsigned char *c, size_t iNumBytes){
unsigned int uCrc16;
unsigned char ucData[2];
size_t i;
uCrc16 = 0;
ucData[0] = 0;
for(i=0; i<iNumBytes; i++){
ucData[1] = ucData[0];
ucData[0] = c[i];
if(uCrc16 & 0x8000){
uCrc16 = (uCrc16 & 0x7fff) << 1;
uCrc16^= 0x1021;
}else{
uCrc16 <<= 1;
}
uCrc16^= (unsigned int)(ucData[0]) | ((unsigned int)(ucData[1]) << 8);
}
return uCrc16;
}