ROS Serial library for Mbed platforms for ROS Indigo Igloo. Check http://wiki.ros.org/rosserial_mbed/ for more information
Dependents: rosserial_mbed_hello_world_publisher rtos_base_control rosserial_mbed_F64MA ROS-RTOS ... more
Test.h
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_mbed 00009 { 00010 00011 static const char TEST[] = "rosserial_mbed/Test"; 00012 00013 class TestRequest : public ros::Msg 00014 { 00015 public: 00016 const char* input; 00017 00018 TestRequest(): 00019 input("") 00020 { 00021 } 00022 00023 virtual int serialize(unsigned char *outbuffer) const 00024 { 00025 int offset = 0; 00026 uint32_t length_input = strlen(this->input); 00027 memcpy(outbuffer + offset, &length_input, sizeof(uint32_t)); 00028 offset += 4; 00029 memcpy(outbuffer + offset, this->input, length_input); 00030 offset += length_input; 00031 return offset; 00032 } 00033 00034 virtual int deserialize(unsigned char *inbuffer) 00035 { 00036 int offset = 0; 00037 uint32_t length_input; 00038 memcpy(&length_input, (inbuffer + offset), sizeof(uint32_t)); 00039 offset += 4; 00040 for(unsigned int k= offset; k< offset+length_input; ++k){ 00041 inbuffer[k-1]=inbuffer[k]; 00042 } 00043 inbuffer[offset+length_input-1]=0; 00044 this->input = (char *)(inbuffer + offset-1); 00045 offset += length_input; 00046 return offset; 00047 } 00048 00049 const char * getType(){ return TEST; }; 00050 const char * getMD5(){ return "39e92f1778057359c64c7b8a7d7b19de"; }; 00051 00052 }; 00053 00054 class TestResponse : public ros::Msg 00055 { 00056 public: 00057 const char* output; 00058 00059 TestResponse(): 00060 output("") 00061 { 00062 } 00063 00064 virtual int serialize(unsigned char *outbuffer) const 00065 { 00066 int offset = 0; 00067 uint32_t length_output = strlen(this->output); 00068 memcpy(outbuffer + offset, &length_output, sizeof(uint32_t)); 00069 offset += 4; 00070 memcpy(outbuffer + offset, this->output, length_output); 00071 offset += length_output; 00072 return offset; 00073 } 00074 00075 virtual int deserialize(unsigned char *inbuffer) 00076 { 00077 int offset = 0; 00078 uint32_t length_output; 00079 memcpy(&length_output, (inbuffer + offset), sizeof(uint32_t)); 00080 offset += 4; 00081 for(unsigned int k= offset; k< offset+length_output; ++k){ 00082 inbuffer[k-1]=inbuffer[k]; 00083 } 00084 inbuffer[offset+length_output-1]=0; 00085 this->output = (char *)(inbuffer + offset-1); 00086 offset += length_output; 00087 return offset; 00088 } 00089 00090 const char * getType(){ return TEST; }; 00091 const char * getMD5(){ return "0825d95fdfa2c8f4bbb4e9c74bccd3fd"; }; 00092 00093 }; 00094 00095 class Test { 00096 public: 00097 typedef TestRequest Request; 00098 typedef TestResponse Response; 00099 }; 00100 00101 } 00102 #endif
Generated on Tue Jul 12 2022 18:39:41 by 1.7.2