Personal fork
Fork of rosserial_mbed_lib by
rosserial_msgs/TopicInfo.h@3:1cf99502f396, 2011-11-12 (annotated)
- Committer:
- nucho
- Date:
- Sat Nov 12 23:54:45 2011 +0000
- Revision:
- 3:1cf99502f396
- Parent:
- 1:ff0ec969dad1
This program supported the revision of 167 of rosserial.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nucho | 3:1cf99502f396 | 1 | #ifndef _ROS_rosserial_msgs_TopicInfo_h |
nucho | 3:1cf99502f396 | 2 | #define _ROS_rosserial_msgs_TopicInfo_h |
nucho | 0:77afd7560544 | 3 | |
nucho | 0:77afd7560544 | 4 | #include <stdint.h> |
nucho | 0:77afd7560544 | 5 | #include <string.h> |
nucho | 0:77afd7560544 | 6 | #include <stdlib.h> |
nucho | 3:1cf99502f396 | 7 | #include "ros/msg.h" |
nucho | 3:1cf99502f396 | 8 | |
nucho | 0:77afd7560544 | 9 | namespace rosserial_msgs |
nucho | 0:77afd7560544 | 10 | { |
nucho | 3:1cf99502f396 | 11 | |
nucho | 0:77afd7560544 | 12 | class TopicInfo : public ros::Msg |
nucho | 0:77afd7560544 | 13 | { |
nucho | 0:77afd7560544 | 14 | public: |
nucho | 3:1cf99502f396 | 15 | uint16_t topic_id; |
nucho | 0:77afd7560544 | 16 | char * topic_name; |
nucho | 0:77afd7560544 | 17 | char * message_type; |
nucho | 3:1cf99502f396 | 18 | char * md5sum; |
nucho | 3:1cf99502f396 | 19 | int32_t buffer_size; |
nucho | 0:77afd7560544 | 20 | enum { ID_PUBLISHER = 0 }; |
nucho | 0:77afd7560544 | 21 | enum { ID_SUBSCRIBER = 1 }; |
nucho | 0:77afd7560544 | 22 | enum { ID_SERVICE_SERVER = 2 }; |
nucho | 3:1cf99502f396 | 23 | enum { ID_SERVICE_CLIENT = 4 }; |
nucho | 3:1cf99502f396 | 24 | enum { ID_PARAMETER_REQUEST = 6 }; |
nucho | 3:1cf99502f396 | 25 | enum { ID_LOG = 7 }; |
nucho | 0:77afd7560544 | 26 | enum { ID_TIME = 10 }; |
nucho | 0:77afd7560544 | 27 | |
nucho | 3:1cf99502f396 | 28 | virtual int serialize(unsigned char *outbuffer) const |
nucho | 0:77afd7560544 | 29 | { |
nucho | 0:77afd7560544 | 30 | int offset = 0; |
nucho | 3:1cf99502f396 | 31 | *(outbuffer + offset + 0) = (this->topic_id >> (8 * 0)) & 0xFF; |
nucho | 3:1cf99502f396 | 32 | *(outbuffer + offset + 1) = (this->topic_id >> (8 * 1)) & 0xFF; |
nucho | 0:77afd7560544 | 33 | offset += sizeof(this->topic_id); |
nucho | 3:1cf99502f396 | 34 | uint32_t * length_topic_name = (uint32_t *)(outbuffer + offset); |
nucho | 0:77afd7560544 | 35 | *length_topic_name = strlen( (const char*) this->topic_name); |
nucho | 0:77afd7560544 | 36 | offset += 4; |
nucho | 0:77afd7560544 | 37 | memcpy(outbuffer + offset, this->topic_name, *length_topic_name); |
nucho | 0:77afd7560544 | 38 | offset += *length_topic_name; |
nucho | 3:1cf99502f396 | 39 | uint32_t * length_message_type = (uint32_t *)(outbuffer + offset); |
nucho | 0:77afd7560544 | 40 | *length_message_type = strlen( (const char*) this->message_type); |
nucho | 0:77afd7560544 | 41 | offset += 4; |
nucho | 0:77afd7560544 | 42 | memcpy(outbuffer + offset, this->message_type, *length_message_type); |
nucho | 0:77afd7560544 | 43 | offset += *length_message_type; |
nucho | 3:1cf99502f396 | 44 | uint32_t * length_md5sum = (uint32_t *)(outbuffer + offset); |
nucho | 3:1cf99502f396 | 45 | *length_md5sum = strlen( (const char*) this->md5sum); |
nucho | 1:ff0ec969dad1 | 46 | offset += 4; |
nucho | 3:1cf99502f396 | 47 | memcpy(outbuffer + offset, this->md5sum, *length_md5sum); |
nucho | 3:1cf99502f396 | 48 | offset += *length_md5sum; |
nucho | 3:1cf99502f396 | 49 | union { |
nucho | 3:1cf99502f396 | 50 | int32_t real; |
nucho | 3:1cf99502f396 | 51 | uint32_t base; |
nucho | 3:1cf99502f396 | 52 | } u_buffer_size; |
nucho | 3:1cf99502f396 | 53 | u_buffer_size.real = this->buffer_size; |
nucho | 3:1cf99502f396 | 54 | *(outbuffer + offset + 0) = (u_buffer_size.base >> (8 * 0)) & 0xFF; |
nucho | 3:1cf99502f396 | 55 | *(outbuffer + offset + 1) = (u_buffer_size.base >> (8 * 1)) & 0xFF; |
nucho | 3:1cf99502f396 | 56 | *(outbuffer + offset + 2) = (u_buffer_size.base >> (8 * 2)) & 0xFF; |
nucho | 3:1cf99502f396 | 57 | *(outbuffer + offset + 3) = (u_buffer_size.base >> (8 * 3)) & 0xFF; |
nucho | 3:1cf99502f396 | 58 | offset += sizeof(this->buffer_size); |
nucho | 0:77afd7560544 | 59 | return offset; |
nucho | 0:77afd7560544 | 60 | } |
nucho | 0:77afd7560544 | 61 | |
nucho | 0:77afd7560544 | 62 | virtual int deserialize(unsigned char *inbuffer) |
nucho | 0:77afd7560544 | 63 | { |
nucho | 0:77afd7560544 | 64 | int offset = 0; |
nucho | 3:1cf99502f396 | 65 | this->topic_id |= ((uint16_t) (*(inbuffer + offset + 0))) << (8 * 0); |
nucho | 3:1cf99502f396 | 66 | this->topic_id |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1); |
nucho | 0:77afd7560544 | 67 | offset += sizeof(this->topic_id); |
nucho | 0:77afd7560544 | 68 | uint32_t length_topic_name = *(uint32_t *)(inbuffer + offset); |
nucho | 0:77afd7560544 | 69 | offset += 4; |
nucho | 0:77afd7560544 | 70 | for(unsigned int k= offset; k< offset+length_topic_name; ++k){ |
nucho | 0:77afd7560544 | 71 | inbuffer[k-1]=inbuffer[k]; |
nucho | 3:1cf99502f396 | 72 | } |
nucho | 0:77afd7560544 | 73 | inbuffer[offset+length_topic_name-1]=0; |
nucho | 0:77afd7560544 | 74 | this->topic_name = (char *)(inbuffer + offset-1); |
nucho | 0:77afd7560544 | 75 | offset += length_topic_name; |
nucho | 0:77afd7560544 | 76 | uint32_t length_message_type = *(uint32_t *)(inbuffer + offset); |
nucho | 0:77afd7560544 | 77 | offset += 4; |
nucho | 0:77afd7560544 | 78 | for(unsigned int k= offset; k< offset+length_message_type; ++k){ |
nucho | 0:77afd7560544 | 79 | inbuffer[k-1]=inbuffer[k]; |
nucho | 3:1cf99502f396 | 80 | } |
nucho | 0:77afd7560544 | 81 | inbuffer[offset+length_message_type-1]=0; |
nucho | 0:77afd7560544 | 82 | this->message_type = (char *)(inbuffer + offset-1); |
nucho | 0:77afd7560544 | 83 | offset += length_message_type; |
nucho | 3:1cf99502f396 | 84 | uint32_t length_md5sum = *(uint32_t *)(inbuffer + offset); |
nucho | 1:ff0ec969dad1 | 85 | offset += 4; |
nucho | 3:1cf99502f396 | 86 | for(unsigned int k= offset; k< offset+length_md5sum; ++k){ |
nucho | 1:ff0ec969dad1 | 87 | inbuffer[k-1]=inbuffer[k]; |
nucho | 3:1cf99502f396 | 88 | } |
nucho | 3:1cf99502f396 | 89 | inbuffer[offset+length_md5sum-1]=0; |
nucho | 3:1cf99502f396 | 90 | this->md5sum = (char *)(inbuffer + offset-1); |
nucho | 3:1cf99502f396 | 91 | offset += length_md5sum; |
nucho | 3:1cf99502f396 | 92 | union { |
nucho | 3:1cf99502f396 | 93 | int32_t real; |
nucho | 3:1cf99502f396 | 94 | uint32_t base; |
nucho | 3:1cf99502f396 | 95 | } u_buffer_size; |
nucho | 3:1cf99502f396 | 96 | u_buffer_size.base = 0; |
nucho | 3:1cf99502f396 | 97 | u_buffer_size.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
nucho | 3:1cf99502f396 | 98 | u_buffer_size.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
nucho | 3:1cf99502f396 | 99 | u_buffer_size.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
nucho | 3:1cf99502f396 | 100 | u_buffer_size.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
nucho | 3:1cf99502f396 | 101 | this->buffer_size = u_buffer_size.real; |
nucho | 3:1cf99502f396 | 102 | offset += sizeof(this->buffer_size); |
nucho | 0:77afd7560544 | 103 | return offset; |
nucho | 0:77afd7560544 | 104 | } |
nucho | 0:77afd7560544 | 105 | |
nucho | 0:77afd7560544 | 106 | virtual const char * getType(){ return "rosserial_msgs/TopicInfo"; }; |
nucho | 3:1cf99502f396 | 107 | virtual const char * getMD5(){ return "63aa5e8f1bdd6f35c69fe1a1b9d28e9f"; }; |
nucho | 0:77afd7560544 | 108 | |
nucho | 0:77afd7560544 | 109 | }; |
nucho | 0:77afd7560544 | 110 | |
nucho | 0:77afd7560544 | 111 | } |
nucho | 0:77afd7560544 | 112 | #endif |