Command Set¶
Command IDs¶
The following table shows the available commands of the USBoard-USS5.
Command | Value | Description |
---|---|---|
CMD_CONNECT |
0 | Check connection |
CMD_SET_CHANNEL_ACTIVE |
1 | Activate channel for sending / receiving |
CMD_GET_DATA_1TO8 |
2 | Request data of sensors 1 to 8 |
CMD_GET_DATA_9TO16 |
3 | Request data of sensors 9 to 16 |
CMD_WRITE_PARASET |
4 | Upload parameter set to board (volatile) |
CMD_WRITE_PARASET_TO_EEPROM |
5 | Write parameter set to board’s EEPROM (non-volatile) |
CMD_READ_PARASET |
6 | Read current parameter set |
CMD_GET_ANALOGIN |
7 | Read values of analogue inputs |
– | 8-12 | Reserved |
CMD_GET_DATA |
13 | Request data of all sensors |
CAN Communication¶
The default base address is 0x400
.
This base address can be changed in the parameter set.
The addresses used by the USBoard-USS5 are calculated from the base address by adding the following offsets.
Offset to base address | Function |
---|---|
+0 |
Receive commands |
+1 |
Answer to CMD_CONNECT |
+2 |
First answer to CMD_GET_DATA_1TO8 |
+3 |
Second answer to CMD_GET_DATA_1TO8 |
+4 |
First answer to CMD_GET_DATA_9TO16 |
+5 |
2nd answer to CMD_GET_DATA_9TO16 |
+6 |
Answer to CMD_READ_PARASET |
+7 |
Answer to CMD_GET_ANALOGIN |
+8 |
Answer to CMD_WRITE_PARASET |
+9 |
Answer to CMD_WRITE_PARASET_TO_EEPROM |
+13 |
1st Answer to CMD_GET_DATA (group 0: 1 to 4) |
+14 |
2nd Answer to CMD_GET_DATA (group 1: 5 to 8) |
+15 |
3rd Answer to CMD_GET_DATA (group 2: 9 to 12) |
+16 |
4th Answer to CMD_GET_DATA (group 3: 13 to 16) |
USB / Serial Interface¶
Communication via USB is done via a USB-serial-converter on the USBoard-USS5. The computer’s operating system can access it like a traditional serial interface. On request the USB converter can be replaced by an RS-232 transmitter. This does not affect the communication protocol of the serial interface.
Note
The RS-232 interface requires a common ground connection between the USBoard-USS5 and the computer.
The serial interface runs at 19200 Baud. Its protocol has the same format as the CAN communication except for the following addition:
Every message from the USBoard-USS5 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-USS5 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;
}