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
Status.h
00001 #ifndef _ROS_bond_Status_h 00002 #define _ROS_bond_Status_h 00003 00004 #include <stdint.h> 00005 #include <string.h> 00006 #include <stdlib.h> 00007 #include "ros/msg.h" 00008 #include "std_msgs/Header.h" 00009 00010 namespace bond 00011 { 00012 00013 class Status : public ros::Msg 00014 { 00015 public: 00016 std_msgs::Header header; 00017 const char* id; 00018 const char* instance_id; 00019 bool active; 00020 float heartbeat_timeout; 00021 float heartbeat_period; 00022 00023 Status(): 00024 header(), 00025 id(""), 00026 instance_id(""), 00027 active(0), 00028 heartbeat_timeout(0), 00029 heartbeat_period(0) 00030 { 00031 } 00032 00033 virtual int serialize(unsigned char *outbuffer) const 00034 { 00035 int offset = 0; 00036 offset += this->header.serialize(outbuffer + offset); 00037 uint32_t length_id = strlen(this->id); 00038 memcpy(outbuffer + offset, &length_id, sizeof(uint32_t)); 00039 offset += 4; 00040 memcpy(outbuffer + offset, this->id, length_id); 00041 offset += length_id; 00042 uint32_t length_instance_id = strlen(this->instance_id); 00043 memcpy(outbuffer + offset, &length_instance_id, sizeof(uint32_t)); 00044 offset += 4; 00045 memcpy(outbuffer + offset, this->instance_id, length_instance_id); 00046 offset += length_instance_id; 00047 union { 00048 bool real; 00049 uint8_t base; 00050 } u_active; 00051 u_active.real = this->active; 00052 *(outbuffer + offset + 0) = (u_active.base >> (8 * 0)) & 0xFF; 00053 offset += sizeof(this->active); 00054 union { 00055 float real; 00056 uint32_t base; 00057 } u_heartbeat_timeout; 00058 u_heartbeat_timeout.real = this->heartbeat_timeout; 00059 *(outbuffer + offset + 0) = (u_heartbeat_timeout.base >> (8 * 0)) & 0xFF; 00060 *(outbuffer + offset + 1) = (u_heartbeat_timeout.base >> (8 * 1)) & 0xFF; 00061 *(outbuffer + offset + 2) = (u_heartbeat_timeout.base >> (8 * 2)) & 0xFF; 00062 *(outbuffer + offset + 3) = (u_heartbeat_timeout.base >> (8 * 3)) & 0xFF; 00063 offset += sizeof(this->heartbeat_timeout); 00064 union { 00065 float real; 00066 uint32_t base; 00067 } u_heartbeat_period; 00068 u_heartbeat_period.real = this->heartbeat_period; 00069 *(outbuffer + offset + 0) = (u_heartbeat_period.base >> (8 * 0)) & 0xFF; 00070 *(outbuffer + offset + 1) = (u_heartbeat_period.base >> (8 * 1)) & 0xFF; 00071 *(outbuffer + offset + 2) = (u_heartbeat_period.base >> (8 * 2)) & 0xFF; 00072 *(outbuffer + offset + 3) = (u_heartbeat_period.base >> (8 * 3)) & 0xFF; 00073 offset += sizeof(this->heartbeat_period); 00074 return offset; 00075 } 00076 00077 virtual int deserialize(unsigned char *inbuffer) 00078 { 00079 int offset = 0; 00080 offset += this->header.deserialize(inbuffer + offset); 00081 uint32_t length_id; 00082 memcpy(&length_id, (inbuffer + offset), sizeof(uint32_t)); 00083 offset += 4; 00084 for(unsigned int k= offset; k< offset+length_id; ++k){ 00085 inbuffer[k-1]=inbuffer[k]; 00086 } 00087 inbuffer[offset+length_id-1]=0; 00088 this->id = (char *)(inbuffer + offset-1); 00089 offset += length_id; 00090 uint32_t length_instance_id; 00091 memcpy(&length_instance_id, (inbuffer + offset), sizeof(uint32_t)); 00092 offset += 4; 00093 for(unsigned int k= offset; k< offset+length_instance_id; ++k){ 00094 inbuffer[k-1]=inbuffer[k]; 00095 } 00096 inbuffer[offset+length_instance_id-1]=0; 00097 this->instance_id = (char *)(inbuffer + offset-1); 00098 offset += length_instance_id; 00099 union { 00100 bool real; 00101 uint8_t base; 00102 } u_active; 00103 u_active.base = 0; 00104 u_active.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); 00105 this->active = u_active.real; 00106 offset += sizeof(this->active); 00107 union { 00108 float real; 00109 uint32_t base; 00110 } u_heartbeat_timeout; 00111 u_heartbeat_timeout.base = 0; 00112 u_heartbeat_timeout.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); 00113 u_heartbeat_timeout.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00114 u_heartbeat_timeout.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00115 u_heartbeat_timeout.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00116 this->heartbeat_timeout = u_heartbeat_timeout.real; 00117 offset += sizeof(this->heartbeat_timeout); 00118 union { 00119 float real; 00120 uint32_t base; 00121 } u_heartbeat_period; 00122 u_heartbeat_period.base = 0; 00123 u_heartbeat_period.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); 00124 u_heartbeat_period.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00125 u_heartbeat_period.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00126 u_heartbeat_period.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00127 this->heartbeat_period = u_heartbeat_period.real; 00128 offset += sizeof(this->heartbeat_period); 00129 return offset; 00130 } 00131 00132 const char * getType(){ return "bond/Status"; }; 00133 const char * getMD5(){ return "eacc84bf5d65b6777d4c50f463dfb9c8"; }; 00134 00135 }; 00136 00137 } 00138 #endif
Generated on Tue Jul 12 2022 18:39:41 by 1.7.2