packet.h
00001 00025 #ifndef _PACKET_H 00026 #define _PACKET_H 00027 00028 #include <string.h> 00029 #include <libplayercore/playercore.h> 00030 //#include <stdint.h> 00031 00032 #define PACKET_LEN 256 00033 00034 enum receive_result_e { 00035 success = 0, 00036 failure = 1, 00037 timeout = 2 00038 }; 00039 00040 00041 class ErraticPacket 00042 { 00043 public: 00044 unsigned char packet[PACKET_LEN]; 00045 unsigned char size; 00046 00047 uint16_t CalcChkSum(); 00048 00049 void Print(); 00050 void PrintHex(); 00051 int Build( unsigned char *data, unsigned char datasize ); 00052 int Send( int fd ); 00053 int Receive( int fd, uint16_t wait = 30 ); 00054 bool Check(); 00055 00056 bool operator!= ( ErraticPacket p ) { 00057 if ( size != p.size) return(true); 00058 00059 if ( memcmp( packet, p.packet, size ) != 0 ) return (true); 00060 00061 return(false); 00062 } 00063 }; 00064 00065 #endif