Packet Data Types; Packet Checksum; Packet Errors - Pioneer 2 / PeopleBot Operation Manual

Pioneer 2 / peoplebot operations manual
Table of Contents

Advertisement

Pioneer 2 Operating System
server to client.
header, a one-byte count of the number of subsequent packet bytes, the client
command and its arguments or the server information data bytes, and, finally, a two-
byte checksum.

Packet Data Types

Client commands and server information packets contain several data types, as defined
in Table 3.
Table 3. P2OS Communication Packet Data Types
Data Type

Packet Checksum

Calculate the PSOS/P2OS client-server packet checksum by successively adding data
byte pairs (high byte first) to the running checksum (initially zero), disregarding sign and
overflow.
If there is an odd number of data bytes, the last byte is XORed to the low-
order byte of the checksum.
int calc_chksum(unsigned char *ptr)
{
int n;
int c = 0;
n = (ptr++);
n -= 2;
while (n > 1)
{
c += (*(ptr)<<8) | *(ptr+1);
c = c & 0xffff;
n -= 2;
ptr += 2;
}
if (n > 0)
c = c ^ (int)*(ptr++);
return(c);
}
NOTE: In P2OS, the checksum word is placed at the end of the packet, with its bytes in
the reverse order of that used for arguments and data; that is, b
is the low byte.

Packet Errors

Currently, P2OS ignores a client command packet whose Byte Count exceeds 200 or has
an erroneous checksum. The client should similarly ignore erroneous server information
packets.
P2OS does not acknowledge receipt of a command packet nor does it have any facility
to handle client acknowledgment of a server information packet. Consequently, Pioneer
client/server communications are as reliable as the physical communication link.
cable tether between the robot and client computer, such as a piggyback laptop,
30
Both are bit streams consisting of four main elements:
Bytes
integer
2
word
4
string
up to ~200,
length-prefixed
/* Step over byte count
/* don't include checksum word */
Order
b
low byte; b
high byte
0
1
b
low byte; b
high byte
0
3
b
length of string;
0
b
first byte of string
1
// ptr is array of bytes
// first is data count
0
a two-byte
*/
is the high byte and b
A
1

Advertisement

Table of Contents
loading

Table of Contents