rosserial for Hydro
Fork of rosserial_mbed_lib by
dianostic_msgs/DiagnosticArray.h@0:77afd7560544, 2011-08-19 (annotated)
- Committer:
- nucho
- Date:
- Fri Aug 19 09:06:30 2011 +0000
- Revision:
- 0:77afd7560544
- Child:
- 1:ff0ec969dad1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nucho | 0:77afd7560544 | 1 | #ifndef ros_DiagnosticArray_h |
nucho | 0:77afd7560544 | 2 | #define ros_DiagnosticArray_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 | 0:77afd7560544 | 7 | #include "../ros/msg.h" |
nucho | 0:77afd7560544 | 8 | #include "std_msgs/Header.h" |
nucho | 0:77afd7560544 | 9 | #include "diagnostic_msgs/DiagnosticStatus.h" |
nucho | 0:77afd7560544 | 10 | |
nucho | 0:77afd7560544 | 11 | namespace diagnostic_msgs |
nucho | 0:77afd7560544 | 12 | { |
nucho | 0:77afd7560544 | 13 | |
nucho | 0:77afd7560544 | 14 | class DiagnosticArray : public ros::Msg |
nucho | 0:77afd7560544 | 15 | { |
nucho | 0:77afd7560544 | 16 | public: |
nucho | 0:77afd7560544 | 17 | std_msgs::Header header; |
nucho | 0:77afd7560544 | 18 | unsigned char status_length; |
nucho | 0:77afd7560544 | 19 | diagnostic_msgs::DiagnosticStatus st_status; |
nucho | 0:77afd7560544 | 20 | diagnostic_msgs::DiagnosticStatus * status; |
nucho | 0:77afd7560544 | 21 | |
nucho | 0:77afd7560544 | 22 | virtual int serialize(unsigned char *outbuffer) |
nucho | 0:77afd7560544 | 23 | { |
nucho | 0:77afd7560544 | 24 | int offset = 0; |
nucho | 0:77afd7560544 | 25 | offset += this->header.serialize(outbuffer + offset); |
nucho | 0:77afd7560544 | 26 | *(outbuffer + offset++) = status_length; |
nucho | 0:77afd7560544 | 27 | *(outbuffer + offset++) = 0; |
nucho | 0:77afd7560544 | 28 | *(outbuffer + offset++) = 0; |
nucho | 0:77afd7560544 | 29 | *(outbuffer + offset++) = 0; |
nucho | 0:77afd7560544 | 30 | for( unsigned char i = 0; i < status_length; i++){ |
nucho | 0:77afd7560544 | 31 | offset += this->status[i].serialize(outbuffer + offset); |
nucho | 0:77afd7560544 | 32 | } |
nucho | 0:77afd7560544 | 33 | return offset; |
nucho | 0:77afd7560544 | 34 | } |
nucho | 0:77afd7560544 | 35 | |
nucho | 0:77afd7560544 | 36 | virtual int deserialize(unsigned char *inbuffer) |
nucho | 0:77afd7560544 | 37 | { |
nucho | 0:77afd7560544 | 38 | int offset = 0; |
nucho | 0:77afd7560544 | 39 | offset += this->header.deserialize(inbuffer + offset); |
nucho | 0:77afd7560544 | 40 | unsigned char status_lengthT = *(inbuffer + offset++); |
nucho | 0:77afd7560544 | 41 | if(status_lengthT > status_length) |
nucho | 0:77afd7560544 | 42 | this->status = (diagnostic_msgs::DiagnosticStatus*)realloc(this->status, status_lengthT * sizeof(diagnostic_msgs::DiagnosticStatus)); |
nucho | 0:77afd7560544 | 43 | offset += 3; |
nucho | 0:77afd7560544 | 44 | status_length = status_lengthT; |
nucho | 0:77afd7560544 | 45 | for( unsigned char i = 0; i < status_length; i++){ |
nucho | 0:77afd7560544 | 46 | offset += this->st_status.deserialize(inbuffer + offset); |
nucho | 0:77afd7560544 | 47 | memcpy( &(this->status[i]), &(this->st_status), sizeof(diagnostic_msgs::DiagnosticStatus)); |
nucho | 0:77afd7560544 | 48 | } |
nucho | 0:77afd7560544 | 49 | return offset; |
nucho | 0:77afd7560544 | 50 | } |
nucho | 0:77afd7560544 | 51 | |
nucho | 0:77afd7560544 | 52 | virtual const char * getType(){ return "diagnostic_msgs/DiagnosticArray"; }; |
nucho | 0:77afd7560544 | 53 | |
nucho | 0:77afd7560544 | 54 | }; |
nucho | 0:77afd7560544 | 55 | |
nucho | 0:77afd7560544 | 56 | } |
nucho | 0:77afd7560544 | 57 | #endif |