ActivMedia Robotics Operating System
always first. Some data are strings of up to a maximum 200 bytes, prefaced by a length byte. Unlike common data integers, the
Packet Checksum
Calculate the PSOS/P2OS/AROS
int calc_chksum(unsigned char *ptr)
{
//ptr is array of bytes
//first is data count
int n; int c = 0;
n = *(ptr++); | /* Step over byte count | */ |
n | /* don't include checksum word */ | |
while (n > 1) |
|
|
{ |
|
|
c += (*(ptr)<<8) *(ptr+1); c = c & 0xffff;
n
}
if (n > 0)
c = c ^ (int)*(ptr++); return(c);
}
NOTE: The checksum integer is placed at the end of the packet, with its bytes in the reverse order of that used for data integers; that is, b0 is the high byte and b1 is the low byte.
Packet Errors
AROS ignores a client command packet whose byte count exceeds 204 (total packet size of 206 bytes) or has an erroneous checksum. The client should similarly ignore erroneous SIPs.
AROS does not acknowledge receipt of a command packet nor does it have any facility to handle client acknowledgment of a SIP. Accordingly, when designing client applications, keep in mind serial communication limitations, particularly data rates and physical linkage. Communication between an onboard PC client connected with the server via a signal cable is much more reliable than over radios, for example. And don’t expect to send a client command every millisecond if the HOST serial port’s baud rate is set to 9,600 kbps.
Because of the
Nonetheless, the
32