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

Revision:
3:1cf99502f396
Parent:
0:77afd7560544
Child:
4:684f39d0c346
--- a/dianostic_msgs/SelfTest.h	Sun Oct 16 09:35:11 2011 +0000
+++ b/dianostic_msgs/SelfTest.h	Sat Nov 12 23:54:45 2011 +0000
@@ -1,10 +1,11 @@
-#ifndef ros_SERVICE_SelfTest_h
-#define ros_SERVICE_SelfTest_h
+#ifndef _ROS_SERVICE_SelfTest_h
+#define _ROS_SERVICE_SelfTest_h
 #include <stdint.h>
 #include <string.h>
 #include <stdlib.h>
-#include "../ros/msg.h"
+#include "ros/msg.h"
 #include "diagnostic_msgs/DiagnosticStatus.h"
+#include "diagnostic_msgs/byte.h"
 
 namespace diagnostic_msgs
 {
@@ -15,7 +16,7 @@
   {
     public:
 
-    virtual int serialize(unsigned char *outbuffer)
+    virtual int serialize(unsigned char *outbuffer) const
     {
       int offset = 0;
       return offset;
@@ -27,7 +28,8 @@
      return offset;
     }
 
-    const char * getType(){ return SELFTEST; };
+    virtual const char * getType(){ return SELFTEST; };
+    virtual const char * getMD5(){ return "d41d8cd98f00b204e9800998ecf8427e"; };
 
   };
 
@@ -35,31 +37,25 @@
   {
     public:
       char * id;
-      unsigned char passed;
-      unsigned char status_length;
+      diagnostic_msgs::byte passed;
+      uint8_t status_length;
       diagnostic_msgs::DiagnosticStatus st_status;
       diagnostic_msgs::DiagnosticStatus * status;
 
-    virtual int serialize(unsigned char *outbuffer)
+    virtual int serialize(unsigned char *outbuffer) const
     {
       int offset = 0;
-      long * length_id = (long *)(outbuffer + offset);
+      uint32_t * length_id = (uint32_t *)(outbuffer + offset);
       *length_id = strlen( (const char*) this->id);
       offset += 4;
       memcpy(outbuffer + offset, this->id, *length_id);
       offset += *length_id;
-      union {
-        unsigned char real;
-        unsigned char base;
-      } u_passed;
-      u_passed.real = this->passed;
-      *(outbuffer + offset + 0) = (u_passed.base >> (8 * 0)) & 0xFF;
-      offset += sizeof(this->passed);
+      offset += this->passed.serialize(outbuffer + offset);
       *(outbuffer + offset++) = status_length;
       *(outbuffer + offset++) = 0;
       *(outbuffer + offset++) = 0;
       *(outbuffer + offset++) = 0;
-      for( unsigned char i = 0; i < status_length; i++){
+      for( uint8_t i = 0; i < status_length; i++){
       offset += this->status[i].serialize(outbuffer + offset);
       }
       return offset;
@@ -72,24 +68,17 @@
       offset += 4;
       for(unsigned int k= offset; k< offset+length_id; ++k){
           inbuffer[k-1]=inbuffer[k];
-           }
+      }
       inbuffer[offset+length_id-1]=0;
       this->id = (char *)(inbuffer + offset-1);
       offset += length_id;
-      union {
-        unsigned char real;
-        unsigned char base;
-      } u_passed;
-      u_passed.base = 0;
-      u_passed.base |= ((typeof(u_passed.base)) (*(inbuffer + offset + 0))) << (8 * 0);
-      this->passed = u_passed.real;
-      offset += sizeof(this->passed);
-      unsigned char status_lengthT = *(inbuffer + offset++);
+      offset += this->passed.deserialize(inbuffer + offset);
+      uint8_t status_lengthT = *(inbuffer + offset++);
       if(status_lengthT > status_length)
         this->status = (diagnostic_msgs::DiagnosticStatus*)realloc(this->status, status_lengthT * sizeof(diagnostic_msgs::DiagnosticStatus));
       offset += 3;
       status_length = status_lengthT;
-      for( unsigned char i = 0; i < status_length; i++){
+      for( uint8_t i = 0; i < status_length; i++){
       offset += this->st_status.deserialize(inbuffer + offset);
         memcpy( &(this->status[i]), &(this->st_status), sizeof(diagnostic_msgs::DiagnosticStatus));
       }
@@ -97,8 +86,15 @@
     }
 
     virtual const char * getType(){ return SELFTEST; };
+    virtual const char * getMD5(){ return "74c9372c870a76da4fc2b3973978b898"; };
 
   };
 
+  class SelfTest {
+    public:
+    typedef SelfTestRequest Request;
+    typedef SelfTestResponse Response;
+  };
+
 }
 #endif
\ No newline at end of file