This program is porting rosserial_arduino for mbed http://www.ros.org/wiki/rosserial_arduino This program supported the revision of 169 of rosserial. This program contains an example.

Dependencies:   rosserial_mbed_lib mbed Servo

Committer:
nucho
Date:
Sat Nov 12 23:53:04 2011 +0000
Revision:
3:dff241b66f84
This program supported the revision of 167 of rosserial.

Who changed what in which revision?

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