mbed RPC

Dependents:   RPC_Serial_OVFZ RPCHTTPServer SerialRPC_rtos_example RPC_HTTP ... more

Fork of mbed-rpc by mbed official

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 #ifndef ARGUMENTS_H
mbed_official 0:efe8172b4113 23 #define ARGUMENTS_H
mbed_official 0:efe8172b4113 24
mbed_official 0:efe8172b4113 25 #include "platform.h"
mbed_official 0:efe8172b4113 26
mbed_official 0:efe8172b4113 27 namespace mbed {
mbed_official 0:efe8172b4113 28
mbed_official 0:efe8172b4113 29 #define RPC_MAX_STRING 128
mbed_official 0:efe8172b4113 30 #define RPC_MAX_ARGS 16
mbed_official 0:efe8172b4113 31
mbed_official 0:efe8172b4113 32 class Arguments {
mbed_official 0:efe8172b4113 33 public:
mbed_official 0:efe8172b4113 34 Arguments(const char* rqs);
mbed_official 0:efe8172b4113 35
mbed_official 0:efe8172b4113 36 template<typename Arg>
mbed_official 0:efe8172b4113 37 Arg getArg(void);
mbed_official 0:efe8172b4113 38
mbed_official 0:efe8172b4113 39 char *obj_name;
mbed_official 0:efe8172b4113 40 char *method_name;
mbed_official 0:efe8172b4113 41
mbed_official 0:efe8172b4113 42 int argc;
mbed_official 0:efe8172b4113 43 char* argv[RPC_MAX_ARGS];
mbed_official 0:efe8172b4113 44
mbed_official 0:efe8172b4113 45 private:
mbed_official 0:efe8172b4113 46 // This copy can be removed if we can assume the request string is
mbed_official 0:efe8172b4113 47 // persistent and writable for the duration of the call
mbed_official 0:efe8172b4113 48 char request[RPC_MAX_STRING];
mbed_official 0:efe8172b4113 49 int index;
mbed_official 0:efe8172b4113 50 char* search_arg(char **arg, char *p, char next_sep);
mbed_official 0:efe8172b4113 51 };
mbed_official 0:efe8172b4113 52
mbed_official 0:efe8172b4113 53 class Reply {
mbed_official 0:efe8172b4113 54 public:
mbed_official 0:efe8172b4113 55 Reply(char* r);
mbed_official 0:efe8172b4113 56
mbed_official 0:efe8172b4113 57 template<typename Data>
mbed_official 0:efe8172b4113 58 void putData(Data d);
mbed_official 0:efe8172b4113 59
mbed_official 0:efe8172b4113 60 private:
mbed_official 0:efe8172b4113 61 void separator(void);
mbed_official 0:efe8172b4113 62 bool first;
mbed_official 0:efe8172b4113 63 char* reply;
mbed_official 0:efe8172b4113 64 };
mbed_official 0:efe8172b4113 65
mbed_official 0:efe8172b4113 66
mbed_official 0:efe8172b4113 67 } // Namespace mbed
mbed_official 0:efe8172b4113 68
mbed_official 0:efe8172b4113 69 #endif