00001 /* Copyright (C) 2002 Dominic Letourneau (dominic.letourneau@courrier.usherb.ca) 00002 00003 This library is free software; you can redistribute it and/or 00004 modify it under the terms of the GNU Lesser General Public 00005 License as published by the Free Software Foundation; either 00006 version 2.1 of the License, or (at your option) any later version. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Lesser General Public License for more details. 00012 00013 You should have received a copy of the GNU Lesser General Public 00014 License along with this library; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00016 */ 00017 #ifndef _PSOSPACKET_H_ 00018 #define _PSOSPACKET_H_ 00019 00020 #include <iostream> 00021 00022 namespace RobotFlow { 00023 00024 class PSOSPacket { 00025 00026 public: 00027 00028 PSOSPacket(); 00029 PSOSPacket(const PSOSPacket& cpy); 00030 PSOSPacket& operator = (const PSOSPacket &eq); 00031 00032 short calculate_checksum(); 00033 void create_packet(unsigned char *data, unsigned char size); 00034 void send_packet(int filedescriptor); 00035 void recv_packet(int filedescriptor); 00036 void print(std::ostream &out); 00037 unsigned char* get_data(){return &m_packet[0];} 00038 unsigned char operator[] (int pos); 00039 int get_size(){return (int) m_size;} 00040 00041 private: 00042 00043 bool read_check(); 00044 unsigned char m_packet[256]; 00045 unsigned char m_size; 00046 00047 }; 00048 00049 }//namespace RobotFlow 00050 #endif