rosserial library for mbed Inspired by nucho's rosserial library This library is still under development

Dependencies:   MODSERIAL mbed

Dependents:   mbed_roshydro_test

Library still under development!

Committer:
akashvibhute
Date:
Sun Feb 15 10:53:43 2015 +0000
Revision:
0:30537dec6e0b
First commit; Library still need to be debugged, compilation issues with new mbed and modserial updates.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
akashvibhute 0:30537dec6e0b 1 #ifndef _ROS_rosgraph_msgs_Log_h
akashvibhute 0:30537dec6e0b 2 #define _ROS_rosgraph_msgs_Log_h
akashvibhute 0:30537dec6e0b 3
akashvibhute 0:30537dec6e0b 4 #include <stdint.h>
akashvibhute 0:30537dec6e0b 5 #include <string.h>
akashvibhute 0:30537dec6e0b 6 #include <stdlib.h>
akashvibhute 0:30537dec6e0b 7 #include "ros/msg.h"
akashvibhute 0:30537dec6e0b 8 #include "std_msgs/Header.h"
akashvibhute 0:30537dec6e0b 9
akashvibhute 0:30537dec6e0b 10 namespace rosgraph_msgs
akashvibhute 0:30537dec6e0b 11 {
akashvibhute 0:30537dec6e0b 12
akashvibhute 0:30537dec6e0b 13 class Log : public ros::Msg
akashvibhute 0:30537dec6e0b 14 {
akashvibhute 0:30537dec6e0b 15 public:
akashvibhute 0:30537dec6e0b 16 std_msgs::Header header;
akashvibhute 0:30537dec6e0b 17 int8_t level;
akashvibhute 0:30537dec6e0b 18 const char* name;
akashvibhute 0:30537dec6e0b 19 const char* msg;
akashvibhute 0:30537dec6e0b 20 const char* file;
akashvibhute 0:30537dec6e0b 21 const char* function;
akashvibhute 0:30537dec6e0b 22 uint32_t line;
akashvibhute 0:30537dec6e0b 23 uint8_t topics_length;
akashvibhute 0:30537dec6e0b 24 char* st_topics;
akashvibhute 0:30537dec6e0b 25 char* * topics;
akashvibhute 0:30537dec6e0b 26 enum { DEBUG = 1 };
akashvibhute 0:30537dec6e0b 27 enum { INFO = 2 };
akashvibhute 0:30537dec6e0b 28 enum { WARN = 4 };
akashvibhute 0:30537dec6e0b 29 enum { ERROR = 8 };
akashvibhute 0:30537dec6e0b 30 enum { FATAL = 16 };
akashvibhute 0:30537dec6e0b 31
akashvibhute 0:30537dec6e0b 32 Log():
akashvibhute 0:30537dec6e0b 33 header(),
akashvibhute 0:30537dec6e0b 34 level(0),
akashvibhute 0:30537dec6e0b 35 name(""),
akashvibhute 0:30537dec6e0b 36 msg(""),
akashvibhute 0:30537dec6e0b 37 file(""),
akashvibhute 0:30537dec6e0b 38 function(""),
akashvibhute 0:30537dec6e0b 39 line(0),
akashvibhute 0:30537dec6e0b 40 topics_length(0), topics(NULL)
akashvibhute 0:30537dec6e0b 41 {
akashvibhute 0:30537dec6e0b 42 }
akashvibhute 0:30537dec6e0b 43
akashvibhute 0:30537dec6e0b 44 virtual int serialize(unsigned char *outbuffer) const
akashvibhute 0:30537dec6e0b 45 {
akashvibhute 0:30537dec6e0b 46 int offset = 0;
akashvibhute 0:30537dec6e0b 47 offset += this->header.serialize(outbuffer + offset);
akashvibhute 0:30537dec6e0b 48 union {
akashvibhute 0:30537dec6e0b 49 int8_t real;
akashvibhute 0:30537dec6e0b 50 uint8_t base;
akashvibhute 0:30537dec6e0b 51 } u_level;
akashvibhute 0:30537dec6e0b 52 u_level.real = this->level;
akashvibhute 0:30537dec6e0b 53 *(outbuffer + offset + 0) = (u_level.base >> (8 * 0)) & 0xFF;
akashvibhute 0:30537dec6e0b 54 offset += sizeof(this->level);
akashvibhute 0:30537dec6e0b 55 uint32_t length_name = strlen(this->name);
akashvibhute 0:30537dec6e0b 56 memcpy(outbuffer + offset, &length_name, sizeof(uint32_t));
akashvibhute 0:30537dec6e0b 57 offset += 4;
akashvibhute 0:30537dec6e0b 58 memcpy(outbuffer + offset, this->name, length_name);
akashvibhute 0:30537dec6e0b 59 offset += length_name;
akashvibhute 0:30537dec6e0b 60 uint32_t length_msg = strlen(this->msg);
akashvibhute 0:30537dec6e0b 61 memcpy(outbuffer + offset, &length_msg, sizeof(uint32_t));
akashvibhute 0:30537dec6e0b 62 offset += 4;
akashvibhute 0:30537dec6e0b 63 memcpy(outbuffer + offset, this->msg, length_msg);
akashvibhute 0:30537dec6e0b 64 offset += length_msg;
akashvibhute 0:30537dec6e0b 65 uint32_t length_file = strlen(this->file);
akashvibhute 0:30537dec6e0b 66 memcpy(outbuffer + offset, &length_file, sizeof(uint32_t));
akashvibhute 0:30537dec6e0b 67 offset += 4;
akashvibhute 0:30537dec6e0b 68 memcpy(outbuffer + offset, this->file, length_file);
akashvibhute 0:30537dec6e0b 69 offset += length_file;
akashvibhute 0:30537dec6e0b 70 uint32_t length_function = strlen(this->function);
akashvibhute 0:30537dec6e0b 71 memcpy(outbuffer + offset, &length_function, sizeof(uint32_t));
akashvibhute 0:30537dec6e0b 72 offset += 4;
akashvibhute 0:30537dec6e0b 73 memcpy(outbuffer + offset, this->function, length_function);
akashvibhute 0:30537dec6e0b 74 offset += length_function;
akashvibhute 0:30537dec6e0b 75 *(outbuffer + offset + 0) = (this->line >> (8 * 0)) & 0xFF;
akashvibhute 0:30537dec6e0b 76 *(outbuffer + offset + 1) = (this->line >> (8 * 1)) & 0xFF;
akashvibhute 0:30537dec6e0b 77 *(outbuffer + offset + 2) = (this->line >> (8 * 2)) & 0xFF;
akashvibhute 0:30537dec6e0b 78 *(outbuffer + offset + 3) = (this->line >> (8 * 3)) & 0xFF;
akashvibhute 0:30537dec6e0b 79 offset += sizeof(this->line);
akashvibhute 0:30537dec6e0b 80 *(outbuffer + offset++) = topics_length;
akashvibhute 0:30537dec6e0b 81 *(outbuffer + offset++) = 0;
akashvibhute 0:30537dec6e0b 82 *(outbuffer + offset++) = 0;
akashvibhute 0:30537dec6e0b 83 *(outbuffer + offset++) = 0;
akashvibhute 0:30537dec6e0b 84 for( uint8_t i = 0; i < topics_length; i++){
akashvibhute 0:30537dec6e0b 85 uint32_t length_topicsi = strlen(this->topics[i]);
akashvibhute 0:30537dec6e0b 86 memcpy(outbuffer + offset, &length_topicsi, sizeof(uint32_t));
akashvibhute 0:30537dec6e0b 87 offset += 4;
akashvibhute 0:30537dec6e0b 88 memcpy(outbuffer + offset, this->topics[i], length_topicsi);
akashvibhute 0:30537dec6e0b 89 offset += length_topicsi;
akashvibhute 0:30537dec6e0b 90 }
akashvibhute 0:30537dec6e0b 91 return offset;
akashvibhute 0:30537dec6e0b 92 }
akashvibhute 0:30537dec6e0b 93
akashvibhute 0:30537dec6e0b 94 virtual int deserialize(unsigned char *inbuffer)
akashvibhute 0:30537dec6e0b 95 {
akashvibhute 0:30537dec6e0b 96 int offset = 0;
akashvibhute 0:30537dec6e0b 97 offset += this->header.deserialize(inbuffer + offset);
akashvibhute 0:30537dec6e0b 98 union {
akashvibhute 0:30537dec6e0b 99 int8_t real;
akashvibhute 0:30537dec6e0b 100 uint8_t base;
akashvibhute 0:30537dec6e0b 101 } u_level;
akashvibhute 0:30537dec6e0b 102 u_level.base = 0;
akashvibhute 0:30537dec6e0b 103 u_level.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
akashvibhute 0:30537dec6e0b 104 this->level = u_level.real;
akashvibhute 0:30537dec6e0b 105 offset += sizeof(this->level);
akashvibhute 0:30537dec6e0b 106 uint32_t length_name;
akashvibhute 0:30537dec6e0b 107 memcpy(&length_name, (inbuffer + offset), sizeof(uint32_t));
akashvibhute 0:30537dec6e0b 108 offset += 4;
akashvibhute 0:30537dec6e0b 109 for(unsigned int k= offset; k< offset+length_name; ++k){
akashvibhute 0:30537dec6e0b 110 inbuffer[k-1]=inbuffer[k];
akashvibhute 0:30537dec6e0b 111 }
akashvibhute 0:30537dec6e0b 112 inbuffer[offset+length_name-1]=0;
akashvibhute 0:30537dec6e0b 113 this->name = (char *)(inbuffer + offset-1);
akashvibhute 0:30537dec6e0b 114 offset += length_name;
akashvibhute 0:30537dec6e0b 115 uint32_t length_msg;
akashvibhute 0:30537dec6e0b 116 memcpy(&length_msg, (inbuffer + offset), sizeof(uint32_t));
akashvibhute 0:30537dec6e0b 117 offset += 4;
akashvibhute 0:30537dec6e0b 118 for(unsigned int k= offset; k< offset+length_msg; ++k){
akashvibhute 0:30537dec6e0b 119 inbuffer[k-1]=inbuffer[k];
akashvibhute 0:30537dec6e0b 120 }
akashvibhute 0:30537dec6e0b 121 inbuffer[offset+length_msg-1]=0;
akashvibhute 0:30537dec6e0b 122 this->msg = (char *)(inbuffer + offset-1);
akashvibhute 0:30537dec6e0b 123 offset += length_msg;
akashvibhute 0:30537dec6e0b 124 uint32_t length_file;
akashvibhute 0:30537dec6e0b 125 memcpy(&length_file, (inbuffer + offset), sizeof(uint32_t));
akashvibhute 0:30537dec6e0b 126 offset += 4;
akashvibhute 0:30537dec6e0b 127 for(unsigned int k= offset; k< offset+length_file; ++k){
akashvibhute 0:30537dec6e0b 128 inbuffer[k-1]=inbuffer[k];
akashvibhute 0:30537dec6e0b 129 }
akashvibhute 0:30537dec6e0b 130 inbuffer[offset+length_file-1]=0;
akashvibhute 0:30537dec6e0b 131 this->file = (char *)(inbuffer + offset-1);
akashvibhute 0:30537dec6e0b 132 offset += length_file;
akashvibhute 0:30537dec6e0b 133 uint32_t length_function;
akashvibhute 0:30537dec6e0b 134 memcpy(&length_function, (inbuffer + offset), sizeof(uint32_t));
akashvibhute 0:30537dec6e0b 135 offset += 4;
akashvibhute 0:30537dec6e0b 136 for(unsigned int k= offset; k< offset+length_function; ++k){
akashvibhute 0:30537dec6e0b 137 inbuffer[k-1]=inbuffer[k];
akashvibhute 0:30537dec6e0b 138 }
akashvibhute 0:30537dec6e0b 139 inbuffer[offset+length_function-1]=0;
akashvibhute 0:30537dec6e0b 140 this->function = (char *)(inbuffer + offset-1);
akashvibhute 0:30537dec6e0b 141 offset += length_function;
akashvibhute 0:30537dec6e0b 142 this->line = ((uint32_t) (*(inbuffer + offset)));
akashvibhute 0:30537dec6e0b 143 this->line |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
akashvibhute 0:30537dec6e0b 144 this->line |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
akashvibhute 0:30537dec6e0b 145 this->line |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
akashvibhute 0:30537dec6e0b 146 offset += sizeof(this->line);
akashvibhute 0:30537dec6e0b 147 uint8_t topics_lengthT = *(inbuffer + offset++);
akashvibhute 0:30537dec6e0b 148 if(topics_lengthT > topics_length)
akashvibhute 0:30537dec6e0b 149 this->topics = (char**)realloc(this->topics, topics_lengthT * sizeof(char*));
akashvibhute 0:30537dec6e0b 150 offset += 3;
akashvibhute 0:30537dec6e0b 151 topics_length = topics_lengthT;
akashvibhute 0:30537dec6e0b 152 for( uint8_t i = 0; i < topics_length; i++){
akashvibhute 0:30537dec6e0b 153 uint32_t length_st_topics;
akashvibhute 0:30537dec6e0b 154 memcpy(&length_st_topics, (inbuffer + offset), sizeof(uint32_t));
akashvibhute 0:30537dec6e0b 155 offset += 4;
akashvibhute 0:30537dec6e0b 156 for(unsigned int k= offset; k< offset+length_st_topics; ++k){
akashvibhute 0:30537dec6e0b 157 inbuffer[k-1]=inbuffer[k];
akashvibhute 0:30537dec6e0b 158 }
akashvibhute 0:30537dec6e0b 159 inbuffer[offset+length_st_topics-1]=0;
akashvibhute 0:30537dec6e0b 160 this->st_topics = (char *)(inbuffer + offset-1);
akashvibhute 0:30537dec6e0b 161 offset += length_st_topics;
akashvibhute 0:30537dec6e0b 162 memcpy( &(this->topics[i]), &(this->st_topics), sizeof(char*));
akashvibhute 0:30537dec6e0b 163 }
akashvibhute 0:30537dec6e0b 164 return offset;
akashvibhute 0:30537dec6e0b 165 }
akashvibhute 0:30537dec6e0b 166
akashvibhute 0:30537dec6e0b 167 const char * getType(){ return "rosgraph_msgs/Log"; };
akashvibhute 0:30537dec6e0b 168 const char * getMD5(){ return "acffd30cd6b6de30f120938c17c593fb"; };
akashvibhute 0:30537dec6e0b 169
akashvibhute 0:30537dec6e0b 170 };
akashvibhute 0:30537dec6e0b 171
akashvibhute 0:30537dec6e0b 172 }
akashvibhute 0:30537dec6e0b 173 #endif