From: Mark Cannon Date: Wed, 13 Feb 2008 18:35:14 +0000 (+0000) Subject: git-svn-id: https://openitg.svn.sourceforge.net/svnroot/openitg@21 83fadc84-e282... X-Git-Url: http://cameron1729.xyz/?a=commitdiff_plain;h=6f240086ea49bd3ebb2e77e1112dc478197f515f;p=openitg.git git-svn-id: https://openitg.svn.sourceforge.net/svnroot/openitg@21 83fadc84-e282-4d84-a09a-c4228d6ae7e5 --- diff --git a/src/arch/InputHandler/InputHandler_Linux_PIUIO.cpp b/src/arch/InputHandler/InputHandler_Linux_PIUIO.cpp index 64870a9f..ed695f36 100644 --- a/src/arch/InputHandler/InputHandler_Linux_PIUIO.cpp +++ b/src/arch/InputHandler/InputHandler_Linux_PIUIO.cpp @@ -1,5 +1,6 @@ #include "global.h" #include "RageLog.h" +#include "RageException.h" #include "LightsManager.h" #include "arch/Lights/LightsDriver_External.h" // needed for g_LightsState @@ -15,6 +16,7 @@ InputHandler_Linux_PIUIO::InputHandler_Linux_PIUIO() // device found and set if( IOBoard.Open() ) { + LOG->Trace( "Opened I/O board." ); m_bFoundDevice = true; InputThread.SetName( "PIUIO thread" ); @@ -22,7 +24,7 @@ InputHandler_Linux_PIUIO::InputHandler_Linux_PIUIO() } else { - LOG->Warn( "InputHandler_Linux_PIUIO: could not open I/O board." ); + sm_crash( "InputHandler_Linux_PIUIO: Failed to open PIU I/O board." ); } } @@ -57,9 +59,12 @@ int InputHandler_Linux_PIUIO::InputThread_Start( void *p ) void InputHandler_Linux_PIUIO::InputThreadMain() { - /* For now, we just want to test lights updates. */ - UpdateLights(); - IOBoard.Write( m_iLightData ); + while( !m_bShutdown ) + { + /* For now, we just want to test lights updates. */ + UpdateLights(); + IOBoard.Write( m_iLightData ); + } } void InputHandler_Linux_PIUIO::UpdateLights() diff --git a/src/io/PIUIO.cpp b/src/io/PIUIO.cpp index a31bf93d..a87d8ff7 100644 --- a/src/io/PIUIO.cpp +++ b/src/io/PIUIO.cpp @@ -3,16 +3,13 @@ #include "USBDevice.h" #include "PIUIO.h" -PIUIO::PIUIO() -{ - Open(); -} - bool PIUIO::Matches( int idVendor, int idProduct ) { if( idVendor == 0x547 && idProduct == 0x1002 ) return true; + LOG->Trace( "Not a match. idVendor %u, idProduct %u", idVendor, idProduct ); + return false; } diff --git a/src/io/PIUIO.h b/src/io/PIUIO.h index e8a85777..340b679e 100644 --- a/src/io/PIUIO.h +++ b/src/io/PIUIO.h @@ -7,8 +7,6 @@ class PIUIO: public USBDriver { public: - PIUIO(); - bool Read( uint32_t *pData ); bool Write( uint32_t iData ); diff --git a/src/io/USBDriver.cpp b/src/io/USBDriver.cpp index f18e7528..cdf35c78 100644 --- a/src/io/USBDriver.cpp +++ b/src/io/USBDriver.cpp @@ -6,10 +6,14 @@ USBDriver::USBDriver() { + LOG->Trace( "USBDriver::USBDriver()" ); + m_pHandle = NULL; // work around segfault + usb_init(); } USBDriver::~USBDriver() { + LOG->Trace( "USBDriver::~USBDriver()" ); Close(); } @@ -19,20 +23,28 @@ bool USBDriver::Matches( int idVendor, int idProduct ) return false; } -struct usb_device *USBDriver::FindDevice() +struct usb_device *USBDriver::FindDevice( usb_bus *usb_busses ) { - for( usb_bus *bus = usb_get_busses(); bus; bus->next ) - for( struct usb_device *dev = bus->devices; dev; dev->next ) + LOG->Trace( "USBDriver::FindDevice()." ); + + for( usb_bus *bus = usb_busses; bus; bus = bus->next ) + for( struct usb_device *dev = bus->devices; dev; dev = dev->next ) if( Matches(dev->descriptor.idVendor, dev->descriptor.idProduct) ) + { + LOG->Trace( "FindDevice() got a match." ); return dev; + } // fall through + LOG->Trace( "FindDevice() found no matches." ); return NULL; } void USBDriver::Close() { - // already closed + LOG->Trace( "USBDriver::Close()" ); + + // never opened if( m_pHandle == NULL ) return; @@ -44,9 +56,12 @@ void USBDriver::Close() bool USBDriver::Open() { + LOG->Trace( "USBDriver::Open()" ); Close(); + LOG->Trace( "Attempting to usb_init()." ); usb_init(); + LOG->Trace( "USB subsystem successfully initialized." ); if( usb_find_busses() < 0 ) { @@ -54,28 +69,29 @@ bool USBDriver::Open() return false; } + LOG->Trace( "usb_find_busses successful." ); + if( usb_find_devices() < 0 ) { LOG->Warn( "usb_find_devices: %s", usb_strerror() ); return false; } - - if( !usb_busses ) - { - LOG->Warn( "usb_busses: %s", usb_strerror() ); - return false; - } + + LOG->Trace( "usb_find_devices successful." ); // set the device - struct usb_device *device = FindDevice(); + struct usb_device *device = FindDevice( usb_busses ); + + LOG->Trace( "device set." ); if( device == NULL ) { LOG->Warn( "USBDriver: could not set usb_device" ); return false; } - + m_pHandle = usb_open( device ); + if( m_pHandle == NULL ) { LOG->Warn( "usb_open: %s", usb_strerror() ); diff --git a/src/io/USBDriver.h b/src/io/USBDriver.h index c4b73192..31296984 100644 --- a/src/io/USBDriver.h +++ b/src/io/USBDriver.h @@ -13,7 +13,7 @@ public: bool Open(); void Close(); protected: - struct usb_device *FindDevice(); + struct usb_device *FindDevice( usb_bus *usb_busses ); virtual bool Matches( int idVendor, int idProduct );