This program is porting rosserial_arduino for mbed http://www.ros.org/wiki/rosserial_arduino This program supported the revision of 169 of rosserial.

Dependencies:  

Dependents:   rosserial_mbed robot_S2

Committer:
nucho
Date:
Wed Feb 29 23:00:21 2012 +0000
Revision:
4:684f39d0c346
Parent:
3:1cf99502f396

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nucho 3:1cf99502f396 1 #ifndef _ROS_std_msgs_ByteMultiArray_h
nucho 3:1cf99502f396 2 #define _ROS_std_msgs_ByteMultiArray_h
nucho 3:1cf99502f396 3
nucho 3:1cf99502f396 4 #include <stdint.h>
nucho 3:1cf99502f396 5 #include <string.h>
nucho 3:1cf99502f396 6 #include <stdlib.h>
nucho 3:1cf99502f396 7 #include "ros/msg.h"
nucho 3:1cf99502f396 8 #include "std_msgs/MultiArrayLayout.h"
nucho 3:1cf99502f396 9 #include "std_msgs/byte.h"
nucho 3:1cf99502f396 10
nucho 3:1cf99502f396 11 namespace std_msgs
nucho 3:1cf99502f396 12 {
nucho 3:1cf99502f396 13
nucho 3:1cf99502f396 14 class ByteMultiArray : public ros::Msg
nucho 3:1cf99502f396 15 {
nucho 3:1cf99502f396 16 public:
nucho 3:1cf99502f396 17 std_msgs::MultiArrayLayout layout;
nucho 3:1cf99502f396 18 uint8_t data_length;
nucho 3:1cf99502f396 19 std_msgs::byte st_data;
nucho 3:1cf99502f396 20 std_msgs::byte * data;
nucho 3:1cf99502f396 21
nucho 3:1cf99502f396 22 virtual int serialize(unsigned char *outbuffer) const
nucho 3:1cf99502f396 23 {
nucho 3:1cf99502f396 24 int offset = 0;
nucho 3:1cf99502f396 25 offset += this->layout.serialize(outbuffer + offset);
nucho 3:1cf99502f396 26 *(outbuffer + offset++) = data_length;
nucho 3:1cf99502f396 27 *(outbuffer + offset++) = 0;
nucho 3:1cf99502f396 28 *(outbuffer + offset++) = 0;
nucho 3:1cf99502f396 29 *(outbuffer + offset++) = 0;
nucho 3:1cf99502f396 30 for( uint8_t i = 0; i < data_length; i++){
nucho 3:1cf99502f396 31 offset += this->data[i].serialize(outbuffer + offset);
nucho 3:1cf99502f396 32 }
nucho 3:1cf99502f396 33 return offset;
nucho 3:1cf99502f396 34 }
nucho 3:1cf99502f396 35
nucho 3:1cf99502f396 36 virtual int deserialize(unsigned char *inbuffer)
nucho 3:1cf99502f396 37 {
nucho 3:1cf99502f396 38 int offset = 0;
nucho 3:1cf99502f396 39 offset += this->layout.deserialize(inbuffer + offset);
nucho 3:1cf99502f396 40 uint8_t data_lengthT = *(inbuffer + offset++);
nucho 3:1cf99502f396 41 if(data_lengthT > data_length)
nucho 3:1cf99502f396 42 this->data = (std_msgs::byte*)realloc(this->data, data_lengthT * sizeof(std_msgs::byte));
nucho 3:1cf99502f396 43 offset += 3;
nucho 3:1cf99502f396 44 data_length = data_lengthT;
nucho 3:1cf99502f396 45 for( uint8_t i = 0; i < data_length; i++){
nucho 3:1cf99502f396 46 offset += this->st_data.deserialize(inbuffer + offset);
nucho 3:1cf99502f396 47 memcpy( &(this->data[i]), &(this->st_data), sizeof(std_msgs::byte));
nucho 3:1cf99502f396 48 }
nucho 3:1cf99502f396 49 return offset;
nucho 3:1cf99502f396 50 }
nucho 3:1cf99502f396 51
nucho 3:1cf99502f396 52 virtual const char * getType(){ return "std_msgs/ByteMultiArray"; };
nucho 3:1cf99502f396 53 virtual const char * getMD5(){ return "70ea476cbcfd65ac2f68f3cda1e891fe"; };
nucho 3:1cf99502f396 54
nucho 3:1cf99502f396 55 };
nucho 3:1cf99502f396 56
nucho 3:1cf99502f396 57 }
nucho 0:77afd7560544 58 #endif