FTD2XX.h

00001 /*-----------------------------------------------------------------------------
00002  * FTD2XX declaration
00003  * Ionetrics 2006
00004  * John Williams
00005  * FTD2XX.h
00006  *---------------------------------------------------------------------------*/
00007 
00008 #ifndef FTD2XX_H
00009 #define FTD2XX_H
00010 
00011 //-----------------------------------------------------------------------------
00012 
00013 #include <pthread.h>
00014 #include <vector>
00015 
00016 #include "AnnotatorCommApi.h"
00017 #include "FTD2XXDeviceInfo.h"
00018 #include "InputStream.h"
00019 #include "OutputStream.h"
00020 
00021 using namespace std;
00022 
00023 //-----------------------------------------------------------------------------
00024 
00025 namespace annotatorcomm
00026 {
00027 
00028 namespace ftd2xx
00029 {
00030 
00031 enum FTD2XXDataBits
00032 {
00033         FTD2XX_DATA_BITS_8 = 0,
00034         FTD2XX_DATA_BITS_7 = 2,
00035 };
00036 
00037 enum FTD2XXFlowControl
00038 {
00039         FTD2XX_FLOW_CONTROL_NONE     = 0x0000,
00040         FTD2XX_FLOW_CONTROL_RTS_CTS  = 0x0100,
00041         FTD2XX_FLOW_CONTROL_DTS_DSR  = 0x0200,
00042         FTD2XX_FLOW_CONTROL_XON_XOFF = 0x0400,
00043 };
00044 
00045 enum FTD2XXParity
00046 {
00047         FTD2XX_PARITY_NONE  = 0,
00048         FTD2XX_PARITY_ODD   = 1,
00049         FTD2XX_PARITY_EVEN  = 2,
00050         FTD2XX_PARITY_MARK  = 3,
00051         FTD2XX_PARITY_SPACE = 4,
00052 };
00053 
00054 enum FTD2XXStopBits
00055 {
00056         FTD2XX_STOP_BITS_1 = 0,
00057         FTD2XX_STOP_BITS_2 = 2,
00058 };
00059 
00082 class ANNCOMM_API FTD2XX
00083 {
00084 public:
00091         static int getNumberOfDevices() throw(IOException);
00092         
00099         static vector<FTD2XXDeviceInfo> getDeviceInfoList() throw(IOException);
00100         
00101 //      static void getDeviceInfoList(FTD2XXDeviceInfo* & list, int & length) throw(IOException);
00102         
00103 public:
00110         FTD2XX(FTD2XXDeviceInfo & info) throw(IOException);
00111         
00115         ~FTD2XX();
00116         
00123         void close() throw(IOException);
00124         
00130         FTD2XXDeviceInfo getDeviceInfo() throw(IOException);
00131         
00138         InputStream* getInputStream() throw(IOException);
00139         
00146         OutputStream* getOutputStream() throw(IOException);
00147         
00156         int read(uint8_t* buffer, int length) throw(IOException);
00157         
00166         int write(uint8_t* buffer, int length) throw(IOException);
00167         
00174         int available() throw(IOException);
00175         
00183         void setTimeouts(int rxTimeout, int txTimeout) throw(IOException);
00184         
00191         void setBaudRate(int rate) throw(IOException);
00192         
00201         void setDataCharacteristics(FTD2XXDataBits dataBits, FTD2XXStopBits stopBits, FTD2XXParity parity) throw(IOException);
00202         
00211         void setFlowControl(FTD2XXFlowControl flowControl, char xon, char xoff) throw(IOException);
00212         
00213 private:
00217         void* handle;
00218         
00222         volatile bool isOpen;
00223         
00227         InputStream* in;
00228         
00232         OutputStream* out;
00233         
00237         pthread_mutex_t mutex;
00238         
00245         void openCheck() throw(IOException);
00246 };
00247 
00248 }
00249 
00250 }
00251 
00252 //-----------------------------------------------------------------------------
00253 
00254 #endif /* FTD2XX_H */

Generated on Tue Aug 1 11:14:11 2006 for libAnnotatorComm by  doxygen 1.4.7