Customized RPCInterface

Fork of RPCInterface by Michael Walker

Committer:
komoritan
Date:
Sat Feb 14 00:22:14 2015 +0000
Revision:
9:bd489829706b
Parent:
5:56fd0b265aba
Fixed

Who changed what in which revision?

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