RPCInterface

Fork of RPCInterface by Michael Walker

Files at this revision

API Documentation at this revision

Comitter:
MichaelW
Date:
Mon Sep 20 14:26:52 2010 +0000
Parent:
0:9232f9e1178d
Child:
2:1d5b7485f683
Commit message:

Changed in this revision

RPCFunction.cpp Show annotated file Show diff for this revision Revisions of this file
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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/RPCFunction.cpp	Thu Sep 16 13:27:57 2010 +0000
+++ b/RPCFunction.cpp	Mon Sep 20 14:26:52 2010 +0000
@@ -1,5 +1,5 @@
 /**
-*@section LICENSE
+* @section LICENSE
 *Copyright (c) 2010 ARM Ltd.
 *
 *Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -20,7 +20,7 @@
 *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 *THE SOFTWARE.
 *
-*@section Description
+* @section Description
 *This class provides an object which can be called over RPC to run the function which is attached to it.
 *
 */      
@@ -69,26 +69,15 @@
         } 
       return res;
     }  
-    //Custom rpc method caller for run so that the string will not be delimted by anything, one argument only
-    //based on code in rpc.h
-    void rpc_method_caller_run(Base *this_ptr, const char *arguments, char *result) {
-        const char *next = arguments;
-        char * arg1 = parse_arg_char(next,NULL);
-
-        (static_cast<RPCFunction*>(this_ptr)->run)(arg1);
-        
-        if(result != NULL) {
-            result[0] = '\0';
-        }
-    }
+    
     //Custom rpc method caller for execute so that the string will not be delimited by anything
     //See line 436 of rpc.h
-    void rpc_method_caller_execute(Base *this_ptr, const char *arguments, char *result) {
+    void rpc_method_caller_run(Base *this_ptr, const char *arguments, char *result) {
     
         const char *next = arguments;
         char* arg1 = parse_arg_char(next,NULL);
         
-        char * res = (static_cast<RPCFunction*>(this_ptr)->execute)(arg1);
+        char * res = (static_cast<RPCFunction*>(this_ptr)->run)(arg1);
         if(result != NULL) {
             write_result<char*>(res, result);
         }
@@ -98,48 +87,29 @@
         _ftr = f;   
     }
     
-    //Function call which executes the packet
-    char* RPCFunction::execute(char * input){
+
+    //Just run the attached function using the string thats in private memory - or just using null values, 
+    char * RPCFunction::run(char * input){
         strcpy(_input, input);
         (*_ftr)(_input,_output);
         return(_output);
     }
-
-    //Just run the attached function using the string thats in private memory - or just using null values, 
-    void RPCFunction::run(char * str){
-        strcpy(_input, str);
-       (*_ftr)(_input,_output);
-    }
     
     //Just read the output string
     char* RPCFunction::read(){
         return(_output);
     }
-    //Just set the input string
-    void RPCFunction::write(char * str){
-        strcpy(_input, str);
-    }
     
     
     #ifdef MBED_RPC
     const rpc_method *RPCFunction::get_rpc_methods() {
        static const rpc_method rpc_methods[] = { 
-        {"execute", rpc_method_caller_execute },                                          //Run using custom caller, all character accepted in string
-        { "run", rpc_method_caller_run },                                                 //Run using custom caller, all character accepted in string
+        { "run", rpc_method_caller_run },                                                 //Run using custom caller, all characters accepted in string
         { "read", rpc_method_caller<char*, RPCFunction, &RPCFunction::read> },
-        { "write", rpc_method_caller<RPCFunction, char*, &RPCFunction::write> },
         RPC_METHOD_SUPER(Base)
       };
       return rpc_methods;
     }       
-         //creating a new one has very little meaning over RPC
-        rpc_class *RPCFunction::get_rpc_class() {
-        static const rpc_function funcs[] = { 
-            /*"new", rpc_function_caller<const char*, void(*f)(char*, char*), const char*, &Base::construct<Packet,void(*f)(char*, char*),const char*> >,*/
-            RPC_METHOD_END
-        };
-        static rpc_class c = { "RPCFunction", funcs, NULL };
-        return &c;
-    }
+
 #endif
 
--- a/RPCFunction.h	Thu Sep 16 13:27:57 2010 +0000
+++ b/RPCFunction.h	Mon Sep 20 14:26:52 2010 +0000
@@ -1,5 +1,5 @@
 /**
-*@section LICENSE
+* @section LICENSE
 *Copyright (c) 2010 ARM Ltd.
 *
 *Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -20,7 +20,7 @@
 *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 *THE SOFTWARE.
 * 
-*@section Description
+* @section Description
 *This class provides an object which can be called over RPC to run the function which is attached to it.
 * 
 */     
@@ -51,21 +51,14 @@
     */
     RPCFunction(void(*f)(char*, char*), const char* = NULL);
 
-    /**
-    *execute
+    /** 
+    *run 
     *
-    * Calls the function which is attached to this object. This method can be called over RPC. This method will wait until the attached function has completed before returning.
-    * 
-    *@param The string to be passed to the 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
+    *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* execute(char *input);
-    
-    /**
-    *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
-    */
-    void run(char* str);
+    char * run(char* str);
     
     /**
     *Reads the value of the output string.
@@ -73,20 +66,12 @@
     *@returns the string outputted from the last time the function was called
     */
     char * read();
-    /**
-    *Sets the value of the input string to the function.
-    *
-    *@param String to be written to the input string
-    */
-    void write(char * str);
+
 
      #ifdef MBED_RPC
     virtual const struct rpc_method *get_rpc_methods();      
-    static struct rpc_class *get_rpc_class();
      #endif
 
-
-
 private:
     void (*_ftr)(char*, char*);
     
--- a/RPCVariable.h	Thu Sep 16 13:27:57 2010 +0000
+++ b/RPCVariable.h	Mon Sep 20 14:26:52 2010 +0000
@@ -1,104 +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
-
-
-#endif  //RPCVARIABLE_H_
-  
-
-
-   
-       
+ /**
+* @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
+
+
+#endif  //RPCVARIABLE_H_
+  
+
+
+   
+       
        
\ No newline at end of file
--- a/SerialRPCInterface.cpp	Thu Sep 16 13:27:57 2010 +0000
+++ b/SerialRPCInterface.cpp	Mon Sep 20 14:26:52 2010 +0000
@@ -1,5 +1,5 @@
 /**
-*@section LICENSE
+* @section LICENSE
 *Copyright (c) 2010 ARM Ltd.
 * 
 *Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -21,7 +21,7 @@
 *THE SOFTWARE.
 *
 * 
-@section DESCRIPTION
+* @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
 */
--- a/SerialRPCInterface.h	Thu Sep 16 13:27:57 2010 +0000
+++ b/SerialRPCInterface.h	Mon Sep 20 14:26:52 2010 +0000
@@ -1,5 +1,5 @@
 /**
-*@section LICENSE
+* @section LICENSE
 *Copyright (c) 2010 ARM Ltd.
 *
 *Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -21,7 +21,7 @@
 *THE SOFTWARE.
 * 
 *
-@section DESCRIPTION
+* @section DESCRIPTION
 *
 *This class sets up RPC communication over serial.
 */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Sep 20 14:26:52 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e