mbed RPC
Embed:
(wiki syntax)
Show/hide line numbers
RPCFunction.h
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2006-2013 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #ifndef RPCFUNCTION_RPC 00017 #define RPCFUNCTION_RPC 00018 00019 #include "rpc.h" 00020 #define STR_LEN 64 00021 00022 namespace mbed { 00023 00024 /** 00025 * 00026 *Class to call custom functions over RPC 00027 * 00028 */ 00029 class RPCFunction: public RPC { 00030 public: 00031 /** 00032 * Constructor 00033 * 00034 *@param f Pointer to the function to call. the function must be of the form void foo(char * input, char * output) 00035 *@param name The name of this object 00036 */ 00037 RPCFunction(void (*f)(Arguments*, Reply*), const char* = NULL); 00038 00039 /** 00040 *run 00041 * 00042 *Calls the attached function passing the string in but doesn't return the result. 00043 *@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 00044 *@return A string output from the function 00045 */ 00046 void run(Arguments* args, Reply* r); 00047 00048 virtual const struct rpc_method *get_rpc_methods(); 00049 00050 private: 00051 void (*_ftr)(Arguments*, Reply*); 00052 00053 char _input[STR_LEN]; 00054 char _output[STR_LEN]; 00055 }; 00056 00057 } 00058 00059 #endif
Generated on Sun Jul 24 2022 15:11:06 by 1.7.2