RTOS Support.

Dependents:   SerialRPC_rtos_example

Fork of RPCInterface by Michael Walker

Committer:
MichaelW
Date:
Thu Sep 16 13:27:57 2010 +0000
Revision:
0:9232f9e1178d
Child:
1:67aefdc74b32
Changed to RPCFunction and RPCVariable.

Who changed what in which revision?

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