mirror of https://github.com/EspoTek/Labrador.git
Fixed segfault; now displays message about iso failure too
This commit is contained in:
parent
7a2f8cf35a
commit
39d1bff5ab
|
@ -28,17 +28,29 @@ genericUsbDriver::genericUsbDriver(QWidget *parent) : QLabel(parent)
|
|||
connectTimer->start(USB_RECONNECT_PERIOD);
|
||||
connect(connectTimer, SIGNAL(timeout()), this, SLOT(checkConnection()));
|
||||
qDebug()<< "Generic Usb Driver setup complete";
|
||||
messageBox = new QMessageBox();
|
||||
}
|
||||
|
||||
genericUsbDriver::~genericUsbDriver(void){
|
||||
qDebug() << "genericUsbDriver dectructor entering";
|
||||
if(connected){
|
||||
psuTimer->stop();
|
||||
recoveryTimer->stop();
|
||||
isoTimer->stop();
|
||||
delete(psuTimer);
|
||||
delete(recoveryTimer);
|
||||
delete(isoTimer);
|
||||
if (psuTimer)
|
||||
{
|
||||
psuTimer->stop();
|
||||
delete(psuTimer);
|
||||
}
|
||||
|
||||
if (recoveryTimer)
|
||||
{
|
||||
recoveryTimer->stop();
|
||||
delete(recoveryTimer);
|
||||
}
|
||||
|
||||
if (isoTimer)
|
||||
{
|
||||
isoTimer->stop();
|
||||
delete(isoTimer);
|
||||
}
|
||||
}
|
||||
qDebug() << "genericUsbDriver dectructor completed";
|
||||
}
|
||||
|
@ -402,7 +414,13 @@ void genericUsbDriver::checkConnection(){
|
|||
|
||||
setDeviceMode(deviceMode);
|
||||
newDig(digitalPinState);
|
||||
usbIsoInit();
|
||||
|
||||
int ret = usbIsoInit();
|
||||
if (ret != 0)
|
||||
{
|
||||
messageBox->setText("A USB connection was established, but isochronous communications could not be initialised.<br>This is usually due to bandwidth limitations on the current USB host and can be fixed by moving to a different port.<br>Please see <a href = 'https://github.com/EspoTek/Labrador/wiki/Troubleshooting-Guide#usb-connection-issues-other-platforms'>https://github.com/EspoTek/Labrador/wiki/Troubleshooting-Guide#usb-connection-issues-other-platforms</a>");
|
||||
messageBox->exec();
|
||||
}
|
||||
|
||||
psuTimer = new QTimer();
|
||||
psuTimer->setTimerType(Qt::PreciseTimer);
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <QThread>
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "functiongencontrol.h"
|
||||
#include "xmega.h"
|
||||
|
@ -83,10 +84,10 @@ protected:
|
|||
unsigned char variant = 0;
|
||||
//Generic Vars
|
||||
//bufferControl *bufferPtr = NULL;
|
||||
QTimer *psuTimer;
|
||||
QTimer *psuTimer = nullptr;
|
||||
unsigned char pipeID[3];
|
||||
QTimer *isoTimer;
|
||||
QTimer *connectTimer;
|
||||
QTimer *isoTimer = nullptr;
|
||||
QTimer *connectTimer = nullptr;
|
||||
QTimer *recoveryTimer;
|
||||
unsigned char currentWriteBuffer = 0;
|
||||
unsigned long timerCount = 0;
|
||||
|
@ -98,6 +99,7 @@ protected:
|
|||
virtual int usbIsoInit(void) = 0;
|
||||
virtual int flashFirmware(void) = 0;
|
||||
uint8_t numero_uno = 1;
|
||||
QMessageBox *messageBox;
|
||||
signals:
|
||||
void sendClearBuffer(bool ch3751, bool ch3752, bool ch750);
|
||||
void setVisible_CH2(bool visible);
|
||||
|
|
|
@ -216,6 +216,7 @@ private:
|
|||
int reinitDigitalPinState;
|
||||
|
||||
QSettings *settings;
|
||||
bool calibrationCanceled = false;
|
||||
|
||||
//Generic Functions
|
||||
void initialisePlot();
|
||||
|
|
|
@ -20,19 +20,24 @@ unixUsbDriver::~unixUsbDriver(void){
|
|||
qDebug() << "\n\nunixUsbDriver destructor ran!";
|
||||
//unixDriverDeleteMutex.lock();
|
||||
if(connected){
|
||||
workerThread->deleteLater();
|
||||
while(workerThread->isRunning()){
|
||||
workerThread->quit();
|
||||
qDebug() << "isRunning?" << workerThread->isFinished();
|
||||
QThread::msleep(100);
|
||||
}
|
||||
delete(isoHandler);
|
||||
if (workerThread)
|
||||
{
|
||||
workerThread->deleteLater();
|
||||
while(workerThread->isRunning()){
|
||||
workerThread->quit();
|
||||
qDebug() << "isRunning?" << workerThread->isFinished();
|
||||
QThread::msleep(100);
|
||||
}
|
||||
}
|
||||
if (isoHandler)
|
||||
delete(isoHandler);
|
||||
//delete(workerThread);
|
||||
qDebug() << "THREAD Gone!";
|
||||
|
||||
for (int i=0; i<NUM_FUTURE_CTX; i++){
|
||||
for (int k=0; k<NUM_ISO_ENDPOINTS; k++){
|
||||
libusb_free_transfer(isoCtx[k][i]);
|
||||
if (isoCtx[k][i])
|
||||
libusb_free_transfer(isoCtx[k][i]);
|
||||
}
|
||||
}
|
||||
qDebug() << "Transfers freed.";
|
||||
|
@ -120,7 +125,7 @@ void unixUsbDriver::usbSendControl(uint8_t RequestType, uint8_t Request, uint16_
|
|||
|
||||
int unixUsbDriver::usbIsoInit(void){
|
||||
int error;
|
||||
|
||||
|
||||
for(int n=0;n<NUM_FUTURE_CTX;n++){
|
||||
for (unsigned char k=0;k<NUM_ISO_ENDPOINTS;k++){
|
||||
isoCtx[k][n] = libusb_alloc_transfer(ISO_PACKETS_PER_CTX);
|
||||
|
@ -311,7 +316,8 @@ void unixUsbDriver::shutdownProcedure(){
|
|||
|
||||
//On physical disconnect, isoTimerTick will not assert stopTime. Hence this duct-tape function.
|
||||
void unixUsbDriver::backupCleanup(){
|
||||
isoHandler->stopTime = true;
|
||||
if (isoHandler)
|
||||
isoHandler->stopTime = true;
|
||||
}
|
||||
|
||||
int unixUsbDriver::flashFirmware(void){
|
||||
|
|
|
@ -74,11 +74,11 @@ protected:
|
|||
unsigned char *midBuffer_current[NUM_ISO_ENDPOINTS];
|
||||
unsigned char *midBuffer_prev[NUM_ISO_ENDPOINTS];
|
||||
qint64 midBufferOffsets[NUM_ISO_ENDPOINTS];
|
||||
libusb_transfer *isoCtx[NUM_ISO_ENDPOINTS][NUM_FUTURE_CTX];
|
||||
libusb_transfer *isoCtx[NUM_ISO_ENDPOINTS][NUM_FUTURE_CTX] = { };
|
||||
tcBlock transferCompleted[NUM_ISO_ENDPOINTS][NUM_FUTURE_CTX];
|
||||
unsigned char dataBuffer[NUM_ISO_ENDPOINTS][NUM_FUTURE_CTX][ISO_PACKET_SIZE*ISO_PACKETS_PER_CTX];
|
||||
worker *isoHandler;
|
||||
QThread *workerThread;
|
||||
worker *isoHandler = nullptr;
|
||||
QThread *workerThread = nullptr;
|
||||
int cumulativeFramePhaseErrors = 0;
|
||||
//Generic Functions
|
||||
virtual unsigned char usbInit(unsigned long VIDin, unsigned long PIDin);
|
||||
|
|
|
@ -131,7 +131,7 @@ void winUsbDriver::usbSendControl(uint8_t RequestType, uint8_t Request, uint16_t
|
|||
}
|
||||
}
|
||||
|
||||
unsigned char winUsbDriver::usbIsoInit(void){
|
||||
int winUsbDriver::usbIsoInit(void){
|
||||
//Iso is slightly less easy than plain old USB.
|
||||
//You must set up NUM_FUTURE_CTX iso transfers, with each transfer containing ISO_PACKETS_PER_CTX isochronous packets.
|
||||
//These transactions are numbered by n = 0,1,2,3...NUM_FUTURE_CTX-1. Transfer n should read data into dataBuffer[n].
|
||||
|
@ -148,14 +148,14 @@ unsigned char winUsbDriver::usbIsoInit(void){
|
|||
if(!success){
|
||||
errorCode = GetLastError();
|
||||
qDebug() << "OvlK_Init failed with error code" << errorCode;
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
for (unsigned char k=0;k<NUM_ISO_ENDPOINTS;k++){
|
||||
success = UsbK_ResetPipe(handle, pipeID[k]);
|
||||
if(!success){
|
||||
errorCode = GetLastError();
|
||||
qDebug() << "UsbK_ResetPipe failed with error code" << errorCode;
|
||||
return 0;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ unsigned char winUsbDriver::usbIsoInit(void){
|
|||
errorCode = GetLastError();
|
||||
qDebug() << "IsoK_Init failed with error code" << errorCode;
|
||||
qDebug() << "n =" << n;
|
||||
return 0;
|
||||
return -3;
|
||||
}
|
||||
|
||||
success = IsoK_SetPackets(isoCtx[k][n], ISO_PACKET_SIZE);
|
||||
|
@ -178,7 +178,7 @@ unsigned char winUsbDriver::usbIsoInit(void){
|
|||
errorCode = GetLastError();
|
||||
qDebug() << "IsoK_SetPackets failed with error code" << errorCode;
|
||||
qDebug() << "n =" << n;
|
||||
return 0;
|
||||
return -4;
|
||||
}
|
||||
|
||||
success = OvlK_Acquire(&ovlkHandle[k][n], ovlPool);
|
||||
|
@ -186,7 +186,7 @@ unsigned char winUsbDriver::usbIsoInit(void){
|
|||
errorCode = GetLastError();
|
||||
qDebug() << "OvlK_Acquire failed with error code" << errorCode;
|
||||
qDebug() << "n =" << n;
|
||||
return 0;
|
||||
return -5;
|
||||
}
|
||||
|
||||
//Sending the transfer requests
|
||||
|
@ -202,7 +202,7 @@ unsigned char winUsbDriver::usbIsoInit(void){
|
|||
connect(isoTimer, SIGNAL(timeout()), this, SLOT(isoTimerTick()));
|
||||
|
||||
qDebug() << "Setup successful!";
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void winUsbDriver::isoTimerTick(void){
|
||||
|
|
|
@ -32,7 +32,7 @@ private:
|
|||
unsigned char dataBuffer[NUM_ISO_ENDPOINTS][NUM_FUTURE_CTX][ISO_PACKET_SIZE*ISO_PACKETS_PER_CTX];
|
||||
//Generic Functions
|
||||
unsigned char usbInit(unsigned long VIDin, unsigned long PIDin);
|
||||
unsigned char usbIsoInit(void);
|
||||
int usbIsoInit(void);
|
||||
int flashFirmware(void);
|
||||
bool allEndpointsComplete(int n);
|
||||
signals:
|
||||
|
|
Loading…
Reference in New Issue