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);
|
connectTimer->start(USB_RECONNECT_PERIOD);
|
||||||
connect(connectTimer, SIGNAL(timeout()), this, SLOT(checkConnection()));
|
connect(connectTimer, SIGNAL(timeout()), this, SLOT(checkConnection()));
|
||||||
qDebug()<< "Generic Usb Driver setup complete";
|
qDebug()<< "Generic Usb Driver setup complete";
|
||||||
|
messageBox = new QMessageBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
genericUsbDriver::~genericUsbDriver(void){
|
genericUsbDriver::~genericUsbDriver(void){
|
||||||
qDebug() << "genericUsbDriver dectructor entering";
|
qDebug() << "genericUsbDriver dectructor entering";
|
||||||
if(connected){
|
if(connected){
|
||||||
psuTimer->stop();
|
if (psuTimer)
|
||||||
recoveryTimer->stop();
|
{
|
||||||
isoTimer->stop();
|
psuTimer->stop();
|
||||||
delete(psuTimer);
|
delete(psuTimer);
|
||||||
delete(recoveryTimer);
|
}
|
||||||
delete(isoTimer);
|
|
||||||
|
if (recoveryTimer)
|
||||||
|
{
|
||||||
|
recoveryTimer->stop();
|
||||||
|
delete(recoveryTimer);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isoTimer)
|
||||||
|
{
|
||||||
|
isoTimer->stop();
|
||||||
|
delete(isoTimer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
qDebug() << "genericUsbDriver dectructor completed";
|
qDebug() << "genericUsbDriver dectructor completed";
|
||||||
}
|
}
|
||||||
|
@ -402,7 +414,13 @@ void genericUsbDriver::checkConnection(){
|
||||||
|
|
||||||
setDeviceMode(deviceMode);
|
setDeviceMode(deviceMode);
|
||||||
newDig(digitalPinState);
|
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 = new QTimer();
|
||||||
psuTimer->setTimerType(Qt::PreciseTimer);
|
psuTimer->setTimerType(Qt::PreciseTimer);
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include "functiongencontrol.h"
|
#include "functiongencontrol.h"
|
||||||
#include "xmega.h"
|
#include "xmega.h"
|
||||||
|
@ -83,10 +84,10 @@ protected:
|
||||||
unsigned char variant = 0;
|
unsigned char variant = 0;
|
||||||
//Generic Vars
|
//Generic Vars
|
||||||
//bufferControl *bufferPtr = NULL;
|
//bufferControl *bufferPtr = NULL;
|
||||||
QTimer *psuTimer;
|
QTimer *psuTimer = nullptr;
|
||||||
unsigned char pipeID[3];
|
unsigned char pipeID[3];
|
||||||
QTimer *isoTimer;
|
QTimer *isoTimer = nullptr;
|
||||||
QTimer *connectTimer;
|
QTimer *connectTimer = nullptr;
|
||||||
QTimer *recoveryTimer;
|
QTimer *recoveryTimer;
|
||||||
unsigned char currentWriteBuffer = 0;
|
unsigned char currentWriteBuffer = 0;
|
||||||
unsigned long timerCount = 0;
|
unsigned long timerCount = 0;
|
||||||
|
@ -98,6 +99,7 @@ protected:
|
||||||
virtual int usbIsoInit(void) = 0;
|
virtual int usbIsoInit(void) = 0;
|
||||||
virtual int flashFirmware(void) = 0;
|
virtual int flashFirmware(void) = 0;
|
||||||
uint8_t numero_uno = 1;
|
uint8_t numero_uno = 1;
|
||||||
|
QMessageBox *messageBox;
|
||||||
signals:
|
signals:
|
||||||
void sendClearBuffer(bool ch3751, bool ch3752, bool ch750);
|
void sendClearBuffer(bool ch3751, bool ch3752, bool ch750);
|
||||||
void setVisible_CH2(bool visible);
|
void setVisible_CH2(bool visible);
|
||||||
|
|
|
@ -216,6 +216,7 @@ private:
|
||||||
int reinitDigitalPinState;
|
int reinitDigitalPinState;
|
||||||
|
|
||||||
QSettings *settings;
|
QSettings *settings;
|
||||||
|
bool calibrationCanceled = false;
|
||||||
|
|
||||||
//Generic Functions
|
//Generic Functions
|
||||||
void initialisePlot();
|
void initialisePlot();
|
||||||
|
|
|
@ -20,19 +20,24 @@ unixUsbDriver::~unixUsbDriver(void){
|
||||||
qDebug() << "\n\nunixUsbDriver destructor ran!";
|
qDebug() << "\n\nunixUsbDriver destructor ran!";
|
||||||
//unixDriverDeleteMutex.lock();
|
//unixDriverDeleteMutex.lock();
|
||||||
if(connected){
|
if(connected){
|
||||||
workerThread->deleteLater();
|
if (workerThread)
|
||||||
while(workerThread->isRunning()){
|
{
|
||||||
workerThread->quit();
|
workerThread->deleteLater();
|
||||||
qDebug() << "isRunning?" << workerThread->isFinished();
|
while(workerThread->isRunning()){
|
||||||
QThread::msleep(100);
|
workerThread->quit();
|
||||||
}
|
qDebug() << "isRunning?" << workerThread->isFinished();
|
||||||
delete(isoHandler);
|
QThread::msleep(100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isoHandler)
|
||||||
|
delete(isoHandler);
|
||||||
//delete(workerThread);
|
//delete(workerThread);
|
||||||
qDebug() << "THREAD Gone!";
|
qDebug() << "THREAD Gone!";
|
||||||
|
|
||||||
for (int i=0; i<NUM_FUTURE_CTX; i++){
|
for (int i=0; i<NUM_FUTURE_CTX; i++){
|
||||||
for (int k=0; k<NUM_ISO_ENDPOINTS; k++){
|
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.";
|
qDebug() << "Transfers freed.";
|
||||||
|
@ -120,7 +125,7 @@ void unixUsbDriver::usbSendControl(uint8_t RequestType, uint8_t Request, uint16_
|
||||||
|
|
||||||
int unixUsbDriver::usbIsoInit(void){
|
int unixUsbDriver::usbIsoInit(void){
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
for(int n=0;n<NUM_FUTURE_CTX;n++){
|
for(int n=0;n<NUM_FUTURE_CTX;n++){
|
||||||
for (unsigned char k=0;k<NUM_ISO_ENDPOINTS;k++){
|
for (unsigned char k=0;k<NUM_ISO_ENDPOINTS;k++){
|
||||||
isoCtx[k][n] = libusb_alloc_transfer(ISO_PACKETS_PER_CTX);
|
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.
|
//On physical disconnect, isoTimerTick will not assert stopTime. Hence this duct-tape function.
|
||||||
void unixUsbDriver::backupCleanup(){
|
void unixUsbDriver::backupCleanup(){
|
||||||
isoHandler->stopTime = true;
|
if (isoHandler)
|
||||||
|
isoHandler->stopTime = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int unixUsbDriver::flashFirmware(void){
|
int unixUsbDriver::flashFirmware(void){
|
||||||
|
|
|
@ -74,11 +74,11 @@ protected:
|
||||||
unsigned char *midBuffer_current[NUM_ISO_ENDPOINTS];
|
unsigned char *midBuffer_current[NUM_ISO_ENDPOINTS];
|
||||||
unsigned char *midBuffer_prev[NUM_ISO_ENDPOINTS];
|
unsigned char *midBuffer_prev[NUM_ISO_ENDPOINTS];
|
||||||
qint64 midBufferOffsets[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];
|
tcBlock transferCompleted[NUM_ISO_ENDPOINTS][NUM_FUTURE_CTX];
|
||||||
unsigned char dataBuffer[NUM_ISO_ENDPOINTS][NUM_FUTURE_CTX][ISO_PACKET_SIZE*ISO_PACKETS_PER_CTX];
|
unsigned char dataBuffer[NUM_ISO_ENDPOINTS][NUM_FUTURE_CTX][ISO_PACKET_SIZE*ISO_PACKETS_PER_CTX];
|
||||||
worker *isoHandler;
|
worker *isoHandler = nullptr;
|
||||||
QThread *workerThread;
|
QThread *workerThread = nullptr;
|
||||||
int cumulativeFramePhaseErrors = 0;
|
int cumulativeFramePhaseErrors = 0;
|
||||||
//Generic Functions
|
//Generic Functions
|
||||||
virtual unsigned char usbInit(unsigned long VIDin, unsigned long PIDin);
|
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.
|
//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.
|
//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].
|
//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){
|
if(!success){
|
||||||
errorCode = GetLastError();
|
errorCode = GetLastError();
|
||||||
qDebug() << "OvlK_Init failed with error code" << errorCode;
|
qDebug() << "OvlK_Init failed with error code" << errorCode;
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
for (unsigned char k=0;k<NUM_ISO_ENDPOINTS;k++){
|
for (unsigned char k=0;k<NUM_ISO_ENDPOINTS;k++){
|
||||||
success = UsbK_ResetPipe(handle, pipeID[k]);
|
success = UsbK_ResetPipe(handle, pipeID[k]);
|
||||||
if(!success){
|
if(!success){
|
||||||
errorCode = GetLastError();
|
errorCode = GetLastError();
|
||||||
qDebug() << "UsbK_ResetPipe failed with error code" << errorCode;
|
qDebug() << "UsbK_ResetPipe failed with error code" << errorCode;
|
||||||
return 0;
|
return -2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ unsigned char winUsbDriver::usbIsoInit(void){
|
||||||
errorCode = GetLastError();
|
errorCode = GetLastError();
|
||||||
qDebug() << "IsoK_Init failed with error code" << errorCode;
|
qDebug() << "IsoK_Init failed with error code" << errorCode;
|
||||||
qDebug() << "n =" << n;
|
qDebug() << "n =" << n;
|
||||||
return 0;
|
return -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
success = IsoK_SetPackets(isoCtx[k][n], ISO_PACKET_SIZE);
|
success = IsoK_SetPackets(isoCtx[k][n], ISO_PACKET_SIZE);
|
||||||
|
@ -178,7 +178,7 @@ unsigned char winUsbDriver::usbIsoInit(void){
|
||||||
errorCode = GetLastError();
|
errorCode = GetLastError();
|
||||||
qDebug() << "IsoK_SetPackets failed with error code" << errorCode;
|
qDebug() << "IsoK_SetPackets failed with error code" << errorCode;
|
||||||
qDebug() << "n =" << n;
|
qDebug() << "n =" << n;
|
||||||
return 0;
|
return -4;
|
||||||
}
|
}
|
||||||
|
|
||||||
success = OvlK_Acquire(&ovlkHandle[k][n], ovlPool);
|
success = OvlK_Acquire(&ovlkHandle[k][n], ovlPool);
|
||||||
|
@ -186,7 +186,7 @@ unsigned char winUsbDriver::usbIsoInit(void){
|
||||||
errorCode = GetLastError();
|
errorCode = GetLastError();
|
||||||
qDebug() << "OvlK_Acquire failed with error code" << errorCode;
|
qDebug() << "OvlK_Acquire failed with error code" << errorCode;
|
||||||
qDebug() << "n =" << n;
|
qDebug() << "n =" << n;
|
||||||
return 0;
|
return -5;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Sending the transfer requests
|
//Sending the transfer requests
|
||||||
|
@ -202,7 +202,7 @@ unsigned char winUsbDriver::usbIsoInit(void){
|
||||||
connect(isoTimer, SIGNAL(timeout()), this, SLOT(isoTimerTick()));
|
connect(isoTimer, SIGNAL(timeout()), this, SLOT(isoTimerTick()));
|
||||||
|
|
||||||
qDebug() << "Setup successful!";
|
qDebug() << "Setup successful!";
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void winUsbDriver::isoTimerTick(void){
|
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];
|
unsigned char dataBuffer[NUM_ISO_ENDPOINTS][NUM_FUTURE_CTX][ISO_PACKET_SIZE*ISO_PACKETS_PER_CTX];
|
||||||
//Generic Functions
|
//Generic Functions
|
||||||
unsigned char usbInit(unsigned long VIDin, unsigned long PIDin);
|
unsigned char usbInit(unsigned long VIDin, unsigned long PIDin);
|
||||||
unsigned char usbIsoInit(void);
|
int usbIsoInit(void);
|
||||||
int flashFirmware(void);
|
int flashFirmware(void);
|
||||||
bool allEndpointsComplete(int n);
|
bool allEndpointsComplete(int n);
|
||||||
signals:
|
signals:
|
||||||
|
|
Loading…
Reference in New Issue