mbed-os

Dependents:   cobaLCDJoyMotor_Thread odometry_omni_3roda_v3 odometry_omni_3roda_v1 odometry_omni_3roda_v2 ... more

Committer:
be_bryan
Date:
Mon Dec 11 17:54:04 2017 +0000
Revision:
0:b74591d5ab33
motor ++

Who changed what in which revision?

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