Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of rosserial_mbed_lib by
SelfTest.h
00001 #ifndef _ROS_SERVICE_SelfTest_h 00002 #define _ROS_SERVICE_SelfTest_h 00003 #include <stdint.h> 00004 #include <string.h> 00005 #include <stdlib.h> 00006 #include "ros/msg.h" 00007 #include "diagnostic_msgs/DiagnosticStatus.h" 00008 #include "diagnostic_msgs/byte.h" 00009 00010 namespace diagnostic_msgs 00011 { 00012 00013 static const char SELFTEST[] = "diagnostic_msgs/SelfTest"; 00014 00015 class SelfTestRequest : public ros::Msg 00016 { 00017 public: 00018 00019 virtual int serialize(unsigned char *outbuffer) const 00020 { 00021 int offset = 0; 00022 return offset; 00023 } 00024 00025 virtual int deserialize(unsigned char *inbuffer) 00026 { 00027 int offset = 0; 00028 return offset; 00029 } 00030 00031 const char * getType(){ return SELFTEST; }; 00032 const char * getMD5(){ return "d41d8cd98f00b204e9800998ecf8427e"; }; 00033 00034 }; 00035 00036 class SelfTestResponse : public ros::Msg 00037 { 00038 public: 00039 char * id; 00040 diagnostic_msgs::byte passed; 00041 uint8_t status_length; 00042 diagnostic_msgs::DiagnosticStatus st_status; 00043 diagnostic_msgs::DiagnosticStatus * status; 00044 00045 virtual int serialize(unsigned char *outbuffer) const 00046 { 00047 int offset = 0; 00048 uint32_t * length_id = (uint32_t *)(outbuffer + offset); 00049 *length_id = strlen( (const char*) this->id); 00050 offset += 4; 00051 memcpy(outbuffer + offset, this->id, *length_id); 00052 offset += *length_id; 00053 offset += this->passed.serialize(outbuffer + offset); 00054 *(outbuffer + offset++) = status_length; 00055 *(outbuffer + offset++) = 0; 00056 *(outbuffer + offset++) = 0; 00057 *(outbuffer + offset++) = 0; 00058 for( uint8_t i = 0; i < status_length; i++){ 00059 offset += this->status[i].serialize(outbuffer + offset); 00060 } 00061 return offset; 00062 } 00063 00064 virtual int deserialize(unsigned char *inbuffer) 00065 { 00066 int offset = 0; 00067 uint32_t length_id = *(uint32_t *)(inbuffer + offset); 00068 offset += 4; 00069 for(unsigned int k= offset; k< offset+length_id; ++k){ 00070 inbuffer[k-1]=inbuffer[k]; 00071 } 00072 inbuffer[offset+length_id-1]=0; 00073 this->id = (char *)(inbuffer + offset-1); 00074 offset += length_id; 00075 offset += this->passed.deserialize(inbuffer + offset); 00076 uint8_t status_lengthT = *(inbuffer + offset++); 00077 if(status_lengthT > status_length) 00078 this->status = (diagnostic_msgs::DiagnosticStatus*)realloc(this->status, status_lengthT * sizeof(diagnostic_msgs::DiagnosticStatus)); 00079 offset += 3; 00080 status_length = status_lengthT; 00081 for( uint8_t i = 0; i < status_length; i++){ 00082 offset += this->st_status.deserialize(inbuffer + offset); 00083 memcpy( &(this->status[i]), &(this->st_status), sizeof(diagnostic_msgs::DiagnosticStatus)); 00084 } 00085 return offset; 00086 } 00087 00088 const char * getType(){ return SELFTEST; }; 00089 const char * getMD5(){ return "74c9372c870a76da4fc2b3973978b898"; }; 00090 00091 }; 00092 00093 class SelfTest { 00094 public: 00095 typedef SelfTestRequest Request; 00096 typedef SelfTestResponse Response; 00097 }; 00098 00099 } 00100 #endif
Generated on Tue Jul 12 2022 19:53:57 by
1.7.2
