00001 #ifndef _ROS_SERVICE_RequestParam_h 00002 #define _ROS_SERVICE_RequestParam_h 00003 #include <stdint.h> 00004 #include <string.h> 00005 #include <stdlib.h> 00006 #include "ros/msg.h" 00007 00008 namespace rosserial_msgs 00009 { 00010 00011 static const char REQUESTPARAM[] = "rosserial_msgs/RequestParam"; 00012 00013 class RequestParamRequest : public ros::Msg 00014 { 00015 public: 00016 char * name; 00017 00018 virtual int serialize(unsigned char *outbuffer) const 00019 { 00020 int offset = 0; 00021 uint32_t * length_name = (uint32_t *)(outbuffer + offset); 00022 *length_name = strlen( (const char*) this->name); 00023 offset += 4; 00024 memcpy(outbuffer + offset, this->name, *length_name); 00025 offset += *length_name; 00026 return offset; 00027 } 00028 00029 virtual int deserialize(unsigned char *inbuffer) 00030 { 00031 int offset = 0; 00032 uint32_t length_name = *(uint32_t *)(inbuffer + offset); 00033 offset += 4; 00034 for(unsigned int k= offset; k< offset+length_name; ++k){ 00035 inbuffer[k-1]=inbuffer[k]; 00036 } 00037 inbuffer[offset+length_name-1]=0; 00038 this->name = (char *)(inbuffer + offset-1); 00039 offset += length_name; 00040 return offset; 00041 } 00042 00043 const char * getType(){ return REQUESTPARAM; }; 00044 const char * getMD5(){ return "c1f3d28f1b044c871e6eff2e9fc3c667"; }; 00045 00046 }; 00047 00048 class RequestParamResponse : public ros::Msg 00049 { 00050 public: 00051 uint8_t ints_length; 00052 int32_t st_ints; 00053 int32_t * ints; 00054 uint8_t floats_length; 00055 float st_floats; 00056 float * floats; 00057 uint8_t strings_length; 00058 char* st_strings; 00059 char* * strings; 00060 00061 virtual int serialize(unsigned char *outbuffer) const 00062 { 00063 int offset = 0; 00064 *(outbuffer + offset++) = ints_length; 00065 *(outbuffer + offset++) = 0; 00066 *(outbuffer + offset++) = 0; 00067 *(outbuffer + offset++) = 0; 00068 for( uint8_t i = 0; i < ints_length; i++){ 00069 union { 00070 int32_t real; 00071 uint32_t base; 00072 } u_intsi; 00073 u_intsi.real = this->ints[i]; 00074 *(outbuffer + offset + 0) = (u_intsi.base >> (8 * 0)) & 0xFF; 00075 *(outbuffer + offset + 1) = (u_intsi.base >> (8 * 1)) & 0xFF; 00076 *(outbuffer + offset + 2) = (u_intsi.base >> (8 * 2)) & 0xFF; 00077 *(outbuffer + offset + 3) = (u_intsi.base >> (8 * 3)) & 0xFF; 00078 offset += sizeof(this->ints[i]); 00079 } 00080 *(outbuffer + offset++) = floats_length; 00081 *(outbuffer + offset++) = 0; 00082 *(outbuffer + offset++) = 0; 00083 *(outbuffer + offset++) = 0; 00084 for( uint8_t i = 0; i < floats_length; i++){ 00085 union { 00086 float real; 00087 uint32_t base; 00088 } u_floatsi; 00089 u_floatsi.real = this->floats[i]; 00090 *(outbuffer + offset + 0) = (u_floatsi.base >> (8 * 0)) & 0xFF; 00091 *(outbuffer + offset + 1) = (u_floatsi.base >> (8 * 1)) & 0xFF; 00092 *(outbuffer + offset + 2) = (u_floatsi.base >> (8 * 2)) & 0xFF; 00093 *(outbuffer + offset + 3) = (u_floatsi.base >> (8 * 3)) & 0xFF; 00094 offset += sizeof(this->floats[i]); 00095 } 00096 *(outbuffer + offset++) = strings_length; 00097 *(outbuffer + offset++) = 0; 00098 *(outbuffer + offset++) = 0; 00099 *(outbuffer + offset++) = 0; 00100 for( uint8_t i = 0; i < strings_length; i++){ 00101 uint32_t * length_stringsi = (uint32_t *)(outbuffer + offset); 00102 *length_stringsi = strlen( (const char*) this->strings[i]); 00103 offset += 4; 00104 memcpy(outbuffer + offset, this->strings[i], *length_stringsi); 00105 offset += *length_stringsi; 00106 } 00107 return offset; 00108 } 00109 00110 virtual int deserialize(unsigned char *inbuffer) 00111 { 00112 int offset = 0; 00113 uint8_t ints_lengthT = *(inbuffer + offset++); 00114 if(ints_lengthT > ints_length) 00115 this->ints = (int32_t*)realloc(this->ints, ints_lengthT * sizeof(int32_t)); 00116 offset += 3; 00117 ints_length = ints_lengthT; 00118 for( uint8_t i = 0; i < ints_length; i++){ 00119 union { 00120 int32_t real; 00121 uint32_t base; 00122 } u_st_ints; 00123 u_st_ints.base = 0; 00124 u_st_ints.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); 00125 u_st_ints.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00126 u_st_ints.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00127 u_st_ints.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00128 this->st_ints = u_st_ints.real; 00129 offset += sizeof(this->st_ints); 00130 memcpy( &(this->ints[i]), &(this->st_ints), sizeof(int32_t)); 00131 } 00132 uint8_t floats_lengthT = *(inbuffer + offset++); 00133 if(floats_lengthT > floats_length) 00134 this->floats = (float*)realloc(this->floats, floats_lengthT * sizeof(float)); 00135 offset += 3; 00136 floats_length = floats_lengthT; 00137 for( uint8_t i = 0; i < floats_length; i++){ 00138 union { 00139 float real; 00140 uint32_t base; 00141 } u_st_floats; 00142 u_st_floats.base = 0; 00143 u_st_floats.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); 00144 u_st_floats.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00145 u_st_floats.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00146 u_st_floats.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00147 this->st_floats = u_st_floats.real; 00148 offset += sizeof(this->st_floats); 00149 memcpy( &(this->floats[i]), &(this->st_floats), sizeof(float)); 00150 } 00151 uint8_t strings_lengthT = *(inbuffer + offset++); 00152 if(strings_lengthT > strings_length) 00153 this->strings = (char**)realloc(this->strings, strings_lengthT * sizeof(char*)); 00154 offset += 3; 00155 strings_length = strings_lengthT; 00156 for( uint8_t i = 0; i < strings_length; i++){ 00157 uint32_t length_st_strings = *(uint32_t *)(inbuffer + offset); 00158 offset += 4; 00159 for(unsigned int k= offset; k< offset+length_st_strings; ++k){ 00160 inbuffer[k-1]=inbuffer[k]; 00161 } 00162 inbuffer[offset+length_st_strings-1]=0; 00163 this->st_strings = (char *)(inbuffer + offset-1); 00164 offset += length_st_strings; 00165 memcpy( &(this->strings[i]), &(this->st_strings), sizeof(char*)); 00166 } 00167 return offset; 00168 } 00169 00170 const char * getType(){ return REQUESTPARAM; }; 00171 const char * getMD5(){ return "9f0e98bda65981986ddf53afa7a40e49"; }; 00172 00173 }; 00174 00175 class RequestParam { 00176 public: 00177 typedef RequestParamRequest Request; 00178 typedef RequestParamResponse Response; 00179 }; 00180 00181 } 00182 #endif