nkjnm
Dependencies: MAX44000 nexpaq_mdk
Fork of LED_Demo by
mbd_os/libraries/rpc/RPCFunction.h@7:3a65ef12ba31, 2016-11-04 (annotated)
- Committer:
- nitsshukla
- Date:
- Fri Nov 04 12:06:04 2016 +0000
- Revision:
- 7:3a65ef12ba31
- Parent:
- 1:55a6170b404f
kghj;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nexpaq | 1:55a6170b404f | 1 | /* mbed Microcontroller Library |
nexpaq | 1:55a6170b404f | 2 | * Copyright (c) 2006-2013 ARM Limited |
nexpaq | 1:55a6170b404f | 3 | * |
nexpaq | 1:55a6170b404f | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
nexpaq | 1:55a6170b404f | 5 | * you may not use this file except in compliance with the License. |
nexpaq | 1:55a6170b404f | 6 | * You may obtain a copy of the License at |
nexpaq | 1:55a6170b404f | 7 | * |
nexpaq | 1:55a6170b404f | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
nexpaq | 1:55a6170b404f | 9 | * |
nexpaq | 1:55a6170b404f | 10 | * Unless required by applicable law or agreed to in writing, software |
nexpaq | 1:55a6170b404f | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
nexpaq | 1:55a6170b404f | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
nexpaq | 1:55a6170b404f | 13 | * See the License for the specific language governing permissions and |
nexpaq | 1:55a6170b404f | 14 | * limitations under the License. |
nexpaq | 1:55a6170b404f | 15 | */ |
nexpaq | 1:55a6170b404f | 16 | #ifndef RPCFUNCTION_RPC |
nexpaq | 1:55a6170b404f | 17 | #define RPCFUNCTION_RPC |
nexpaq | 1:55a6170b404f | 18 | |
nexpaq | 1:55a6170b404f | 19 | #include "rpc.h" |
nexpaq | 1:55a6170b404f | 20 | #define STR_LEN 64 |
nexpaq | 1:55a6170b404f | 21 | |
nexpaq | 1:55a6170b404f | 22 | namespace mbed { |
nexpaq | 1:55a6170b404f | 23 | |
nexpaq | 1:55a6170b404f | 24 | /** |
nexpaq | 1:55a6170b404f | 25 | * |
nexpaq | 1:55a6170b404f | 26 | *Class to call custom functions over RPC |
nexpaq | 1:55a6170b404f | 27 | * |
nexpaq | 1:55a6170b404f | 28 | */ |
nexpaq | 1:55a6170b404f | 29 | class RPCFunction: public RPC { |
nexpaq | 1:55a6170b404f | 30 | public: |
nexpaq | 1:55a6170b404f | 31 | /** |
nexpaq | 1:55a6170b404f | 32 | * Constructor |
nexpaq | 1:55a6170b404f | 33 | * |
nexpaq | 1:55a6170b404f | 34 | *@param f Pointer to the function to call. the function must be of the form void foo(char * input, char * output) |
nexpaq | 1:55a6170b404f | 35 | *@param name The name of this object |
nexpaq | 1:55a6170b404f | 36 | */ |
nexpaq | 1:55a6170b404f | 37 | RPCFunction(void (*f)(Arguments*, Reply*), const char* = NULL); |
nexpaq | 1:55a6170b404f | 38 | |
nexpaq | 1:55a6170b404f | 39 | /** |
nexpaq | 1:55a6170b404f | 40 | *run |
nexpaq | 1:55a6170b404f | 41 | * |
nexpaq | 1:55a6170b404f | 42 | *Calls the attached function passing the string in but doesn't return the result. |
nexpaq | 1:55a6170b404f | 43 | *@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 |
nexpaq | 1:55a6170b404f | 44 | *@return A string output from the function |
nexpaq | 1:55a6170b404f | 45 | */ |
nexpaq | 1:55a6170b404f | 46 | void run(Arguments* args, Reply* r); |
nexpaq | 1:55a6170b404f | 47 | |
nexpaq | 1:55a6170b404f | 48 | virtual const struct rpc_method *get_rpc_methods(); |
nexpaq | 1:55a6170b404f | 49 | |
nexpaq | 1:55a6170b404f | 50 | private: |
nexpaq | 1:55a6170b404f | 51 | void (*_ftr)(Arguments*, Reply*); |
nexpaq | 1:55a6170b404f | 52 | |
nexpaq | 1:55a6170b404f | 53 | char _input[STR_LEN]; |
nexpaq | 1:55a6170b404f | 54 | char _output[STR_LEN]; |
nexpaq | 1:55a6170b404f | 55 | }; |
nexpaq | 1:55a6170b404f | 56 | |
nexpaq | 1:55a6170b404f | 57 | } |
nexpaq | 1:55a6170b404f | 58 | |
nexpaq | 1:55a6170b404f | 59 | #endif |