Committer:
PA
Date:
Thu Jun 14 08:55:27 2012 +0000
Revision:
0:a7276b35b90b

        

Who changed what in which revision?

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