This C++ library supports all the features of all the USB products except the D/A streaming features of the USB-DA12-8A product, although support for those features will be provided eventually. While the underlying AIOUSB library has been thoroughly tested, this C++ library has not yet been thoroughly tested and should be considered beta software.
/* * compile: g++ -ggdb -Wall -pthread -fPIC test.cpp ../libclassaiousbdbg.a ../../lib/libaiousbcppdbg.a -lusb-1.0 -o test * / #include <iostream> #include <iomanip> #include <USBDeviceManager.hpp> using namespace AIOUSB; using namespace std; int main( int argc, char *argv[] ) { int result = 0; USBDeviceManager deviceManager; try { deviceManager.open(); USBDeviceArray devices = deviceManager.getDeviceByProductID( USBDeviceManager::MIN_PRODUCT_ID, USBDeviceManager::MAX_PRODUCT_ID ); if( devices.size() > 0 ) { USBDevice &device = *devices.at( 0 ); cout << "Found a device with product ID " << hex << device.getProductID() << " and name \'" << device.getName() << "\'" << endl; } else cout << "No devices found" << endl; deviceManager.close(); } catch( exception &ex ) { cerr << "Error \'" << ex.what() << "\' occurred while manipulating device" << endl; result = 1; if( deviceManager.isOpen() ) deviceManager.close(); } // catch( ... return result; } // main()
The above example is obviously simplistic as well as generic. In a "real" application, one would search for devices of a specific type (i.e. product ID) and then cast instances of the generic class AIOUSB::USBDevice to a specific device class, such as AIOUSB::USB_AI16_Family.