00001 #ifndef _ROS_SERVICE_Test_h 00002 #define _ROS_SERVICE_Test_h 00003 #include <stdint.h> 00004 #include <string.h> 00005 #include <stdlib.h> 00006 #include "ros/msg.h" 00007 00008 namespace rosserial_arduino 00009 { 00010 00011 static const char TEST[] = "rosserial_arduino/Test"; 00012 00013 class TestRequest : public ros::Msg 00014 { 00015 public: 00016 char * input; 00017 00018 virtual int serialize(unsigned char *outbuffer) const 00019 { 00020 int offset = 0; 00021 uint32_t * length_input = (uint32_t *)(outbuffer + offset); 00022 *length_input = strlen( (const char*) this->input); 00023 offset += 4; 00024 memcpy(outbuffer + offset, this->input, *length_input); 00025 offset += *length_input; 00026 return offset; 00027 } 00028 00029 virtual int deserialize(unsigned char *inbuffer) 00030 { 00031 int offset = 0; 00032 uint32_t length_input = *(uint32_t *)(inbuffer + offset); 00033 offset += 4; 00034 for(unsigned int k= offset; k< offset+length_input; ++k){ 00035 inbuffer[k-1]=inbuffer[k]; 00036 } 00037 inbuffer[offset+length_input-1]=0; 00038 this->input = (char *)(inbuffer + offset-1); 00039 offset += length_input; 00040 return offset; 00041 } 00042 00043 const char * getType(){ return TEST; }; 00044 const char * getMD5(){ return "39e92f1778057359c64c7b8a7d7b19de"; }; 00045 00046 }; 00047 00048 class TestResponse : public ros::Msg 00049 { 00050 public: 00051 char * output; 00052 00053 virtual int serialize(unsigned char *outbuffer) const 00054 { 00055 int offset = 0; 00056 uint32_t * length_output = (uint32_t *)(outbuffer + offset); 00057 *length_output = strlen( (const char*) this->output); 00058 offset += 4; 00059 memcpy(outbuffer + offset, this->output, *length_output); 00060 offset += *length_output; 00061 return offset; 00062 } 00063 00064 virtual int deserialize(unsigned char *inbuffer) 00065 { 00066 int offset = 0; 00067 uint32_t length_output = *(uint32_t *)(inbuffer + offset); 00068 offset += 4; 00069 for(unsigned int k= offset; k< offset+length_output; ++k){ 00070 inbuffer[k-1]=inbuffer[k]; 00071 } 00072 inbuffer[offset+length_output-1]=0; 00073 this->output = (char *)(inbuffer + offset-1); 00074 offset += length_output; 00075 return offset; 00076 } 00077 00078 const char * getType(){ return TEST; }; 00079 const char * getMD5(){ return "0825d95fdfa2c8f4bbb4e9c74bccd3fd"; }; 00080 00081 }; 00082 00083 class Test { 00084 public: 00085 typedef TestRequest Request; 00086 typedef TestResponse Response; 00087 }; 00088 00089 } 00090 #endif