packet.hpp
Go to the documentation of this file.
00001 /*
00002  *  P2OS for ROS
00003  *  Copyright (C) 2009  David Feil-Seifer, Brian Gerkey, Kasper Stoy,
00004  *      Richard Vaughan, & Andrew Howard
00005  *  Copyright (C) 2018  Hunter L. Allen
00006  *
00007  *  This program is free software; you can redistribute it and/or modify
00008  *  it under the terms of the GNU General Public License as published by
00009  *  the Free Software Foundation; either version 2 of the License, or
00010  *  (at your option) any later version.
00011  *
00012  *  This program is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *  GNU General Public License for more details.
00016  *
00017  *  You should have received a copy of the GNU General Public License
00018  *  along with this program; if not, write to the Free Software
00019  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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_


p2os_driver
Author(s): Hunter L. Allen , David Feil-Seifer , Aris Synodinos , Brian Gerkey, Kasper Stoy, Richard Vaughan, Andrew Howard, Tucker Hermans, ActivMedia Robotics LLC, MobileRobots Inc.
autogenerated on Wed Mar 27 2019 02:34:57