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_SERVICE_ListControllers_h
akashvibhute 0:30537dec6e0b 2 #define _ROS_SERVICE_ListControllers_h
akashvibhute 0:30537dec6e0b 3 #include <stdint.h>
akashvibhute 0:30537dec6e0b 4 #include <string.h>
akashvibhute 0:30537dec6e0b 5 #include <stdlib.h>
akashvibhute 0:30537dec6e0b 6 #include "ros/msg.h"
akashvibhute 0:30537dec6e0b 7
akashvibhute 0:30537dec6e0b 8 namespace pr2_mechanism_msgs
akashvibhute 0:30537dec6e0b 9 {
akashvibhute 0:30537dec6e0b 10
akashvibhute 0:30537dec6e0b 11 static const char LISTCONTROLLERS[] = "pr2_mechanism_msgs/ListControllers";
akashvibhute 0:30537dec6e0b 12
akashvibhute 0:30537dec6e0b 13 class ListControllersRequest : public ros::Msg
akashvibhute 0:30537dec6e0b 14 {
akashvibhute 0:30537dec6e0b 15 public:
akashvibhute 0:30537dec6e0b 16
akashvibhute 0:30537dec6e0b 17 ListControllersRequest()
akashvibhute 0:30537dec6e0b 18 {
akashvibhute 0:30537dec6e0b 19 }
akashvibhute 0:30537dec6e0b 20
akashvibhute 0:30537dec6e0b 21 virtual int serialize(unsigned char *outbuffer) const
akashvibhute 0:30537dec6e0b 22 {
akashvibhute 0:30537dec6e0b 23 int offset = 0;
akashvibhute 0:30537dec6e0b 24 return offset;
akashvibhute 0:30537dec6e0b 25 }
akashvibhute 0:30537dec6e0b 26
akashvibhute 0:30537dec6e0b 27 virtual int deserialize(unsigned char *inbuffer)
akashvibhute 0:30537dec6e0b 28 {
akashvibhute 0:30537dec6e0b 29 int offset = 0;
akashvibhute 0:30537dec6e0b 30 return offset;
akashvibhute 0:30537dec6e0b 31 }
akashvibhute 0:30537dec6e0b 32
akashvibhute 0:30537dec6e0b 33 const char * getType(){ return LISTCONTROLLERS; };
akashvibhute 0:30537dec6e0b 34 const char * getMD5(){ return "d41d8cd98f00b204e9800998ecf8427e"; };
akashvibhute 0:30537dec6e0b 35
akashvibhute 0:30537dec6e0b 36 };
akashvibhute 0:30537dec6e0b 37
akashvibhute 0:30537dec6e0b 38 class ListControllersResponse : public ros::Msg
akashvibhute 0:30537dec6e0b 39 {
akashvibhute 0:30537dec6e0b 40 public:
akashvibhute 0:30537dec6e0b 41 uint8_t controllers_length;
akashvibhute 0:30537dec6e0b 42 char* st_controllers;
akashvibhute 0:30537dec6e0b 43 char* * controllers;
akashvibhute 0:30537dec6e0b 44 uint8_t state_length;
akashvibhute 0:30537dec6e0b 45 char* st_state;
akashvibhute 0:30537dec6e0b 46 char* * state;
akashvibhute 0:30537dec6e0b 47
akashvibhute 0:30537dec6e0b 48 ListControllersResponse():
akashvibhute 0:30537dec6e0b 49 controllers_length(0), controllers(NULL),
akashvibhute 0:30537dec6e0b 50 state_length(0), state(NULL)
akashvibhute 0:30537dec6e0b 51 {
akashvibhute 0:30537dec6e0b 52 }
akashvibhute 0:30537dec6e0b 53
akashvibhute 0:30537dec6e0b 54 virtual int serialize(unsigned char *outbuffer) const
akashvibhute 0:30537dec6e0b 55 {
akashvibhute 0:30537dec6e0b 56 int offset = 0;
akashvibhute 0:30537dec6e0b 57 *(outbuffer + offset++) = controllers_length;
akashvibhute 0:30537dec6e0b 58 *(outbuffer + offset++) = 0;
akashvibhute 0:30537dec6e0b 59 *(outbuffer + offset++) = 0;
akashvibhute 0:30537dec6e0b 60 *(outbuffer + offset++) = 0;
akashvibhute 0:30537dec6e0b 61 for( uint8_t i = 0; i < controllers_length; i++){
akashvibhute 0:30537dec6e0b 62 uint32_t length_controllersi = strlen(this->controllers[i]);
akashvibhute 0:30537dec6e0b 63 memcpy(outbuffer + offset, &length_controllersi, sizeof(uint32_t));
akashvibhute 0:30537dec6e0b 64 offset += 4;
akashvibhute 0:30537dec6e0b 65 memcpy(outbuffer + offset, this->controllers[i], length_controllersi);
akashvibhute 0:30537dec6e0b 66 offset += length_controllersi;
akashvibhute 0:30537dec6e0b 67 }
akashvibhute 0:30537dec6e0b 68 *(outbuffer + offset++) = state_length;
akashvibhute 0:30537dec6e0b 69 *(outbuffer + offset++) = 0;
akashvibhute 0:30537dec6e0b 70 *(outbuffer + offset++) = 0;
akashvibhute 0:30537dec6e0b 71 *(outbuffer + offset++) = 0;
akashvibhute 0:30537dec6e0b 72 for( uint8_t i = 0; i < state_length; i++){
akashvibhute 0:30537dec6e0b 73 uint32_t length_statei = strlen(this->state[i]);
akashvibhute 0:30537dec6e0b 74 memcpy(outbuffer + offset, &length_statei, sizeof(uint32_t));
akashvibhute 0:30537dec6e0b 75 offset += 4;
akashvibhute 0:30537dec6e0b 76 memcpy(outbuffer + offset, this->state[i], length_statei);
akashvibhute 0:30537dec6e0b 77 offset += length_statei;
akashvibhute 0:30537dec6e0b 78 }
akashvibhute 0:30537dec6e0b 79 return offset;
akashvibhute 0:30537dec6e0b 80 }
akashvibhute 0:30537dec6e0b 81
akashvibhute 0:30537dec6e0b 82 virtual int deserialize(unsigned char *inbuffer)
akashvibhute 0:30537dec6e0b 83 {
akashvibhute 0:30537dec6e0b 84 int offset = 0;
akashvibhute 0:30537dec6e0b 85 uint8_t controllers_lengthT = *(inbuffer + offset++);
akashvibhute 0:30537dec6e0b 86 if(controllers_lengthT > controllers_length)
akashvibhute 0:30537dec6e0b 87 this->controllers = (char**)realloc(this->controllers, controllers_lengthT * sizeof(char*));
akashvibhute 0:30537dec6e0b 88 offset += 3;
akashvibhute 0:30537dec6e0b 89 controllers_length = controllers_lengthT;
akashvibhute 0:30537dec6e0b 90 for( uint8_t i = 0; i < controllers_length; i++){
akashvibhute 0:30537dec6e0b 91 uint32_t length_st_controllers;
akashvibhute 0:30537dec6e0b 92 memcpy(&length_st_controllers, (inbuffer + offset), sizeof(uint32_t));
akashvibhute 0:30537dec6e0b 93 offset += 4;
akashvibhute 0:30537dec6e0b 94 for(unsigned int k= offset; k< offset+length_st_controllers; ++k){
akashvibhute 0:30537dec6e0b 95 inbuffer[k-1]=inbuffer[k];
akashvibhute 0:30537dec6e0b 96 }
akashvibhute 0:30537dec6e0b 97 inbuffer[offset+length_st_controllers-1]=0;
akashvibhute 0:30537dec6e0b 98 this->st_controllers = (char *)(inbuffer + offset-1);
akashvibhute 0:30537dec6e0b 99 offset += length_st_controllers;
akashvibhute 0:30537dec6e0b 100 memcpy( &(this->controllers[i]), &(this->st_controllers), sizeof(char*));
akashvibhute 0:30537dec6e0b 101 }
akashvibhute 0:30537dec6e0b 102 uint8_t state_lengthT = *(inbuffer + offset++);
akashvibhute 0:30537dec6e0b 103 if(state_lengthT > state_length)
akashvibhute 0:30537dec6e0b 104 this->state = (char**)realloc(this->state, state_lengthT * sizeof(char*));
akashvibhute 0:30537dec6e0b 105 offset += 3;
akashvibhute 0:30537dec6e0b 106 state_length = state_lengthT;
akashvibhute 0:30537dec6e0b 107 for( uint8_t i = 0; i < state_length; i++){
akashvibhute 0:30537dec6e0b 108 uint32_t length_st_state;
akashvibhute 0:30537dec6e0b 109 memcpy(&length_st_state, (inbuffer + offset), sizeof(uint32_t));
akashvibhute 0:30537dec6e0b 110 offset += 4;
akashvibhute 0:30537dec6e0b 111 for(unsigned int k= offset; k< offset+length_st_state; ++k){
akashvibhute 0:30537dec6e0b 112 inbuffer[k-1]=inbuffer[k];
akashvibhute 0:30537dec6e0b 113 }
akashvibhute 0:30537dec6e0b 114 inbuffer[offset+length_st_state-1]=0;
akashvibhute 0:30537dec6e0b 115 this->st_state = (char *)(inbuffer + offset-1);
akashvibhute 0:30537dec6e0b 116 offset += length_st_state;
akashvibhute 0:30537dec6e0b 117 memcpy( &(this->state[i]), &(this->st_state), sizeof(char*));
akashvibhute 0:30537dec6e0b 118 }
akashvibhute 0:30537dec6e0b 119 return offset;
akashvibhute 0:30537dec6e0b 120 }
akashvibhute 0:30537dec6e0b 121
akashvibhute 0:30537dec6e0b 122 const char * getType(){ return LISTCONTROLLERS; };
akashvibhute 0:30537dec6e0b 123 const char * getMD5(){ return "39c8d39516aed5c7d76284ac06c220e5"; };
akashvibhute 0:30537dec6e0b 124
akashvibhute 0:30537dec6e0b 125 };
akashvibhute 0:30537dec6e0b 126
akashvibhute 0:30537dec6e0b 127 class ListControllers {
akashvibhute 0:30537dec6e0b 128 public:
akashvibhute 0:30537dec6e0b 129 typedef ListControllersRequest Request;
akashvibhute 0:30537dec6e0b 130 typedef ListControllersResponse Response;
akashvibhute 0:30537dec6e0b 131 };
akashvibhute 0:30537dec6e0b 132
akashvibhute 0:30537dec6e0b 133 }
akashvibhute 0:30537dec6e0b 134 #endif
akashvibhute 0:30537dec6e0b 135