local fork (temporary)

Dependents:   VodafoneUSBModem_bleedingedge2

Fork of USBHostWANDongle_bleedingedge by Donatien Garnier

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers IUSBHostSerial.h Source File

IUSBHostSerial.h

00001 /* IUSBHostSerial.h */
00002 /* Copyright (c) 2010-2012 mbed.org, MIT License
00003 *
00004 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
00005 * and associated documentation files (the "Software"), to deal in the Software without
00006 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
00007 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
00008 * Software is furnished to do so, subject to the following conditions:
00009 *
00010 * The above copyright notice and this permission notice shall be included in all copies or
00011 * substantial portions of the Software.
00012 *
00013 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
00014 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00015 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
00016 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00017 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00018 */
00019 
00020 #ifndef IUSBHOSTSERIAL_H_
00021 #define IUSBHOSTSERIAL_H_
00022 
00023 /**
00024  * Generic interface to abstract 3G dongles' impl
00025  */
00026 
00027 #include "IUSBHostSerialListener.h"
00028 
00029 class IUSBHostSerial {
00030 public:
00031 
00032     enum IrqType {
00033         RxIrq,
00034         TxIrq
00035     };
00036 
00037     /*
00038     * Get a char from the dongle's serial interface
00039     */
00040     virtual int getc() = 0;
00041 
00042     /*
00043     * Put a char to the dongle's serial interface
00044     */
00045     virtual int putc(int c) = 0;
00046 
00047     /*
00048      *  Read a packet from the dongle's serial interface, to be called after multiple getc() calls
00049      */
00050     virtual int readPacket() = 0;
00051 
00052     /*
00053      *  Write a packet to the dongle's serial interface, to be called after multiple putc() calls
00054      */
00055     virtual int writePacket() = 0;
00056 
00057     /**
00058     * Check the number of bytes available.
00059     *
00060     * @returns the number of bytes available
00061     */
00062     virtual int readable() = 0;
00063 
00064     /**
00065     * Check the free space in output.
00066     *
00067     * @returns the number of bytes available
00068     */
00069     virtual int writeable() = 0;
00070 
00071     /**
00072      *  Attach a handler to call when a packet is received / when a packet has been transmitted.
00073      *
00074      *  @param pListener instance of the listener deriving from the IUSBHostSerialListener
00075      */
00076     virtual void attach(IUSBHostSerialListener* pListener) = 0;
00077 
00078     /**
00079      * Enable or disable readable/writeable callbacks
00080      */
00081     virtual void setupIrq(bool en, IrqType irq = RxIrq) = 0;
00082 
00083 };
00084 
00085 #endif /* IUSBHOSTSERIAL_H_ */