capstone_finish

Dependencies:   BufferedSerial motor_sn7544

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?

UserRevisionLine numberNew contents of line
Jeonghoon 3:2a3664dc6634 1 #ifndef _ROS_std_msgs_String_h
Jeonghoon 3:2a3664dc6634 2 #define _ROS_std_msgs_String_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 std_msgs
Jeonghoon 3:2a3664dc6634 10 {
Jeonghoon 3:2a3664dc6634 11
Jeonghoon 3:2a3664dc6634 12 class String : public ros::Msg
Jeonghoon 3:2a3664dc6634 13 {
Jeonghoon 3:2a3664dc6634 14 public:
Jeonghoon 3:2a3664dc6634 15 typedef const char* _data_type;
Jeonghoon 3:2a3664dc6634 16 _data_type data;
Jeonghoon 3:2a3664dc6634 17
Jeonghoon 3:2a3664dc6634 18 String():
Jeonghoon 3:2a3664dc6634 19 data("")
Jeonghoon 3:2a3664dc6634 20 {
Jeonghoon 3:2a3664dc6634 21 }
Jeonghoon 3:2a3664dc6634 22
Jeonghoon 3:2a3664dc6634 23 virtual int serialize(unsigned char *outbuffer) const
Jeonghoon 3:2a3664dc6634 24 {
Jeonghoon 3:2a3664dc6634 25 int offset = 0;
Jeonghoon 3:2a3664dc6634 26 uint32_t length_data = strlen(this->data);
Jeonghoon 3:2a3664dc6634 27 varToArr(outbuffer + offset, length_data);
Jeonghoon 3:2a3664dc6634 28 offset += 4;
Jeonghoon 3:2a3664dc6634 29 memcpy(outbuffer + offset, this->data, length_data);
Jeonghoon 3:2a3664dc6634 30 offset += length_data;
Jeonghoon 3:2a3664dc6634 31 return offset;
Jeonghoon 3:2a3664dc6634 32 }
Jeonghoon 3:2a3664dc6634 33
Jeonghoon 3:2a3664dc6634 34 virtual int deserialize(unsigned char *inbuffer)
Jeonghoon 3:2a3664dc6634 35 {
Jeonghoon 3:2a3664dc6634 36 int offset = 0;
Jeonghoon 3:2a3664dc6634 37 uint32_t length_data;
Jeonghoon 3:2a3664dc6634 38 arrToVar(length_data, (inbuffer + offset));
Jeonghoon 3:2a3664dc6634 39 offset += 4;
Jeonghoon 3:2a3664dc6634 40 for(unsigned int k= offset; k< offset+length_data; ++k){
Jeonghoon 3:2a3664dc6634 41 inbuffer[k-1]=inbuffer[k];
Jeonghoon 3:2a3664dc6634 42 }
Jeonghoon 3:2a3664dc6634 43 inbuffer[offset+length_data-1]=0;
Jeonghoon 3:2a3664dc6634 44 this->data = (char *)(inbuffer + offset-1);
Jeonghoon 3:2a3664dc6634 45 offset += length_data;
Jeonghoon 3:2a3664dc6634 46 return offset;
Jeonghoon 3:2a3664dc6634 47 }
Jeonghoon 3:2a3664dc6634 48
Jeonghoon 3:2a3664dc6634 49 const char * getType(){ return "std_msgs/String"; };
Jeonghoon 3:2a3664dc6634 50 const char * getMD5(){ return "992ce8a1687cec8c8bd883ec73ca41d1"; };
Jeonghoon 3:2a3664dc6634 51
Jeonghoon 3:2a3664dc6634 52 };
Jeonghoon 3:2a3664dc6634 53
Jeonghoon 3:2a3664dc6634 54 }
Jeonghoon 3:2a3664dc6634 55 #endif