Trial updated library for RPCInterface. The original library by Michael Walker now includes this fix. The trial library here will be deleted shortly...

Dependents:   HTTPServerExample_LR WebServerRPC WebServerRPC_Mai19 12_06_22_correction_probleme

Committer:
hexley
Date:
Fri Feb 04 00:56:43 2011 +0000
Revision:
0:1c61049a0349
Memory leak addressed in RPCFunction.cpp

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hexley 0:1c61049a0349 1 /**
hexley 0:1c61049a0349 2 * @section LICENSE
hexley 0:1c61049a0349 3 *Copyright (c) 2010 ARM Ltd.
hexley 0:1c61049a0349 4 *
hexley 0:1c61049a0349 5 *Permission is hereby granted, free of charge, to any person obtaining a copy
hexley 0:1c61049a0349 6 *of this software and associated documentation files (the "Software"), to deal
hexley 0:1c61049a0349 7 *in the Software without restriction, including without limitation the rights
hexley 0:1c61049a0349 8 *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
hexley 0:1c61049a0349 9 *copies of the Software, and to permit persons to whom the Software is
hexley 0:1c61049a0349 10 *furnished to do so, subject to the following conditions:
hexley 0:1c61049a0349 11 *
hexley 0:1c61049a0349 12 *The above copyright notice and this permission notice shall be included in
hexley 0:1c61049a0349 13 *all copies or substantial portions of the Software.
hexley 0:1c61049a0349 14 *
hexley 0:1c61049a0349 15 *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
hexley 0:1c61049a0349 16 *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
hexley 0:1c61049a0349 17 *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
hexley 0:1c61049a0349 18 *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
hexley 0:1c61049a0349 19 *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
hexley 0:1c61049a0349 20 *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
hexley 0:1c61049a0349 21 *THE SOFTWARE.
hexley 0:1c61049a0349 22 *
hexley 0:1c61049a0349 23 *
hexley 0:1c61049a0349 24 * @section DESCRIPTION
hexley 0:1c61049a0349 25 *
hexley 0:1c61049a0349 26 *This class sets up RPC communication over serial.
hexley 0:1c61049a0349 27 */
hexley 0:1c61049a0349 28 #ifndef INTERFACE
hexley 0:1c61049a0349 29 #define INTERFACE
hexley 0:1c61049a0349 30
hexley 0:1c61049a0349 31 /**
hexley 0:1c61049a0349 32 *Includes
hexley 0:1c61049a0349 33 */
hexley 0:1c61049a0349 34 #include "mbed.h"
hexley 0:1c61049a0349 35 #include "platform.h"
hexley 0:1c61049a0349 36 #include "rpc.h"
hexley 0:1c61049a0349 37 #include "RPCFunction.h"
hexley 0:1c61049a0349 38 #include "RPCVariable.h"
hexley 0:1c61049a0349 39
hexley 0:1c61049a0349 40
hexley 0:1c61049a0349 41 namespace mbed{
hexley 0:1c61049a0349 42 /**
hexley 0:1c61049a0349 43 *Provides an Interface to mbed over RPC.
hexley 0:1c61049a0349 44 *
hexley 0:1c61049a0349 45 *For the chosen communication type this class sets up the necessary interrupts to receive RPC messages. Receives the messages, passes them to the rpc function and then returns the result.
hexley 0:1c61049a0349 46 */
hexley 0:1c61049a0349 47 class SerialRPCInterface{
hexley 0:1c61049a0349 48 public:
hexley 0:1c61049a0349 49 /**
hexley 0:1c61049a0349 50 *Constructor
hexley 0:1c61049a0349 51 *
hexley 0:1c61049a0349 52 *Sets up RPC communication using serial communication.
hexley 0:1c61049a0349 53 *
hexley 0:1c61049a0349 54 *@param tx The transmit pin of the serial port.
hexley 0:1c61049a0349 55 *@param rx The receive pin of the serial port.
hexley 0:1c61049a0349 56 *@param baud Set the baud rate, default is 9600.
hexley 0:1c61049a0349 57 */
hexley 0:1c61049a0349 58 SerialRPCInterface(PinName tx, PinName rx, int baud = 9600);
hexley 0:1c61049a0349 59
hexley 0:1c61049a0349 60 /**
hexley 0:1c61049a0349 61 *Disable the RPC.
hexley 0:1c61049a0349 62 *
hexley 0:1c61049a0349 63 *This will stop RPC messages being recevied and interpreted by this library. This might be used to prevent RPC commands interrupting an important piece of code on mbed.
hexley 0:1c61049a0349 64 */
hexley 0:1c61049a0349 65 void Disable(void);
hexley 0:1c61049a0349 66
hexley 0:1c61049a0349 67 /**
hexley 0:1c61049a0349 68 *Enable the RPC
hexley 0:1c61049a0349 69 *
hexley 0:1c61049a0349 70 *This will set this class to receiving and executing RPC commands. The class starts in this mode so this function only needs to be called if you have previosuly disabled the RPC.
hexley 0:1c61049a0349 71 *
hexley 0:1c61049a0349 72 */
hexley 0:1c61049a0349 73 void Enable(void);
hexley 0:1c61049a0349 74
hexley 0:1c61049a0349 75 //The Serial Port
hexley 0:1c61049a0349 76 Serial pc;
hexley 0:1c61049a0349 77
hexley 0:1c61049a0349 78
hexley 0:1c61049a0349 79 private:
hexley 0:1c61049a0349 80 //Handle messgaes and take appropriate action
hexley 0:1c61049a0349 81 void _MsgProcess(void);
hexley 0:1c61049a0349 82 void _RegClasses(void);
hexley 0:1c61049a0349 83 void _RPCSerial();
hexley 0:1c61049a0349 84 bool _enabled;
hexley 0:1c61049a0349 85 char _command[256];
hexley 0:1c61049a0349 86 char _response[256];
hexley 0:1c61049a0349 87 bool _RPCflag;
hexley 0:1c61049a0349 88 };
hexley 0:1c61049a0349 89 }
hexley 0:1c61049a0349 90 #endif