int main( int argc, char *argv[] ) { struct sigaction sigact; int rval = 0; sigact.sa_handler = sighandler; sigemptyset(&sigact.sa_mask); sigact.sa_flags = 0; sigaction(SIGINT, &sigact, NULL); sigaction(SIGTERM, &sigact, NULL); sigaction(SIGQUIT, &sigact, NULL); using namespace USB; DeviceManager mgr; theMgr = &mgr; try { mgr.registerDevice( SpacePilotDevice::VendorID, SpacePilotDevice::ProductID, &SpacePilotDevice::factory ); mgr.start(); if ( argc > 1 ) { std::shared_ptr<Device> sppro = mgr.findDevice( SpacePilotDevice::VendorID, SpacePilotDevice::ProductID ); if ( sppro ) { SpacePilotDevice *dev = reinterpret_cast<SpacePilotDevice *>( sppro.get() ); dev->setLCD( std::string( argv[1] ) ); } } mgr.processEventLoop(); } catch ( usb_error &e ) { int err = e.getUSBError(); libusb_error ec = (libusb_error)( err ); std::cerr << "ERROR: " << libusb_error_name( err ) << " - " << libusb_strerror( ec ) << std::endl; rval = -1; } catch ( ... ) { rval = -1; } mgr.shutdown(); theMgr = nullptr; return rval; }
void com_service::start() { DeviceManager* devmgr = DeviceManager::getInstance(loop_); devmgr->start(); }