clodbuster/packet.h
1 /*
2  * Player - One Hell of a Robot Server
3  * Copyright (C) 2000
4  * Brian Gerkey, Kasper Stoy, Richard Vaughan, & Andrew Howard
5  *
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  *
21  */
22 
23 /*
24  * $Id$
25  * GRASP version of the P2OS packet class. this class has methods
26  * for building, printing, sending and receiving GRASP Board packets.
27  *
28  */
29 
30 #ifndef _PACKET_H
31 #define _PACKET_H
32 
33 #include <string.h>
34 
35 #define PACKET_LEN 12
36 
38 {
39  public:
40  unsigned char packet[PACKET_LEN];
41  unsigned int size;
42  unsigned int retsize;
43  void Print();
44  void PrintHex();
45  int Build(unsigned char command, unsigned char data);
46  int Build(unsigned char command);
47 
48  int Send( int fd );
49  int Receive( int fd,unsigned char command );
50 
51  bool operator!= ( GRASPPacket p ) {
52  if ( size != p.size) return(true);
53 
54  if ( memcmp( packet, p.packet, size ) != 0 ) return (true);
55 
56  return(false);
57  }
58 };
59 
60 #endif
void PrintHex()
PrintHex.
Definition: mbase/packet.cc:66
int Build(unsigned char *data, unsigned char datasize)
Build.
Definition: mbase/packet.cc:319
void Print()
Copyright (C) 2006 Videre Design Copyright (C) 2000 Brian Gerkey, Kasper Stoy, Richard Vaughan,...
Definition: erratic/packet.cc:39
void Print()
Copyright (C) 2010 Ana Teresa Hernández Malagón anat.hernandezm@gmail.com Movirobotics athernandez@...
Definition: mbase/packet.cc:49
int Send(int fd)
Send.
Definition: mbase/packet.cc:348
Definition: clodbuster/packet.h:37
bool Check()
Check.
Definition: mbase/packet.cc:83
uint16_t CalcChkSum()
CalcChkSum.
Definition: mbase/packet.cc:108
int Receive(int fd, uint16_t wait=30)
Receive.
Definition: mbase/packet.cc:130