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:
1:ff0ec969dad1
--- a/ros/service_server.h	Sun Oct 16 09:35:11 2011 +0000
+++ b/ros/service_server.h	Sat Nov 12 23:54:45 2011 +0000
@@ -32,46 +32,41 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef ROS_SERVICE_SERVER_H_
-#define ROS_SERVICE_SERVER_H_
+#ifndef _ROS_SERVICE_SERVER_H_
+#define _ROS_SERVICE_SERVER_H_
 
-#include "node_output.h"
+#include "rosserial_msgs/TopicInfo.h"
+
+#include "publisher.h"
+#include "subscriber.h"
 
 namespace ros {
 
-  template<typename SrvRequest , typename SrvResponse>
-  class ServiceServer : MsgReceiver{
+  template<typename MReq , typename MRes>
+  class ServiceServer : public Subscriber_ {
     public:
-      typedef void(*CallbackT)(const SrvRequest&,  SrvResponse&);
+      typedef void(*CallbackT)(const MReq&,  MRes&);
 
-      ServiceServer(const char* topic_name, CallbackT cb){
+      ServiceServer(const char* topic_name, CallbackT cb) :
+        pub(topic_name, &resp, rosserial_msgs::TopicInfo::ID_SERVICE_SERVER + rosserial_msgs::TopicInfo::ID_PUBLISHER)
+      {
         this->topic_ = topic_name;
         this->cb_ = cb;
       }
 
-      ServiceServer(ServiceServer& srv){
-        this->topic_ = srv.topic_;
-        this->cb_ = srv.cb_;
+      // these refer to the subscriber
+      virtual void callback(unsigned char *data){
+        req.deserialize(data);
+        cb_(req,resp);
+        pub.publish(&resp);
       }
-
-      virtual void receive(unsigned char * data){
-        req.deserialize(data);
-        this->cb_(req, resp);
-        no_->publish(id_, &resp);
-      }
+      virtual const char * getMsgType(){ return this->req.getType(); }
+      virtual const char * getMsgMD5(){ return this->req.getMD5(); }
+      virtual int getEndpointType(){ return rosserial_msgs::TopicInfo::ID_SERVICE_SERVER + rosserial_msgs::TopicInfo::ID_SUBSCRIBER; }
 
-      virtual int _getType(){
-        return 3;
-      }
-     
-      virtual const char * getMsgType(){
-        return req.getType();
-      }
-
-      SrvRequest req;
-      SrvResponse resp;
-      NodeOutput_ * no_;
-
+      MReq req;
+      MRes resp;
+      Publisher pub;
     private:
       CallbackT cb_;
   };