capstone_finish
Dependencies: BufferedSerial motor_sn7544
rosserial_msgs/Log.h@10:ca4e4062701a, 2019-11-26 (annotated)
- Committer:
- Jeonghoon
- Date:
- Tue Nov 26 15:30:27 2019 +0000
- Revision:
- 10:ca4e4062701a
- Parent:
- 3:2a3664dc6634
capstone finish
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jeonghoon | 3:2a3664dc6634 | 1 | #ifndef _ROS_rosserial_msgs_Log_h |
Jeonghoon | 3:2a3664dc6634 | 2 | #define _ROS_rosserial_msgs_Log_h |
Jeonghoon | 3:2a3664dc6634 | 3 | |
Jeonghoon | 3:2a3664dc6634 | 4 | #include <stdint.h> |
Jeonghoon | 3:2a3664dc6634 | 5 | #include <string.h> |
Jeonghoon | 3:2a3664dc6634 | 6 | #include <stdlib.h> |
Jeonghoon | 3:2a3664dc6634 | 7 | #include "ros/msg.h" |
Jeonghoon | 3:2a3664dc6634 | 8 | |
Jeonghoon | 3:2a3664dc6634 | 9 | namespace rosserial_msgs |
Jeonghoon | 3:2a3664dc6634 | 10 | { |
Jeonghoon | 3:2a3664dc6634 | 11 | |
Jeonghoon | 3:2a3664dc6634 | 12 | class Log : public ros::Msg |
Jeonghoon | 3:2a3664dc6634 | 13 | { |
Jeonghoon | 3:2a3664dc6634 | 14 | public: |
Jeonghoon | 3:2a3664dc6634 | 15 | typedef uint8_t _level_type; |
Jeonghoon | 3:2a3664dc6634 | 16 | _level_type level; |
Jeonghoon | 3:2a3664dc6634 | 17 | typedef const char* _msg_type; |
Jeonghoon | 3:2a3664dc6634 | 18 | _msg_type msg; |
Jeonghoon | 3:2a3664dc6634 | 19 | enum { ROSDEBUG = 0 }; |
Jeonghoon | 3:2a3664dc6634 | 20 | enum { INFO = 1 }; |
Jeonghoon | 3:2a3664dc6634 | 21 | enum { WARN = 2 }; |
Jeonghoon | 3:2a3664dc6634 | 22 | enum { ERROR = 3 }; |
Jeonghoon | 3:2a3664dc6634 | 23 | enum { FATAL = 4 }; |
Jeonghoon | 3:2a3664dc6634 | 24 | |
Jeonghoon | 3:2a3664dc6634 | 25 | Log(): |
Jeonghoon | 3:2a3664dc6634 | 26 | level(0), |
Jeonghoon | 3:2a3664dc6634 | 27 | msg("") |
Jeonghoon | 3:2a3664dc6634 | 28 | { |
Jeonghoon | 3:2a3664dc6634 | 29 | } |
Jeonghoon | 3:2a3664dc6634 | 30 | |
Jeonghoon | 3:2a3664dc6634 | 31 | virtual int serialize(unsigned char *outbuffer) const |
Jeonghoon | 3:2a3664dc6634 | 32 | { |
Jeonghoon | 3:2a3664dc6634 | 33 | int offset = 0; |
Jeonghoon | 3:2a3664dc6634 | 34 | *(outbuffer + offset + 0) = (this->level >> (8 * 0)) & 0xFF; |
Jeonghoon | 3:2a3664dc6634 | 35 | offset += sizeof(this->level); |
Jeonghoon | 3:2a3664dc6634 | 36 | uint32_t length_msg = strlen(this->msg); |
Jeonghoon | 3:2a3664dc6634 | 37 | varToArr(outbuffer + offset, length_msg); |
Jeonghoon | 3:2a3664dc6634 | 38 | offset += 4; |
Jeonghoon | 3:2a3664dc6634 | 39 | memcpy(outbuffer + offset, this->msg, length_msg); |
Jeonghoon | 3:2a3664dc6634 | 40 | offset += length_msg; |
Jeonghoon | 3:2a3664dc6634 | 41 | return offset; |
Jeonghoon | 3:2a3664dc6634 | 42 | } |
Jeonghoon | 3:2a3664dc6634 | 43 | |
Jeonghoon | 3:2a3664dc6634 | 44 | virtual int deserialize(unsigned char *inbuffer) |
Jeonghoon | 3:2a3664dc6634 | 45 | { |
Jeonghoon | 3:2a3664dc6634 | 46 | int offset = 0; |
Jeonghoon | 3:2a3664dc6634 | 47 | this->level = ((uint8_t) (*(inbuffer + offset))); |
Jeonghoon | 3:2a3664dc6634 | 48 | offset += sizeof(this->level); |
Jeonghoon | 3:2a3664dc6634 | 49 | uint32_t length_msg; |
Jeonghoon | 3:2a3664dc6634 | 50 | arrToVar(length_msg, (inbuffer + offset)); |
Jeonghoon | 3:2a3664dc6634 | 51 | offset += 4; |
Jeonghoon | 3:2a3664dc6634 | 52 | for(unsigned int k= offset; k< offset+length_msg; ++k){ |
Jeonghoon | 3:2a3664dc6634 | 53 | inbuffer[k-1]=inbuffer[k]; |
Jeonghoon | 3:2a3664dc6634 | 54 | } |
Jeonghoon | 3:2a3664dc6634 | 55 | inbuffer[offset+length_msg-1]=0; |
Jeonghoon | 3:2a3664dc6634 | 56 | this->msg = (char *)(inbuffer + offset-1); |
Jeonghoon | 3:2a3664dc6634 | 57 | offset += length_msg; |
Jeonghoon | 3:2a3664dc6634 | 58 | return offset; |
Jeonghoon | 3:2a3664dc6634 | 59 | } |
Jeonghoon | 3:2a3664dc6634 | 60 | |
Jeonghoon | 3:2a3664dc6634 | 61 | const char * getType(){ return "rosserial_msgs/Log"; }; |
Jeonghoon | 3:2a3664dc6634 | 62 | const char * getMD5(){ return "11abd731c25933261cd6183bd12d6295"; }; |
Jeonghoon | 3:2a3664dc6634 | 63 | |
Jeonghoon | 3:2a3664dc6634 | 64 | }; |
Jeonghoon | 3:2a3664dc6634 | 65 | |
Jeonghoon | 3:2a3664dc6634 | 66 | } |
Jeonghoon | 3:2a3664dc6634 | 67 | #endif |