orca-robotics INTRODUCTION Overview Download and Install Documentation REPOSITORY Interfaces Drivers Libraries Utilities Software Map DEVELOPER Dashboard PEOPLE Contributors Users Project Download Mailing lists
|
usbftdi.h00001 /* 00002 * Orca-Robotics Project: Components for robotics 00003 * http://orca-robotics.sf.net/ 00004 * Copyright (c) 2004-2008 Alex Brooks, Alexei Makarenko, Tobias Kaupp 00005 * 00006 * This copy of Orca is licensed to you under the terms described in 00007 * the LICENSE file included in this distribution. 00008 * 00009 */ 00010 00011 #ifndef USBFTDI_H 00012 #define USBFTDI_H 00013 00014 #include <ftd2xx.h> 00015 #include <string> 00016 #include "usbftdiexceptions.h" 00017 00018 namespace usbftdi 00019 { 00020 00021 // Return codes 00022 const int USBFTDI_OK=0; 00023 const int USBFTDI_TIMEOUT=-1; 00024 00025 00026 // 00027 // @author Alex Brooks 00028 // 00029 class UsbFtdi 00030 { 00031 00032 public: 00033 00034 // 00035 // Params are: 00036 // - Vendor ID 00037 // - Product ID 00038 // - Description (as the device reports itself) 00039 // 00040 UsbFtdi( DWORD iVID, DWORD iPID, const std::string &description, int debugLevel=0 ); 00041 ~UsbFtdi(); 00042 00043 void write( const unsigned char *data, int numBytes ); 00044 00045 // 00046 // Waits for one or more bytes to arrive 00047 // 00048 // Timeout is 100ms (TODO: this should be configurable) 00049 // 00050 // Returns: 00051 // USBFTDI_OK 00052 // USBFTDI_TIMEOUT 00053 int waitForData(); 00054 00055 int bytesInRxQueue(); 00056 00057 // Returns the number of bytes read. 00058 // Caller has the responsibility to ensure that there's enough space. 00059 int readNonBlocking( unsigned char *bytes, int maxBytesToRead ); 00060 00061 private: 00062 00063 void reset(); 00064 00065 // for debugging 00066 void printQueueStatus(); 00067 00068 // handle to the USB device 00069 FT_HANDLE ftHandle_; 00070 00071 // event handle we'll use to block on data arrival 00072 EVENT_HANDLE eventHandle_; 00073 00074 int debugLevel_; 00075 }; 00076 00077 } 00078 00079 #endif |
Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)