Working towards recieving twists

Dependencies:   BufferedSerial

Fork of ros_lib_kinetic by Gary Servin

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Log.h Source File

Log.h

00001 #ifndef _ROS_rosgraph_msgs_Log_h
00002 #define _ROS_rosgraph_msgs_Log_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 #include "std_msgs/Header.h"
00009 
00010 namespace rosgraph_msgs
00011 {
00012 
00013   class Log : public ros::Msg
00014   {
00015     public:
00016       typedef std_msgs::Header _header_type;
00017       _header_type header;
00018       typedef int8_t _level_type;
00019       _level_type level;
00020       typedef const char* _name_type;
00021       _name_type name;
00022       typedef const char* _msg_type;
00023       _msg_type msg;
00024       typedef const char* _file_type;
00025       _file_type file;
00026       typedef const char* _function_type;
00027       _function_type function;
00028       typedef uint32_t _line_type;
00029       _line_type line;
00030       uint32_t topics_length;
00031       typedef char* _topics_type;
00032       _topics_type st_topics;
00033       _topics_type * topics;
00034       enum { DEBUG = 1  };
00035       enum { INFO = 2   };
00036       enum { WARN = 4   };
00037       enum { ERROR = 8  };
00038       enum { FATAL = 16  };
00039 
00040     Log():
00041       header(),
00042       level(0),
00043       name(""),
00044       msg(""),
00045       file(""),
00046       function(""),
00047       line(0),
00048       topics_length(0), topics(NULL)
00049     {
00050     }
00051 
00052     virtual int serialize(unsigned char *outbuffer) const
00053     {
00054       int offset = 0;
00055       offset += this->header.serialize(outbuffer + offset);
00056       union {
00057         int8_t real;
00058         uint8_t base;
00059       } u_level;
00060       u_level.real = this->level;
00061       *(outbuffer + offset + 0) = (u_level.base >> (8 * 0)) & 0xFF;
00062       offset += sizeof(this->level);
00063       uint32_t length_name = strlen(this->name);
00064       varToArr(outbuffer + offset, length_name);
00065       offset += 4;
00066       memcpy(outbuffer + offset, this->name, length_name);
00067       offset += length_name;
00068       uint32_t length_msg = strlen(this->msg);
00069       varToArr(outbuffer + offset, length_msg);
00070       offset += 4;
00071       memcpy(outbuffer + offset, this->msg, length_msg);
00072       offset += length_msg;
00073       uint32_t length_file = strlen(this->file);
00074       varToArr(outbuffer + offset, length_file);
00075       offset += 4;
00076       memcpy(outbuffer + offset, this->file, length_file);
00077       offset += length_file;
00078       uint32_t length_function = strlen(this->function);
00079       varToArr(outbuffer + offset, length_function);
00080       offset += 4;
00081       memcpy(outbuffer + offset, this->function, length_function);
00082       offset += length_function;
00083       *(outbuffer + offset + 0) = (this->line >> (8 * 0)) & 0xFF;
00084       *(outbuffer + offset + 1) = (this->line >> (8 * 1)) & 0xFF;
00085       *(outbuffer + offset + 2) = (this->line >> (8 * 2)) & 0xFF;
00086       *(outbuffer + offset + 3) = (this->line >> (8 * 3)) & 0xFF;
00087       offset += sizeof(this->line);
00088       *(outbuffer + offset + 0) = (this->topics_length >> (8 * 0)) & 0xFF;
00089       *(outbuffer + offset + 1) = (this->topics_length >> (8 * 1)) & 0xFF;
00090       *(outbuffer + offset + 2) = (this->topics_length >> (8 * 2)) & 0xFF;
00091       *(outbuffer + offset + 3) = (this->topics_length >> (8 * 3)) & 0xFF;
00092       offset += sizeof(this->topics_length);
00093       for( uint32_t i = 0; i < topics_length; i++){
00094       uint32_t length_topicsi = strlen(this->topics[i]);
00095       varToArr(outbuffer + offset, length_topicsi);
00096       offset += 4;
00097       memcpy(outbuffer + offset, this->topics[i], length_topicsi);
00098       offset += length_topicsi;
00099       }
00100       return offset;
00101     }
00102 
00103     virtual int deserialize(unsigned char *inbuffer)
00104     {
00105       int offset = 0;
00106       offset += this->header.deserialize(inbuffer + offset);
00107       union {
00108         int8_t real;
00109         uint8_t base;
00110       } u_level;
00111       u_level.base = 0;
00112       u_level.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
00113       this->level = u_level.real;
00114       offset += sizeof(this->level);
00115       uint32_t length_name;
00116       arrToVar(length_name, (inbuffer + offset));
00117       offset += 4;
00118       for(unsigned int k= offset; k< offset+length_name; ++k){
00119           inbuffer[k-1]=inbuffer[k];
00120       }
00121       inbuffer[offset+length_name-1]=0;
00122       this->name = (char *)(inbuffer + offset-1);
00123       offset += length_name;
00124       uint32_t length_msg;
00125       arrToVar(length_msg, (inbuffer + offset));
00126       offset += 4;
00127       for(unsigned int k= offset; k< offset+length_msg; ++k){
00128           inbuffer[k-1]=inbuffer[k];
00129       }
00130       inbuffer[offset+length_msg-1]=0;
00131       this->msg = (char *)(inbuffer + offset-1);
00132       offset += length_msg;
00133       uint32_t length_file;
00134       arrToVar(length_file, (inbuffer + offset));
00135       offset += 4;
00136       for(unsigned int k= offset; k< offset+length_file; ++k){
00137           inbuffer[k-1]=inbuffer[k];
00138       }
00139       inbuffer[offset+length_file-1]=0;
00140       this->file = (char *)(inbuffer + offset-1);
00141       offset += length_file;
00142       uint32_t length_function;
00143       arrToVar(length_function, (inbuffer + offset));
00144       offset += 4;
00145       for(unsigned int k= offset; k< offset+length_function; ++k){
00146           inbuffer[k-1]=inbuffer[k];
00147       }
00148       inbuffer[offset+length_function-1]=0;
00149       this->function = (char *)(inbuffer + offset-1);
00150       offset += length_function;
00151       this->line =  ((uint32_t) (*(inbuffer + offset)));
00152       this->line |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00153       this->line |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00154       this->line |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00155       offset += sizeof(this->line);
00156       uint32_t topics_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00157       topics_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00158       topics_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00159       topics_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00160       offset += sizeof(this->topics_length);
00161       if(topics_lengthT > topics_length)
00162         this->topics = (char**)realloc(this->topics, topics_lengthT * sizeof(char*));
00163       topics_length = topics_lengthT;
00164       for( uint32_t i = 0; i < topics_length; i++){
00165       uint32_t length_st_topics;
00166       arrToVar(length_st_topics, (inbuffer + offset));
00167       offset += 4;
00168       for(unsigned int k= offset; k< offset+length_st_topics; ++k){
00169           inbuffer[k-1]=inbuffer[k];
00170       }
00171       inbuffer[offset+length_st_topics-1]=0;
00172       this->st_topics = (char *)(inbuffer + offset-1);
00173       offset += length_st_topics;
00174         memcpy( &(this->topics[i]), &(this->st_topics), sizeof(char*));
00175       }
00176      return offset;
00177     }
00178 
00179     const char * getType(){ return "rosgraph_msgs/Log"; };
00180     const char * getMD5(){ return "acffd30cd6b6de30f120938c17c593fb"; };
00181 
00182   };
00183 
00184 }
00185 #endif