RPCInterface

Fork of RPCInterface by Michael Walker

Committer:
MichaelW
Date:
Mon Sep 20 14:29:18 2010 +0000
Revision:
2:1d5b7485f683
Parent:
1:67aefdc74b32
Child:
4:05f0d66bee57

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MichaelW 2:1d5b7485f683 1 /**
MichaelW 1:67aefdc74b32 2 * @section LICENSE
MichaelW 0:9232f9e1178d 3 *Copyright (c) 2010 ARM Ltd.
MichaelW 0:9232f9e1178d 4 *
MichaelW 0:9232f9e1178d 5 *Permission is hereby granted, free of charge, to any person obtaining a copy
MichaelW 0:9232f9e1178d 6 *of this software and associated documentation files (the "Software"), to deal
MichaelW 0:9232f9e1178d 7 *in the Software without restriction, including without limitation the rights
MichaelW 0:9232f9e1178d 8 *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
MichaelW 0:9232f9e1178d 9 *copies of the Software, and to permit persons to whom the Software is
MichaelW 0:9232f9e1178d 10 *furnished to do so, subject to the following conditions:
MichaelW 0:9232f9e1178d 11 *
MichaelW 0:9232f9e1178d 12 *The above copyright notice and this permission notice shall be included in
MichaelW 0:9232f9e1178d 13 *all copies or substantial portions of the Software.
MichaelW 0:9232f9e1178d 14 *
MichaelW 0:9232f9e1178d 15 *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
MichaelW 0:9232f9e1178d 16 *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
MichaelW 0:9232f9e1178d 17 *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
MichaelW 0:9232f9e1178d 18 *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
MichaelW 0:9232f9e1178d 19 *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
MichaelW 0:9232f9e1178d 20 *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
MichaelW 0:9232f9e1178d 21 *THE SOFTWARE.
MichaelW 0:9232f9e1178d 22 *
MichaelW 1:67aefdc74b32 23 * @section Description
MichaelW 0:9232f9e1178d 24 *This class provides an object which can be called over RPC to run the function which is attached to it.
MichaelW 0:9232f9e1178d 25 *
MichaelW 0:9232f9e1178d 26 */
MichaelW 0:9232f9e1178d 27 #ifndef RPCFUNCTION_RPC
MichaelW 0:9232f9e1178d 28 #define RPCFUNCTION_RPC
MichaelW 0:9232f9e1178d 29 /**
MichaelW 0:9232f9e1178d 30 *Includes
MichaelW 0:9232f9e1178d 31 */
MichaelW 0:9232f9e1178d 32 #include "mbed.h"
MichaelW 0:9232f9e1178d 33 #define STR_LEN 64
MichaelW 0:9232f9e1178d 34 #include "platform.h"
MichaelW 0:9232f9e1178d 35
MichaelW 0:9232f9e1178d 36 #ifdef MBED_RPC
MichaelW 0:9232f9e1178d 37 #include "rpc.h"
MichaelW 0:9232f9e1178d 38 #endif
MichaelW 0:9232f9e1178d 39 /**
MichaelW 0:9232f9e1178d 40 *
MichaelW 0:9232f9e1178d 41 *Class to call custom functions over RPC
MichaelW 0:9232f9e1178d 42 *
MichaelW 0:9232f9e1178d 43 */
MichaelW 0:9232f9e1178d 44 class RPCFunction : public Base{
MichaelW 0:9232f9e1178d 45 public:
MichaelW 0:9232f9e1178d 46 /**
MichaelW 0:9232f9e1178d 47 * Constructor
MichaelW 0:9232f9e1178d 48 *
MichaelW 0:9232f9e1178d 49 *@param f Pointer to the function to call. the function must be of the form void foo(char * input, char * output)
MichaelW 0:9232f9e1178d 50 *@param name The name of this object
MichaelW 0:9232f9e1178d 51 */
MichaelW 0:9232f9e1178d 52 RPCFunction(void(*f)(char*, char*), const char* = NULL);
MichaelW 0:9232f9e1178d 53
MichaelW 1:67aefdc74b32 54 /**
MichaelW 1:67aefdc74b32 55 *run
MichaelW 0:9232f9e1178d 56 *
MichaelW 1:67aefdc74b32 57 *Calls the attached function passing the string in but doesn't return the result.
MichaelW 1:67aefdc74b32 58 *@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
MichaelW 0:9232f9e1178d 59 *@return A string output from the function
MichaelW 0:9232f9e1178d 60 */
MichaelW 1:67aefdc74b32 61 char * run(char* str);
MichaelW 0:9232f9e1178d 62
MichaelW 0:9232f9e1178d 63 /**
MichaelW 0:9232f9e1178d 64 *Reads the value of the output string.
MichaelW 0:9232f9e1178d 65 *
MichaelW 0:9232f9e1178d 66 *@returns the string outputted from the last time the function was called
MichaelW 0:9232f9e1178d 67 */
MichaelW 0:9232f9e1178d 68 char * read();
MichaelW 1:67aefdc74b32 69
MichaelW 0:9232f9e1178d 70
MichaelW 0:9232f9e1178d 71 #ifdef MBED_RPC
MichaelW 0:9232f9e1178d 72 virtual const struct rpc_method *get_rpc_methods();
MichaelW 0:9232f9e1178d 73 #endif
MichaelW 0:9232f9e1178d 74
MichaelW 0:9232f9e1178d 75 private:
MichaelW 0:9232f9e1178d 76 void (*_ftr)(char*, char*);
MichaelW 0:9232f9e1178d 77
MichaelW 0:9232f9e1178d 78 char _input[STR_LEN];
MichaelW 0:9232f9e1178d 79 char _output[STR_LEN];
MichaelW 0:9232f9e1178d 80
MichaelW 0:9232f9e1178d 81 };
MichaelW 0:9232f9e1178d 82 #endif