Personal fork
Fork of rosserial_mbed_lib by
rosserial_msgs/Log.h@5:19c5437ed9fe, 2014-05-01 (annotated)
- Committer:
- garyservin
- Date:
- Thu May 01 06:01:31 2014 +0000
- Revision:
- 5:19c5437ed9fe
- Parent:
- 3:1cf99502f396
Updated to hydro
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nucho | 3:1cf99502f396 | 1 | #ifndef _ROS_rosserial_msgs_Log_h |
nucho | 3:1cf99502f396 | 2 | #define _ROS_rosserial_msgs_Log_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 | 0:77afd7560544 | 8 | |
nucho | 0:77afd7560544 | 9 | namespace rosserial_msgs |
nucho | 0:77afd7560544 | 10 | { |
nucho | 0:77afd7560544 | 11 | |
nucho | 0:77afd7560544 | 12 | class Log : public ros::Msg |
nucho | 0:77afd7560544 | 13 | { |
nucho | 0:77afd7560544 | 14 | public: |
nucho | 3:1cf99502f396 | 15 | uint8_t level; |
nucho | 0:77afd7560544 | 16 | char * msg; |
nucho | 0:77afd7560544 | 17 | enum { DEBUG = 0 }; |
nucho | 0:77afd7560544 | 18 | enum { INFO = 1 }; |
nucho | 0:77afd7560544 | 19 | enum { WARN = 2 }; |
nucho | 0:77afd7560544 | 20 | enum { ERROR = 3 }; |
nucho | 0:77afd7560544 | 21 | enum { FATAL = 4 }; |
nucho | 0:77afd7560544 | 22 | |
nucho | 3:1cf99502f396 | 23 | virtual int serialize(unsigned char *outbuffer) const |
nucho | 0:77afd7560544 | 24 | { |
nucho | 0:77afd7560544 | 25 | int offset = 0; |
nucho | 3:1cf99502f396 | 26 | *(outbuffer + offset + 0) = (this->level >> (8 * 0)) & 0xFF; |
nucho | 0:77afd7560544 | 27 | offset += sizeof(this->level); |
nucho | 3:1cf99502f396 | 28 | uint32_t * length_msg = (uint32_t *)(outbuffer + offset); |
nucho | 0:77afd7560544 | 29 | *length_msg = strlen( (const char*) this->msg); |
nucho | 0:77afd7560544 | 30 | offset += 4; |
nucho | 0:77afd7560544 | 31 | memcpy(outbuffer + offset, this->msg, *length_msg); |
nucho | 0:77afd7560544 | 32 | offset += *length_msg; |
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 | 3:1cf99502f396 | 39 | this->level |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); |
nucho | 0:77afd7560544 | 40 | offset += sizeof(this->level); |
nucho | 0:77afd7560544 | 41 | uint32_t length_msg = *(uint32_t *)(inbuffer + offset); |
nucho | 0:77afd7560544 | 42 | offset += 4; |
nucho | 0:77afd7560544 | 43 | for(unsigned int k= offset; k< offset+length_msg; ++k){ |
nucho | 0:77afd7560544 | 44 | inbuffer[k-1]=inbuffer[k]; |
nucho | 3:1cf99502f396 | 45 | } |
nucho | 0:77afd7560544 | 46 | inbuffer[offset+length_msg-1]=0; |
nucho | 0:77afd7560544 | 47 | this->msg = (char *)(inbuffer + offset-1); |
nucho | 0:77afd7560544 | 48 | offset += length_msg; |
nucho | 0:77afd7560544 | 49 | return offset; |
nucho | 0:77afd7560544 | 50 | } |
nucho | 0:77afd7560544 | 51 | |
nucho | 0:77afd7560544 | 52 | virtual const char * getType(){ return "rosserial_msgs/Log"; }; |
nucho | 3:1cf99502f396 | 53 | virtual const char * getMD5(){ return "7170d5aec999754ba0d9f762bf49b913"; }; |
nucho | 0:77afd7560544 | 54 | |
nucho | 0:77afd7560544 | 55 | }; |
nucho | 0:77afd7560544 | 56 | |
nucho | 0:77afd7560544 | 57 | } |
nucho | 0:77afd7560544 | 58 | #endif |