diff --git a/Desktop_Interface/bin/labrador.app/Contents/MacOS/Labrador b/Desktop_Interface/bin/labrador.app/Contents/MacOS/Labrador index 95c981d7..c1c1409c 100755 Binary files a/Desktop_Interface/bin/labrador.app/Contents/MacOS/Labrador and b/Desktop_Interface/bin/labrador.app/Contents/MacOS/Labrador differ diff --git a/Desktop_Interface/mainwindow.cpp b/Desktop_Interface/mainwindow.cpp index 91193664..8b11a7cd 100644 --- a/Desktop_Interface/mainwindow.cpp +++ b/Desktop_Interface/mainwindow.cpp @@ -1073,7 +1073,7 @@ void MainWindow::reinitUsb(void){ reinitUsbStage2(); #else ui->controller_iso->driver->shutdownProcedure(); - QTimer::singleShot(2000, this, SLOT(reinitUsbStage2())); + QTimer::singleShot(3000, this, SLOT(reinitUsbStage2())); #endif qDebug() << "ReinitUsb Stage 1 complete"; } diff --git a/Desktop_Interface/mainwindow.o b/Desktop_Interface/mainwindow.o index 3c96c8c6..51303d7f 100644 Binary files a/Desktop_Interface/mainwindow.o and b/Desktop_Interface/mainwindow.o differ diff --git a/Desktop_Interface/moc/moc_unixusbdriver.cpp b/Desktop_Interface/moc/moc_unixusbdriver.cpp index 20b9c000..6a56d7a7 100644 --- a/Desktop_Interface/moc/moc_unixusbdriver.cpp +++ b/Desktop_Interface/moc/moc_unixusbdriver.cpp @@ -109,8 +109,8 @@ int worker::qt_metacall(QMetaObject::Call _c, int _id, void **_a) return _id; } struct qt_meta_stringdata_unixUsbDriver_t { - QByteArrayData data[5]; - char stringdata0[59]; + QByteArrayData data[6]; + char stringdata0[73]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ @@ -123,11 +123,12 @@ QT_MOC_LITERAL(0, 0, 13), // "unixUsbDriver" QT_MOC_LITERAL(1, 14, 12), // "isoTimerTick" QT_MOC_LITERAL(2, 27, 0), // "" QT_MOC_LITERAL(3, 28, 12), // "recoveryTick" -QT_MOC_LITERAL(4, 41, 17) // "shutdownProcedure" +QT_MOC_LITERAL(4, 41, 17), // "shutdownProcedure" +QT_MOC_LITERAL(5, 59, 13) // "backupCleanup" }, "unixUsbDriver\0isoTimerTick\0\0recoveryTick\0" - "shutdownProcedure" + "shutdownProcedure\0backupCleanup" }; #undef QT_MOC_LITERAL @@ -137,7 +138,7 @@ static const uint qt_meta_data_unixUsbDriver[] = { 7, // revision 0, // classname 0, 0, // classinfo - 3, 14, // methods + 4, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors @@ -145,13 +146,15 @@ static const uint qt_meta_data_unixUsbDriver[] = { 0, // signalCount // slots: name, argc, parameters, tag, flags - 1, 0, 29, 2, 0x0a /* Public */, - 3, 0, 30, 2, 0x0a /* Public */, - 4, 0, 31, 2, 0x0a /* Public */, + 1, 0, 34, 2, 0x0a /* Public */, + 3, 0, 35, 2, 0x0a /* Public */, + 4, 0, 36, 2, 0x0a /* Public */, + 5, 0, 37, 2, 0x0a /* Public */, // slots: parameters QMetaType::Void, QMetaType::Void, + QMetaType::Void, QMetaType::Void, 0 // eod @@ -166,6 +169,7 @@ void unixUsbDriver::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _i case 0: _t->isoTimerTick(); break; case 1: _t->recoveryTick(); break; case 2: _t->shutdownProcedure(); break; + case 3: _t->backupCleanup(); break; default: ; } } @@ -197,13 +201,13 @@ int unixUsbDriver::qt_metacall(QMetaObject::Call _c, int _id, void **_a) if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { - if (_id < 3) + if (_id < 4) qt_static_metacall(this, _c, _id, _a); - _id -= 3; + _id -= 4; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { - if (_id < 3) + if (_id < 4) *reinterpret_cast(_a[0]) = -1; - _id -= 3; + _id -= 4; } return _id; } diff --git a/Desktop_Interface/moc_unixusbdriver.o b/Desktop_Interface/moc_unixusbdriver.o index 62510a1f..c64673e7 100644 Binary files a/Desktop_Interface/moc_unixusbdriver.o and b/Desktop_Interface/moc_unixusbdriver.o differ diff --git a/Desktop_Interface/unixusbdriver.cpp b/Desktop_Interface/unixusbdriver.cpp index 89679bad..3d58ea31 100644 --- a/Desktop_Interface/unixusbdriver.cpp +++ b/Desktop_Interface/unixusbdriver.cpp @@ -12,7 +12,6 @@ unixUsbDriver::~unixUsbDriver(void){ qDebug() << "\n\nunixUsbDriver destructor ran!"; //unixDriverDeleteMutex.lock(); workerThread->terminate(); - //workerThread->deleteLater(); delete(isoHandler); delete(workerThread); qDebug() << "THREAD Gone!"; @@ -195,6 +194,7 @@ void unixUsbDriver::isoTimerTick(void){ error = libusb_cancel_transfer(isoCtx[k][earliest]); numCancelled++; qDebug() << "Cancelled" << earliest << k; + qDebug() << "Total Cancelled =" << numCancelled; if(numCancelled == (NUM_FUTURE_CTX * NUM_ISO_ENDPOINTS)){ isoHandler->stopTime = true; } @@ -239,4 +239,10 @@ bool unixUsbDriver::allEndpointsComplete(int n){ void unixUsbDriver::shutdownProcedure(){ shutdownMode = true; + QTimer::singleShot(1000, this, SLOT(backupCleanup())); +} + +//On physical disconnect, isoTimerTick will not assert stopTime. Hence this duct-tape function. +void unixUsbDriver::backupCleanup(){ + isoHandler->stopTime = true; } diff --git a/Desktop_Interface/unixusbdriver.h b/Desktop_Interface/unixusbdriver.h index 0f255775..8c4924e6 100644 --- a/Desktop_Interface/unixusbdriver.h +++ b/Desktop_Interface/unixusbdriver.h @@ -27,14 +27,22 @@ public: ~worker(){}; libusb_context *ctx; bool stopTime = false; + unsigned char cleanupRemaining = 2; public slots: void handle(){ qDebug() << "SUB THREAD ID" << QThread::currentThreadId(); while(1){ - if(!stopTime){ - if(libusb_event_handling_ok(ctx)){ - libusb_handle_events_timeout(ctx, &tv); - //qDebug() << "HANDLED"; + //qDebug() << cleanupRemaining; + if(libusb_event_handling_ok(ctx)){ + libusb_handle_events_timeout(ctx, &tv); + //qDebug() << "HANDLED"; + } + if(stopTime){ + if(cleanupRemaining){ + cleanupRemaining--; + }else while(1){ + QThread::msleep(100); + qDebug() << "Cleanup complete"; } } } @@ -73,6 +81,7 @@ public slots: void isoTimerTick(void); void recoveryTick(void); void shutdownProcedure(void); + void backupCleanup(void); }; //Callback on iso transfer complete. diff --git a/Desktop_Interface/unixusbdriver.o b/Desktop_Interface/unixusbdriver.o index 96234fba..d1eddcee 100644 Binary files a/Desktop_Interface/unixusbdriver.o and b/Desktop_Interface/unixusbdriver.o differ