mbase/packet.h
1 
32 #ifndef _PACKET_H
33 #define _PACKET_H
34 
35 #include <string.h>
36 #include <libplayercore/playercore.h>
37 //#include <stdint.h>
38 
39 #define PACKET_LEN 256
40 
41 enum receive_result_e {
42  success = 0,
43  failure = 1,
44  timeout = 2
45 };
46 
47 
49 {
50  public:
51  unsigned char packet[PACKET_LEN];
52  unsigned char size;
53 
54  uint16_t CalcChkSum();
55 
56  void Print();
57  void PrintHex();
58  int Build( unsigned char *data, unsigned char datasize );
59  int Send( int fd );
60  int Receive( int fd, uint16_t wait = 30 );
61  bool Check();
62 
63  bool operator!= ( mbasedriverPacket p )
64  {
65  if ( size != p.size) return(true);
66 
67  if ( memcmp( packet, p.packet, size ) != 0 ) return (true);
68 
69  return(false);
70  }
71 };
72 
73 #endif
uint16_t CalcChkSum()
CalcChkSum.
Definition: mbase/packet.cc:108
bool Check()
Check.
Definition: mbase/packet.cc:83
int Build(unsigned char *data, unsigned char datasize)
Build.
Definition: mbase/packet.cc:319
int Receive(int fd, uint16_t wait=30)
Receive.
Definition: mbase/packet.cc:130
void Print()
Copyright (C) 2010 Ana Teresa Hernández Malagón Movirobotics Copyright (C) 2006 Videre Design Copyrig...
Definition: mbase/packet.cc:49
int Send(int fd)
Send.
Definition: mbase/packet.cc:348
Definition: mbase/packet.h:48
void PrintHex()
PrintHex.
Definition: mbase/packet.cc:66