Learning how to use RPC.

Committer:
MichaelW
Date:
Mon Sep 27 08:32:57 2010 +0000
Revision:
4:05f0d66bee57
Parent:
1:67aefdc74b32
Child:
5:56fd0b265aba
Initial publish in new library format

Who changed what in which revision?

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