complete motor

Dependencies:   BufferedSerial motor_sn7544

Committer:
Jeonghoon
Date:
Thu Jun 27 04:58:29 2019 +0000
Revision:
7:13dd93a0efe8
combine motor with ROS

Who changed what in which revision?

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