RPC library working for the K64F

Dependents:   RPC_Serial

Fork of mbed-rpc by Mbed

Committer:
mbed_official
Date:
Tue Nov 20 17:23:59 2012 +0000
Revision:
0:efe8172b4113
Child:
1:6919289a5946
mbed RPC

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 #include "RPCFunction.h"
mbed_official 0:efe8172b4113 23
mbed_official 0:efe8172b4113 24 namespace mbed {
mbed_official 0:efe8172b4113 25
mbed_official 0:efe8172b4113 26 //Custom rpc method caller for execute so that the string will not be delimited by anything
mbed_official 0:efe8172b4113 27 void rpc_method_caller_run(RPC *this_ptr, Arguments *arguments, Reply *result) {
mbed_official 0:efe8172b4113 28 ((static_cast<RPCFunction*>(this_ptr))->run)(arguments, result);
mbed_official 0:efe8172b4113 29 }
mbed_official 0:efe8172b4113 30
mbed_official 0:efe8172b4113 31 RPCFunction::RPCFunction(void (*f)(Arguments*, Reply*), const char* name) : RPC(name) {
mbed_official 0:efe8172b4113 32 _ftr = f;
mbed_official 0:efe8172b4113 33 }
mbed_official 0:efe8172b4113 34
mbed_official 0:efe8172b4113 35 //Just run the attached function using the string thats in private memory - or just using null values,
mbed_official 0:efe8172b4113 36 void RPCFunction::run(Arguments* args, Reply* r) {
mbed_official 0:efe8172b4113 37 (*_ftr)(args, r);
mbed_official 0:efe8172b4113 38 }
mbed_official 0:efe8172b4113 39
mbed_official 0:efe8172b4113 40 const rpc_method *RPCFunction::get_rpc_methods() {
mbed_official 0:efe8172b4113 41 static const rpc_method rpc_methods[] = {
mbed_official 0:efe8172b4113 42 {"run", rpc_method_caller_run }, //Run using custom caller, all characters accepted in string
mbed_official 0:efe8172b4113 43 RPC_METHOD_SUPER(RPC)
mbed_official 0:efe8172b4113 44 };
mbed_official 0:efe8172b4113 45 return rpc_methods;
mbed_official 0:efe8172b4113 46 }
mbed_official 0:efe8172b4113 47
mbed_official 0:efe8172b4113 48 }