Learning how to use RPC.

Files at this revision

API Documentation at this revision

Comitter:
MichaelW
Date:
Sat Nov 27 21:00:02 2010 +0000
Parent:
4:05f0d66bee57
Child:
6:f15d3610ddbe
Commit message:
Updated Includes to include necessary includes in RPCVariable.h and RPCFunction.h

Changed in this revision

RPCFunction.h Show annotated file Show diff for this revision Revisions of this file
RPCVariable.h Show annotated file Show diff for this revision Revisions of this file
SerialRPCInterface.cpp Show annotated file Show diff for this revision Revisions of this file
SerialRPCInterface.h Show annotated file Show diff for this revision Revisions of this file
--- a/RPCFunction.h	Mon Sep 27 08:32:57 2010 +0000
+++ b/RPCFunction.h	Sat Nov 27 21:00:02 2010 +0000
@@ -1,82 +1,84 @@
- /**
-* @section LICENSE
-*Copyright (c) 2010 ARM Ltd.
-*
-*Permission is hereby granted, free of charge, to any person obtaining a copy
-*of this software and associated documentation files (the "Software"), to deal
-*in the Software without restriction, including without limitation the rights
-*to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-*copies of the Software, and to permit persons to whom the Software is
-*furnished to do so, subject to the following conditions:
-* 
-*The above copyright notice and this permission notice shall be included in
-*all copies or substantial portions of the Software.
-* 
-*THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-*IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-*FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-*AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-*LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-*OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-*THE SOFTWARE.
-* 
-* @section Description
-*This class provides an object which can be called over RPC to run the function which is attached to it.
-* 
-*/     
-#ifndef RPCFUNCTION_RPC
-#define RPCFUNCTION_RPC
-/**
-*Includes
-*/
-#include "mbed.h"
-#define STR_LEN 64
-#include "platform.h"
- 
-#ifdef MBED_RPC
-#include "rpc.h"
-#endif
-/**
-*
-*Class to call custom functions over RPC
-*
-*/
-class RPCFunction : public Base{
-public:
-    /**
-    * Constructor
-    * 
-    *@param f Pointer to the function to call. the function must be of the form void foo(char * input, char * output)
-    *@param name The name of this object
-    */
-    RPCFunction(void(*f)(char*, char*), const char* = NULL);
-
-    /** 
-    *run 
-    *
-    *Calls the attached function passing the string in but doesn't return the result.
-    *@param str The string to be passed into the attached function. This string can consist of any ASCII characters apart from escape codes. The usual limtations on argument content for RPC strings has been removed
-    *@return A string output from the function
-    */
-    char * run(char* str);
-    
-    /**
-    *Reads the value of the output string.
-    *
-    *@returns the string outputted from the last time the function was called
-    */
-    char * read();
-
-
-     #ifdef MBED_RPC
-    virtual const struct rpc_method *get_rpc_methods();      
-     #endif
-
-private:
-    void (*_ftr)(char*, char*);
-    
-    char _input[STR_LEN];
-    char _output[STR_LEN];
-    
-};
+ /**
+* @section LICENSE
+*Copyright (c) 2010 ARM Ltd.
+*
+*Permission is hereby granted, free of charge, to any person obtaining a copy
+*of this software and associated documentation files (the "Software"), to deal
+*in the Software without restriction, including without limitation the rights
+*to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+*copies of the Software, and to permit persons to whom the Software is
+*furnished to do so, subject to the following conditions:
+* 
+*The above copyright notice and this permission notice shall be included in
+*all copies or substantial portions of the Software.
+* 
+*THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+*IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+*FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+*AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+*LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+*OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+*THE SOFTWARE.
+* 
+* @section Description
+*This class provides an object which can be called over RPC to run the function which is attached to it.
+* 
+*/     
+#ifndef RPCFUNCTION_RPC
+#define RPCFUNCTION_RPC
+/**
+*Includes
+*/
+#include "mbed.h"
+#include "platform.h"
+#include "rpc.h"
+#define STR_LEN 64
+#include "platform.h"
+ 
+#ifdef MBED_RPC
+#include "rpc.h"
+#endif
+/**
+*
+*Class to call custom functions over RPC
+*
+*/
+class RPCFunction : public Base{
+public:
+    /**
+    * Constructor
+    * 
+    *@param f Pointer to the function to call. the function must be of the form void foo(char * input, char * output)
+    *@param name The name of this object
+    */
+    RPCFunction(void(*f)(char*, char*), const char* = NULL);
+
+    /** 
+    *run 
+    *
+    *Calls the attached function passing the string in but doesn't return the result.
+    *@param str The string to be passed into the attached function. This string can consist of any ASCII characters apart from escape codes. The usual limtations on argument content for RPC strings has been removed
+    *@return A string output from the function
+    */
+    char * run(char* str);
+    
+    /**
+    *Reads the value of the output string.
+    *
+    *@returns the string outputted from the last time the function was called
+    */
+    char * read();
+
+
+     #ifdef MBED_RPC
+    virtual const struct rpc_method *get_rpc_methods();      
+     #endif
+
+private:
+    void (*_ftr)(char*, char*);
+    
+    char _input[STR_LEN];
+    char _output[STR_LEN];
+    
+};
 #endif
\ No newline at end of file
--- a/RPCVariable.h	Mon Sep 27 08:32:57 2010 +0000
+++ b/RPCVariable.h	Sat Nov 27 21:00:02 2010 +0000
@@ -1,98 +1,104 @@
- /**
-* @section LICENSE
-*Copyright (c) 2010 ARM Ltd.
-*
-*Permission is hereby granted, free of charge, to any person obtaining a copy
-*of this software and associated documentation files (the "Software"), to deal
-*in the Software without restriction, including without limitation the rights
-*to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-*copies of the Software, and to permit persons to whom the Software is
-*furnished to do so, subject to the following conditions:
-* 
-*The above copyright notice and this permission notice shall be included in
-*all copies or substantial portions of the Software.
-* 
-*THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-*IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-*FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-*AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-*LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-*OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-*THE SOFTWARE.
-*
-* @section Description
-*This class provides an object to which a variable can be attached. Any type 
-*for which a parse_args function specilisation exists can be attached. This includes 
-*all of the standard types.
-*
-*/
- #ifndef RPCVARIABLE_H_  
- #define RPCVARIABLE_H_
- /**
- *Class to read and set an attached variable using the RPC
- *
- */
-template<class T>
-class RPCVariable : public Base{
-public:
-    /**
-    * Constructor
-    * 
-    *@param ptr Pointer to the variable to make accessible over RPC. Any type of 
-    *variable can be connected
-    *@param name The name of that this object will be over RPC
-    */
-    template<class A>
-    RPCVariable(A * ptr, const char * name) : Base(name){
-        _ptr = ptr;
-    }
-    /**
-    *Read the variable over RPC.
-    * 
-    *@return The value of the variable
-    */
-    T read(){
-        return(*_ptr);
-    }
-    /**
-    *Write a value to the variable over RPC
-    * 
-    *@param The value to be written to the attached variable.
-    */
-    void write(T value){
-        *_ptr = value;
-    }
-
-                                                                                   #ifdef MBED_RPC
-    virtual const struct rpc_method *get_rpc_methods();    
-    static struct rpc_class *get_rpc_class();
-                     #endif
-
-private:
-    T * _ptr;
-                                           
-};
-
-//Set up RPC methods
-#ifdef MBED_RPC
-template <class T>
-    const rpc_method *RPCVariable<T>::get_rpc_methods() {
-       static const rpc_method rpc_methods[] = {
-        { "read", rpc_method_caller<T, RPCVariable, &RPCVariable::read> },
-        { "write", rpc_method_caller<RPCVariable, T, &RPCVariable::write> },
-        RPC_METHOD_SUPER(Base)
-      };
-      return rpc_methods;
-    }       
-    template <class T>
-    rpc_class *RPCVariable<T>::get_rpc_class() {
-        static const rpc_function funcs[] = {"new", rpc_function_caller<const char*, T,const char* , &Base::construct<RemoteVar, T ,const char*> >,RPC_METHOD_END};
-        static rpc_class c = { "RPCVariable", funcs, NULL };
-        return &c;
-    }
-#endif
-
-//There could be specialisation for integer, to also give increment and decrements
-
-
+ /**
+* @section LICENSE
+*Copyright (c) 2010 ARM Ltd.
+*
+*Permission is hereby granted, free of charge, to any person obtaining a copy
+*of this software and associated documentation files (the "Software"), to deal
+*in the Software without restriction, including without limitation the rights
+*to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+*copies of the Software, and to permit persons to whom the Software is
+*furnished to do so, subject to the following conditions:
+* 
+*The above copyright notice and this permission notice shall be included in
+*all copies or substantial portions of the Software.
+* 
+*THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+*IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+*FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+*AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+*LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+*OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+*THE SOFTWARE.
+*
+* @section Description
+*This class provides an object to which a variable can be attached. Any type 
+*for which a parse_args function specilisation exists can be attached. This includes 
+*all of the standard types.
+*
+*/
+ #ifndef RPCVARIABLE_H_  
+ #define RPCVARIABLE_H_
+/** Includes
+*
+*/
+#include "mbed.h"
+#include "platform.h"
+#include "rpc.h"
+ /**
+ *Class to read and set an attached variable using the RPC
+ *
+ */
+template<class T>
+class RPCVariable : public Base{
+public:
+    /**
+    * Constructor
+    * 
+    *@param ptr Pointer to the variable to make accessible over RPC. Any type of 
+    *variable can be connected
+    *@param name The name of that this object will be over RPC
+    */
+    template<class A>
+    RPCVariable(A * ptr, const char * name) : Base(name){
+        _ptr = ptr;
+    }
+    /**
+    *Read the variable over RPC.
+    * 
+    *@return The value of the variable
+    */
+    T read(){
+        return(*_ptr);
+    }
+    /**
+    *Write a value to the variable over RPC
+    * 
+    *@param The value to be written to the attached variable.
+    */
+    void write(T value){
+        *_ptr = value;
+    }
+
+                                                                                   #ifdef MBED_RPC
+    virtual const struct rpc_method *get_rpc_methods();    
+    static struct rpc_class *get_rpc_class();
+                     #endif
+
+private:
+    T * _ptr;
+                                           
+};
+
+//Set up RPC methods
+#ifdef MBED_RPC
+template <class T>
+    const rpc_method *RPCVariable<T>::get_rpc_methods() {
+       static const rpc_method rpc_methods[] = {
+        { "read", rpc_method_caller<T, RPCVariable, &RPCVariable::read> },
+        { "write", rpc_method_caller<RPCVariable, T, &RPCVariable::write> },
+        RPC_METHOD_SUPER(Base)
+      };
+      return rpc_methods;
+    }       
+    template <class T>
+    rpc_class *RPCVariable<T>::get_rpc_class() {
+        static const rpc_function funcs[] = {"new", rpc_function_caller<const char*, T,const char* , &Base::construct<RemoteVar, T ,const char*> >,RPC_METHOD_END};
+        static rpc_class c = { "RPCVariable", funcs, NULL };
+        return &c;
+    }
+#endif
+
+//There could be specialisation for integer, to also give increment and decrements
+
+
 #endif  //RPCVARIABLE_H_
\ No newline at end of file
--- a/SerialRPCInterface.cpp	Mon Sep 27 08:32:57 2010 +0000
+++ b/SerialRPCInterface.cpp	Sat Nov 27 21:00:02 2010 +0000
@@ -1,75 +1,75 @@
- /**
-* @section LICENSE
-*Copyright (c) 2010 ARM Ltd.
-* 
-*Permission is hereby granted, free of charge, to any person obtaining a copy
-*of this software and associated documentation files (the "Software"), to deal
-*in the Software without restriction, including without limitation the rights
-*to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-*copies of the Software, and to permit persons to whom the Software is
-*furnished to do so, subject to the following conditions:
-* 
-*The above copyright notice and this permission notice shall be included in
-*all copies or substantial portions of the Software.
-* 
-*THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-*IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-*FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-*AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-*LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-*OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-*THE SOFTWARE.
-*
-* 
-* @section DESCRIPTION
-*
-*This class sets up RPC communication. This allows objects on mbed to be controlled. Objects can be created or existing objects can be used
-*/
-#include "SerialRPCInterface.h"
-
-using namespace mbed;
-
-//Requires multiple contstructors for each type, serial to set different pin numbers, TCP for port.
-SerialRPCInterface::SerialRPCInterface(PinName tx, PinName rx, int baud):pc(tx, rx) {
-    _RegClasses();
-    _enabled  = true;
-     pc.attach(this, &SerialRPCInterface::_RPCSerial, Serial::RxIrq);
-     if(baud != 9600)pc.baud(baud);
-}
-
-void SerialRPCInterface::_RegClasses(void){
-    //Register classes with base 
-    Base::add_rpc_class<AnalogIn>();
-    Base::add_rpc_class<AnalogOut>();
-    Base::add_rpc_class<DigitalIn>();
-    Base::add_rpc_class<DigitalOut>();
-    Base::add_rpc_class<DigitalInOut>();
-    Base::add_rpc_class<PwmOut>();
-    Base::add_rpc_class<Timer>();
-    Base::add_rpc_class<BusOut>();
-    Base::add_rpc_class<BusIn>();
-    Base::add_rpc_class<BusInOut>();
-    Base::add_rpc_class<Serial>();
-}
-
-void SerialRPCInterface::Disable(void){
-     _enabled = false;
- }
-void SerialRPCInterface::Enable(void){
-    _enabled = true;
-}
-void SerialRPCInterface::_MsgProcess(void) {
-    if(_enabled == true){
-        rpc(_command, _response);
-    }
-}
-
-void SerialRPCInterface::_RPCSerial() {
-    _RPCflag = true;
-    if(_enabled == true){
-        pc.gets(_command, 256);
-        _MsgProcess();
-        pc.printf("%s\n", _response);
-    }
-    _RPCflag = false;
-}
+ /**
+* @section LICENSE
+*Copyright (c) 2010 ARM Ltd.
+* 
+*Permission is hereby granted, free of charge, to any person obtaining a copy
+*of this software and associated documentation files (the "Software"), to deal
+*in the Software without restriction, including without limitation the rights
+*to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+*copies of the Software, and to permit persons to whom the Software is
+*furnished to do so, subject to the following conditions:
+* 
+*The above copyright notice and this permission notice shall be included in
+*all copies or substantial portions of the Software.
+* 
+*THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+*IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+*FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+*AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+*LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+*OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+*THE SOFTWARE.
+*
+* 
+* @section DESCRIPTION
+*
+*This class sets up RPC communication. This allows objects on mbed to be controlled. Objects can be created or existing objects can be used
+*/
+#include "SerialRPCInterface.h"
+
+using namespace mbed;
+
+//Requires multiple contstructors for each type, serial to set different pin numbers, TCP for port.
+SerialRPCInterface::SerialRPCInterface(PinName tx, PinName rx, int baud):pc(tx, rx) {
+    _RegClasses();
+    _enabled  = true;
+     pc.attach(this, &SerialRPCInterface::_RPCSerial, Serial::RxIrq);
+     if(baud != 9600)pc.baud(baud);
+}
+
+void SerialRPCInterface::_RegClasses(void){
+    //Register classes with base 
+    Base::add_rpc_class<AnalogIn>();
+    Base::add_rpc_class<AnalogOut>();
+    Base::add_rpc_class<DigitalIn>();
+    Base::add_rpc_class<DigitalOut>();
+    Base::add_rpc_class<DigitalInOut>();
+    Base::add_rpc_class<PwmOut>();
+    Base::add_rpc_class<Timer>();
+    Base::add_rpc_class<BusOut>();
+    Base::add_rpc_class<BusIn>();
+    Base::add_rpc_class<BusInOut>();
+    Base::add_rpc_class<Serial>();
+}
+
+void SerialRPCInterface::Disable(void){
+     _enabled = false;
+ }
+void SerialRPCInterface::Enable(void){
+    _enabled = true;
+}
+void SerialRPCInterface::_MsgProcess(void) {
+    if(_enabled == true){
+        rpc(_command, _response);
+    }
+}
+
+void SerialRPCInterface::_RPCSerial() {
+    _RPCflag = true;
+    if(_enabled == true){
+        pc.gets(_command, 256);
+        _MsgProcess();
+        pc.printf("%s\n", _response);
+    }
+    _RPCflag = false;
+}
--- a/SerialRPCInterface.h	Mon Sep 27 08:32:57 2010 +0000
+++ b/SerialRPCInterface.h	Sat Nov 27 21:00:02 2010 +0000
@@ -1,90 +1,90 @@
-/**
-* @section LICENSE
-*Copyright (c) 2010 ARM Ltd.
-*
-*Permission is hereby granted, free of charge, to any person obtaining a copy
-*of this software and associated documentation files (the "Software"), to deal
-*in the Software without restriction, including without limitation the rights
-*to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-*copies of the Software, and to permit persons to whom the Software is
-*furnished to do so, subject to the following conditions:
-* 
-*The above copyright notice and this permission notice shall be included in
-*all copies or substantial portions of the Software.
-* 
-*THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-*IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-*FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-*AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-*LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-*OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-*THE SOFTWARE.
-* 
-*
-* @section DESCRIPTION
-*
-*This class sets up RPC communication over serial.
-*/
-#ifndef INTERFACE
-#define INTERFACE
-
-/**
-*Includes
-*/
-#include "mbed.h"
-#include "platform.h"
-#include "rpc.h"
-#include "RPCFunction.h"
-#include "RPCVariable.h"
-
-
-namespace mbed{
-/**
-*Provides an Interface to mbed over RPC. 
-* 
-*For the chosen communication type this class sets up the necessary interrupts to receive RPC messages. Receives the messages, passes them to the rpc function and then returns the result.
-*/
-class SerialRPCInterface{
-public:
-    /**
-    *Constructor
-    *
-    *Sets up RPC communication using serial communication.
-    *
-    *@param tx The transmit pin of the serial port.
-    *@param rx The receive pin of the serial port. 
-    *@param baud Set the baud rate, default is 9600.
-    */
-    SerialRPCInterface(PinName tx, PinName rx, int baud = 9600);
- 
-    /**
-    *Disable the RPC. 
-    * 
-    *This will stop RPC messages being recevied and interpreted by this library. This might be used to prevent RPC commands interrupting an important piece of code on mbed.
-    */
-    void Disable(void);
-    
-    /**
-    *Enable the RPC
-    * 
-    *This will set this class to receiving and executing RPC commands. The class starts in this mode so this function only needs to be called if you have previosuly disabled the RPC.
-    *
-    */
-    void Enable(void);
-    
-    //The Serial Port
-    Serial pc;
-    
-
-private:
-    //Handle messgaes and take appropriate action
-    void _MsgProcess(void);
-    void _RegClasses(void);
-    void _RPCSerial();
-    bool _enabled;
-    char _command[256];
-    char _response[256];
-    bool _RPCflag;
-};
-}
+/**
+* @section LICENSE
+*Copyright (c) 2010 ARM Ltd.
+*
+*Permission is hereby granted, free of charge, to any person obtaining a copy
+*of this software and associated documentation files (the "Software"), to deal
+*in the Software without restriction, including without limitation the rights
+*to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+*copies of the Software, and to permit persons to whom the Software is
+*furnished to do so, subject to the following conditions:
+* 
+*The above copyright notice and this permission notice shall be included in
+*all copies or substantial portions of the Software.
+* 
+*THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+*IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+*FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+*AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+*LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+*OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+*THE SOFTWARE.
+* 
+*
+* @section DESCRIPTION
+*
+*This class sets up RPC communication over serial.
+*/
+#ifndef INTERFACE
+#define INTERFACE
+
+/**
+*Includes
+*/
+#include "mbed.h"
+#include "platform.h"
+#include "rpc.h"
+#include "RPCFunction.h"
+#include "RPCVariable.h"
+
+
+namespace mbed{
+/**
+*Provides an Interface to mbed over RPC. 
+* 
+*For the chosen communication type this class sets up the necessary interrupts to receive RPC messages. Receives the messages, passes them to the rpc function and then returns the result.
+*/
+class SerialRPCInterface{
+public:
+    /**
+    *Constructor
+    *
+    *Sets up RPC communication using serial communication.
+    *
+    *@param tx The transmit pin of the serial port.
+    *@param rx The receive pin of the serial port. 
+    *@param baud Set the baud rate, default is 9600.
+    */
+    SerialRPCInterface(PinName tx, PinName rx, int baud = 9600);
+ 
+    /**
+    *Disable the RPC. 
+    * 
+    *This will stop RPC messages being recevied and interpreted by this library. This might be used to prevent RPC commands interrupting an important piece of code on mbed.
+    */
+    void Disable(void);
+    
+    /**
+    *Enable the RPC
+    * 
+    *This will set this class to receiving and executing RPC commands. The class starts in this mode so this function only needs to be called if you have previosuly disabled the RPC.
+    *
+    */
+    void Enable(void);
+    
+    //The Serial Port
+    Serial pc;
+    
+
+private:
+    //Handle messgaes and take appropriate action
+    void _MsgProcess(void);
+    void _RegClasses(void);
+    void _RPCSerial();
+    bool _enabled;
+    char _command[256];
+    char _response[256];
+    bool _RPCflag;
+};
+}
 #endif
\ No newline at end of file