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