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