SelfTest.h
Go to the documentation of this file.
00001 #ifndef ros_SERVICE_SelfTest_h
00002 #define ros_SERVICE_SelfTest_h
00003 #include <stdint.h>
00004 #include <string.h>
00005 #include <stdlib.h>
00006 #include "../ros/msg.h"
00007 #include "diagnostic_msgs/DiagnosticStatus.h"
00008 
00009 namespace diagnostic_msgs
00010 {
00011 
00012 static const char SELFTEST[] = "diagnostic_msgs/SelfTest";
00013 
00014   class SelfTestRequest : public ros::Msg
00015   {
00016     public:
00017 
00018     virtual int serialize(unsigned char *outbuffer)
00019     {
00020       int offset = 0;
00021       return offset;
00022     }
00023 
00024     virtual int deserialize(unsigned char *inbuffer)
00025     {
00026       int offset = 0;
00027      return offset;
00028     }
00029 
00030     const char * getType(){ return SELFTEST; };
00031 
00032   };
00033 
00034   class SelfTestResponse : public ros::Msg
00035   {
00036     public:
00037       char * id;
00038       unsigned char passed;
00039       unsigned char status_length;
00040       diagnostic_msgs::DiagnosticStatus st_status;
00041       diagnostic_msgs::DiagnosticStatus * status;
00042 
00043     virtual int serialize(unsigned char *outbuffer)
00044     {
00045       int offset = 0;
00046       long * length_id = (long *)(outbuffer + offset);
00047       *length_id = strlen( (const char*) this->id);
00048       offset += 4;
00049       memcpy(outbuffer + offset, this->id, *length_id);
00050       offset += *length_id;
00051       union {
00052         unsigned char real;
00053         unsigned char base;
00054       } u_passed;
00055       u_passed.real = this->passed;
00056       *(outbuffer + offset + 0) = (u_passed.base >> (8 * 0)) & 0xFF;
00057       offset += sizeof(this->passed);
00058       *(outbuffer + offset++) = status_length;
00059       *(outbuffer + offset++) = 0;
00060       *(outbuffer + offset++) = 0;
00061       *(outbuffer + offset++) = 0;
00062       for( unsigned char i = 0; i < status_length; i++){
00063       offset += this->status[i].serialize(outbuffer + offset);
00064       }
00065       return offset;
00066     }
00067 
00068     virtual int deserialize(unsigned char *inbuffer)
00069     {
00070       int offset = 0;
00071       uint32_t length_id = *(uint32_t *)(inbuffer + offset);
00072       offset += 4;
00073       for(unsigned int k= offset; k< offset+length_id; ++k){
00074           inbuffer[k-1]=inbuffer[k];
00075            }
00076       inbuffer[offset+length_id-1]=0;
00077       this->id = (char *)(inbuffer + offset-1);
00078       offset += length_id;
00079       union {
00080         unsigned char real;
00081         unsigned char base;
00082       } u_passed;
00083       u_passed.base = 0;
00084       u_passed.base |= ((typeof(u_passed.base)) (*(inbuffer + offset + 0))) << (8 * 0);
00085       this->passed = u_passed.real;
00086       offset += sizeof(this->passed);
00087       unsigned char status_lengthT = *(inbuffer + offset++);
00088       if(status_lengthT > status_length)
00089         this->status = (diagnostic_msgs::DiagnosticStatus*)realloc(this->status, status_lengthT * sizeof(diagnostic_msgs::DiagnosticStatus));
00090       offset += 3;
00091       status_length = status_lengthT;
00092       for( unsigned char i = 0; i < status_length; i++){
00093       offset += this->st_status.deserialize(inbuffer + offset);
00094         memcpy( &(this->status[i]), &(this->st_status), sizeof(diagnostic_msgs::DiagnosticStatus));
00095       }
00096      return offset;
00097     }
00098 
00099     const char * getType(){ return SELFTEST; };
00100 
00101   };
00102 
00103 }
00104 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


traxbot_robot
Author(s): André Gonçalves Araújo
autogenerated on Fri Feb 1 2013 13:21:12