Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef P2OS_DRIVER__PACKET_HPP_
00023 #define P2OS_DRIVER__PACKET_HPP_
00024 #include <ros/ros.h>
00025
00026 #include <cstring>
00027
00028 namespace
00029 {
00030 constexpr size_t packet_len = 256;
00031 }
00032
00033 class P2OSPacket
00034 {
00035 public:
00036 unsigned char packet[packet_len];
00037 unsigned char size;
00038 ros::Time timestamp;
00039
00040 int CalcChkSum();
00041
00042 void Print();
00043 void PrintHex();
00044 int Build(unsigned char * data, unsigned char datasize);
00045 int Send(int fd);
00046 int Receive(int fd);
00047 bool Check();
00048
00049 bool operator!=(P2OSPacket p)
00050 {
00051 if (size != p.size) {return true;}
00052
00053 if (memcmp(packet, p.packet, size) != 0) {return true;}
00054
00055 return false;
00056 }
00057 };
00058
00059 #endif // P2OS_DRIVER__PACKET_HPP_