support to unsigned short and variable-length argument

Fork of mbed-rpc by mbed official

Committer:
va009039
Date:
Fri Feb 15 13:35:22 2013 +0000
Revision:
1:96ac4b2bbd64
Parent:
0:efe8172b4113
support to unsigned short and variable-length argument

Who changed what in which revision?

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