project wireless

Dependencies:   mbed nRF24L01P nRF24L01P_Hello_World TextLCD

Fork of nRF24L01P_Hello_World by Owen Edwards

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SerialRPCInterface.h Source File

SerialRPCInterface.h

00001 /**
00002 * @section LICENSE
00003 *Copyright (c) 2010 ARM Ltd.
00004 *
00005 *Permission is hereby granted, free of charge, to any person obtaining a copy
00006 *of this software and associated documentation files (the "Software"), to deal
00007 *in the Software without restriction, including without limitation the rights
00008 *to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00009 *copies of the Software, and to permit persons to whom the Software is
00010 *furnished to do so, subject to the following conditions:
00011 * 
00012 *The above copyright notice and this permission notice shall be included in
00013 *all copies or substantial portions of the Software.
00014 * 
00015 *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00016 *IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00017 *FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00018 *AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00019 *LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00020 *OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00021 *THE SOFTWARE.
00022 * 
00023 *
00024 * @section DESCRIPTION
00025 *
00026 *This class sets up RPC communication over serial.
00027 */
00028 #ifndef INTERFACE
00029 #define INTERFACE
00030 
00031 /**
00032 *Includes
00033 */
00034 #include "mbed.h"
00035 #include "platform.h"
00036 #include "rpc.h"
00037 #include "RPCFunction.h"
00038 #include "RPCVariable.h"
00039 
00040 
00041 namespace mbed{
00042 /**
00043 *Provides an Interface to mbed over RPC. 
00044 * 
00045 *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.
00046 */
00047 class SerialRPCInterface{
00048 public:
00049     /**
00050     *Constructor
00051     *
00052     *Sets up RPC communication using serial communication.
00053     *
00054     *@param tx The transmit pin of the serial port.
00055     *@param rx The receive pin of the serial port. 
00056     *@param baud Set the baud rate, default is 9600.
00057     */
00058     SerialRPCInterface(PinName tx, PinName rx, int baud = 9600);
00059  
00060     /**
00061     *Disable the RPC. 
00062     * 
00063     *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.
00064     */
00065     void Disable(void);
00066     
00067     /**
00068     *Enable the RPC
00069     * 
00070     *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.
00071     *
00072     */
00073     void Enable(void);
00074     
00075     //The Serial Port
00076     Serial pc;
00077     
00078 
00079 private:
00080     //Handle messgaes and take appropriate action
00081     void _MsgProcess(void);
00082     void _RegClasses(void);
00083     void _RPCSerial();
00084     bool _enabled;
00085     char _command[256];
00086     char _response[256];
00087     bool _RPCflag;
00088 };
00089 }
00090 #endif