diff --git a/config.h b/config.h index 9871909..b29837d 100644 --- a/config.h +++ b/config.h @@ -6,7 +6,7 @@ //try to keep this in sync. //SavvyCAN will complain if you connect a GVRET board with a revision //less than this number. -#define CURRENT_GVRET_VER 321 +#define CURRENT_GVRET_VER 322 #endif // CONFIG diff --git a/frameplaybackwindow.cpp b/frameplaybackwindow.cpp index f16c24c..83bb46e 100644 --- a/frameplaybackwindow.cpp +++ b/frameplaybackwindow.cpp @@ -71,6 +71,7 @@ FramePlaybackWindow::FramePlaybackWindow(const QVector *frames, Serial playbackTimer->setInterval(ui->spinPlaySpeed->value()); //set the timer to the default value of the control connect(this, SIGNAL(sendCANFrame(const CANFrame*,int)), worker, SLOT(sendFrame(const CANFrame*,int)), Qt::QueuedConnection); + connect(this, SIGNAL(sendFrameBatch(const QList*)), worker, SLOT(sendFrameBatch(const QList*)), Qt::QueuedConnection); QStringList headers; headers << "Source" << "Loops"; @@ -520,7 +521,8 @@ void FramePlaybackWindow::btnSelectNoneClick() } void FramePlaybackWindow::timerTriggered() -{ +{ + sendingBuffer.clear(); for (int count = 0; count < ui->spinBurstSpeed->value(); count++) { if (!playbackActive) @@ -537,6 +539,7 @@ void FramePlaybackWindow::timerTriggered() updatePosition(false); } } + emit sendFrameBatch(&sendingBuffer); } void FramePlaybackWindow::updatePosition(bool forward) @@ -606,13 +609,26 @@ void FramePlaybackWindow::updatePosition(bool forward) } //only send frame out if its ID is checked in the list. Otherwise discard it. - const CANFrame *thisFrame = ¤tSeqItem->data[currentPosition]; + CANFrame *thisFrame = ¤tSeqItem->data[currentPosition]; + int originalBus = thisFrame->bus; if (currentSeqItem->idFilters.find(thisFrame->ID).value()) { //index 0 is none, 1 is Bus 0, 2 is bus 1, 3 is both, 4 is from file - if (whichBusSend & 1) emit sendCANFrame(thisFrame, 0); - if (whichBusSend & 2) emit sendCANFrame(thisFrame, 1); - if (whichBusSend & 4) emit sendCANFrame(thisFrame, thisFrame->bus); + if (whichBusSend & 4) + { + sendingBuffer.append(*thisFrame); + } + if (whichBusSend & 1) + { + thisFrame->bus = 0; + sendingBuffer.append(*thisFrame); + } + if (whichBusSend & 2) + { + thisFrame->bus = 1; + sendingBuffer.append(*thisFrame); + } + thisFrame->bus = originalBus; updateFrameLabel(); } diff --git a/frameplaybackwindow.h b/frameplaybackwindow.h index d6e2a2d..07296dd 100644 --- a/frameplaybackwindow.h +++ b/frameplaybackwindow.h @@ -55,11 +55,13 @@ private slots: signals: void sendCANFrame(const CANFrame *, int); + void sendFrameBatch(const QList *); private: Ui::FramePlaybackWindow *ui; QList foundID; QList frameCache; + QList sendingBuffer; const QVector *modelFrames; int currentPosition; QTimer *playbackTimer; diff --git a/serialworker.cpp b/serialworker.cpp index c033522..3238fff 100644 --- a/serialworker.cpp +++ b/serialworker.cpp @@ -70,11 +70,11 @@ void SerialWorker::setSerialPort(QSerialPortInfo *port) serial = new QSerialPort(*port); qDebug() << "Serial port name is " << port->portName(); - serial->setBaudRate(serial->Baud115200); + serial->setBaudRate(10000000); //more speed! probably does nothing for USB serial serial->setDataBits(serial->Data8); - serial->setFlowControl(serial->HardwareControl); + serial->setFlowControl(serial->HardwareControl); //this is important though serial->open(QIODevice::ReadWrite); - serial->setDataTerminalReady(true); + serial->setDataTerminalReady(true); //you do need to set these or the fan gets dirty serial->setRequestToSend(true); QByteArray output; output.append(0xE7); //this puts the device into binary comm mode @@ -85,6 +85,8 @@ void SerialWorker::setSerialPort(QSerialPortInfo *port) output.append(0x07); //request device information output.append(0xF1); output.append(0x08); //setting singlewire mode + output.append(0xF1); //yet another command + output.append(0x09); //comm validation command if (settings.value("Main/SingleWireMode", false).toBool()) { output.append(0x10); //signal that we do want single wire mode @@ -122,6 +124,7 @@ void SerialWorker::connectionTimeout() //then emit the the failure signal and see if anyone cares qDebug() << "Failed to connect to GVRET at that com port"; ticker->stop(); + closeSerialPort(); //make sure it's properly closed anyway emit connectionFailure(); } } @@ -171,6 +174,14 @@ void SerialWorker::sendFrame(const CANFrame *frame, int bus = 0) serial->write(buffer); } +//a simple way for another thread to pass us a bunch of frames to send. +//Don't get carried away here. The GVRET firmware only has finite +//buffers and besides, the other end will get buried in traffic. +void SerialWorker::sendFrameBatch(const QList *frames) +{ + for (int i = 0; i < frames->length(); i++) sendFrame(&frames->at(i), frames->at(i).bus); +} + void SerialWorker::updateBaudRates(int Speed1, int Speed2) { QByteArray buffer; diff --git a/serialworker.h b/serialworker.h index c0ff1ce..0b3c3b7 100644 --- a/serialworker.h +++ b/serialworker.h @@ -50,6 +50,7 @@ public slots: void setSerialPort(QSerialPortInfo*); void closeSerialPort(); void sendFrame(const CANFrame *, int); + void sendFrameBatch(const QList *); void updateBaudRates(int, int); void stopFrameCapture(); void startFrameCapture(); //only need to call this if previously stopped. Otherwise it's the default