RPCInterface

Fork of RPCInterface by Michael Walker

Committer:
MichaelW
Date:
Mon Sep 27 08:32:57 2010 +0000
Revision:
4:05f0d66bee57
Parent:
2:1d5b7485f683
Child:
5:56fd0b265aba
Initial publish in new library format

Who changed what in which revision?

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