Capstone project for Bachelor's in Mechanical Engineering 2011

Dependencies:   FatFileSystem MAX3100 MODGPS MODSERIAL SDFileSystem mbed

Committer:
lhiggs
Date:
Wed May 29 00:45:41 2013 +0000
Revision:
0:0529d2d7762f
Broken, after updating all the libraries. RPC has issues with new mbed libraries.

Who changed what in which revision?

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