Custom sender is no longer crashing
There are a TON of explorations I did here, many may be unnecessary, but this is a stake in the ground. The main issue was the strange queue logic in canconmanager::sendFrame which puts the tx data in the rx queue so it will show up in the displayed data. It caused SIGABRT and SIGSEG to show up everywhere. It is NOT fixed yet, but TX works over the wire you just can't see it in the tableview. I thought at first it was only when overwrite data was active, so I put in a a pile of changes to keep frames and filtered frames as two seperate copies of data where frames was always complete and filtered was only what was seen in the mainwindow. It made it so the graphing window would work with overwrite data active which is an improvement. I wouldn't roll these changes back. Because of these changes I had to update the frame sorting code adjust the refresh function in canframemode.cpp I also thought it was related to UI updates, but its not, that's been confirmed. I put a mutex around the custom sender tick timer so that the 1ms timer wouldn't re-enter its callback. This didn't fix the crash, but it sure seems to make a lot of sense, and the way I did it no elasped time is lost for tracking purposes, and in reality theres no way 1ms was consistent anyway. I put a mutex around the shrinking of frames and filteredframes to make sure we weren't deleting at the same time as accessing, but honestly we acccess those lists in many places without semaphores so that probably did nothing. Fixed a bug in FrameSenderWindow:DoModifiers that was improperly parsing and sometimes crashing when looking for the ~ operator before a symbol. Also added some minor work to keep row expansion functioning when changing filters or sorting. Need to make some tweaks so it stops trying so hard when overwrite is not active Theres also code in main.c taht makes debugging output super verbose. Committing now to start cleanup
This commit is contained in:
+84
-54
@@ -236,11 +236,11 @@ void CANFrameModel::setAllFilters(bool state)
|
||||
* quicksort on the columns and interpret the columns numerically. But, correct or not, this implementation is quite fast
|
||||
* and sorts the columns properly.
|
||||
*/
|
||||
uint64_t CANFrameModel::getCANFrameVal(int row, Column col)
|
||||
uint64_t CANFrameModel::getCANFrameVal(QVector<CANFrame> *frames, int row, Column col)
|
||||
{
|
||||
uint64_t temp = 0;
|
||||
if (row >= frames.count()) return 0;
|
||||
CANFrame frame = frames[row];
|
||||
if (row >= frames->count()) return 0;
|
||||
CANFrame frame = frames->at(row);
|
||||
switch (col)
|
||||
{
|
||||
case Column::TimeStamp:
|
||||
@@ -279,18 +279,18 @@ void CANFrameModel::qSortCANFrameAsc(QVector<CANFrame> *frames, Column column, i
|
||||
qDebug() << "Lower " << lowerBound << " Upper" << upperBound;
|
||||
if (lowerBound < upperBound)
|
||||
{
|
||||
uint64_t piv = getCANFrameVal(lowerBound + (upperBound - lowerBound) / 2, column);
|
||||
uint64_t piv = getCANFrameVal(frames, lowerBound + (upperBound - lowerBound) / 2, column);
|
||||
i = lowerBound - 1;
|
||||
j = upperBound + 1;
|
||||
for (;;){
|
||||
do {
|
||||
i++;
|
||||
} while ((i < upperBound) && getCANFrameVal(i, column) < piv);
|
||||
} while ((i < upperBound) && getCANFrameVal(frames, i, column) < piv);
|
||||
|
||||
do
|
||||
{
|
||||
j--;
|
||||
} while ((j > lowerBound) && getCANFrameVal(j, column) > piv);
|
||||
} while ((j > lowerBound) && getCANFrameVal(frames, j, column) > piv);
|
||||
if (i < j) {
|
||||
CANFrame temp = frames->at(i);
|
||||
frames->replace(i, frames->at(j));
|
||||
@@ -310,18 +310,18 @@ void CANFrameModel::qSortCANFrameDesc(QVector<CANFrame> *frames, Column column,
|
||||
qDebug() << "Lower " << lowerBound << " Upper" << upperBound;
|
||||
if (lowerBound < upperBound)
|
||||
{
|
||||
uint64_t piv = getCANFrameVal(lowerBound + (upperBound - lowerBound) / 2, column);
|
||||
uint64_t piv = getCANFrameVal(frames, lowerBound + (upperBound - lowerBound) / 2, column);
|
||||
i = lowerBound - 1;
|
||||
j = upperBound + 1;
|
||||
for (;;){
|
||||
do {
|
||||
i++;
|
||||
} while ((i < upperBound) && getCANFrameVal(i, column) > piv);
|
||||
} while ((i < upperBound) && getCANFrameVal(frames, i, column) > piv);
|
||||
|
||||
do
|
||||
{
|
||||
j--;
|
||||
} while ((j > lowerBound) && getCANFrameVal(j, column) < piv);
|
||||
} while ((j > lowerBound) && getCANFrameVal(frames, j, column) < piv);
|
||||
if (i < j) {
|
||||
CANFrame temp = frames->at(i);
|
||||
frames->replace(i, frames->at(j));
|
||||
@@ -338,11 +338,13 @@ void CANFrameModel::qSortCANFrameDesc(QVector<CANFrame> *frames, Column column,
|
||||
void CANFrameModel::sortByColumn(int column)
|
||||
{
|
||||
sortDirAsc = !sortDirAsc;
|
||||
//beginResetModel();
|
||||
if (sortDirAsc) qSortCANFrameAsc(&frames, Column(column), 0, frames.count()-1);
|
||||
else qSortCANFrameDesc(&frames, Column(column), 0, frames.count()-1);
|
||||
//endResetModel();
|
||||
sendRefresh();
|
||||
if (sortDirAsc) qSortCANFrameAsc(&filteredFrames, Column(column), 0, filteredFrames.count()-1);
|
||||
else qSortCANFrameDesc(&filteredFrames, Column(column), 0, filteredFrames.count()-1);
|
||||
|
||||
mutex.lock();
|
||||
beginResetModel();
|
||||
endResetModel();
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
//End of custom sorting code
|
||||
@@ -365,34 +367,38 @@ void CANFrameModel::recalcOverwrite()
|
||||
|
||||
idAugmented = frame.frameId();
|
||||
idAugmented = idAugmented + (frame.bus << 29ull);
|
||||
if (!overWriteFrames.contains(idAugmented))
|
||||
if (filters[frame.frameId()] && busFilters[frame.bus])
|
||||
{
|
||||
frame.timedelta = 0;
|
||||
frame.frameCount = 1;
|
||||
overWriteFrames.insert(idAugmented, frame);
|
||||
}
|
||||
else
|
||||
{
|
||||
frame.timedelta = frame.timeStamp().microSeconds() - overWriteFrames[idAugmented].timeStamp().microSeconds();
|
||||
frame.frameCount = overWriteFrames[idAugmented].frameCount + 1;
|
||||
overWriteFrames[idAugmented] = frame;
|
||||
if (!overWriteFrames.contains(idAugmented))
|
||||
{
|
||||
frame.timedelta = 0;
|
||||
frame.frameCount = 1;
|
||||
overWriteFrames.insert(idAugmented, frame);
|
||||
}
|
||||
else
|
||||
{
|
||||
frame.timedelta = frame.timeStamp().microSeconds() - overWriteFrames[idAugmented].timeStamp().microSeconds();
|
||||
frame.frameCount = overWriteFrames[idAugmented].frameCount + 1;
|
||||
overWriteFrames[idAugmented] = frame;
|
||||
}
|
||||
}
|
||||
}
|
||||
//Then replace the old list of frames with just the unique list
|
||||
frames.clear();
|
||||
frames.append(overWriteFrames.values().toVector());
|
||||
frames.reserve(preallocSize);
|
||||
//frames.clear();
|
||||
//frames.append(overWriteFrames.values().toVector());
|
||||
//frames.reserve(preallocSize);
|
||||
|
||||
filteredFrames.clear();
|
||||
filteredFrames.append(overWriteFrames.values().toVector());
|
||||
filteredFrames.reserve(preallocSize);
|
||||
|
||||
for (int i = 0; i < frames.count(); i++)
|
||||
/*for (int i = 0; i < frames.count(); i++)
|
||||
{
|
||||
if (filters[frames[i].frameId()] && busFilters[frames[i].bus])
|
||||
{
|
||||
filteredFrames.append(frames[i]);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
endResetModel();
|
||||
mutex.unlock();
|
||||
@@ -705,20 +711,32 @@ void CANFrameModel::addFrame(const CANFrame& frame, bool autoRefresh = false)
|
||||
else //yes, overwrite dups
|
||||
{
|
||||
bool found = false;
|
||||
for (int i = 0; i < frames.count(); i++)
|
||||
// for (int i = 0; i < frames.count(); i++)
|
||||
// {
|
||||
// if ( (frames[i].frameId() == tempFrame.frameId()) && (frames[i].bus == tempFrame.bus) )
|
||||
// {
|
||||
// tempFrame.frameCount = frames[i].frameCount + 1;
|
||||
// tempFrame.timedelta = tempFrame.timeStamp().microSeconds() - frames[i].timeStamp().microSeconds();
|
||||
// frames.replace(i, tempFrame);
|
||||
// found = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
for (int i = 0; i < filteredFrames.count(); i++)
|
||||
{
|
||||
if ( (frames[i].frameId() == tempFrame.frameId()) && (frames[i].bus == tempFrame.bus) )
|
||||
if ( (filteredFrames[i].frameId() == tempFrame.frameId()) && (filteredFrames[i].bus == tempFrame.bus) )
|
||||
{
|
||||
tempFrame.frameCount = frames[i].frameCount + 1;
|
||||
tempFrame.timedelta = tempFrame.timeStamp().microSeconds() - frames[i].timeStamp().microSeconds();
|
||||
frames.replace(i, tempFrame);
|
||||
tempFrame.frameCount = filteredFrames[i].frameCount + 1;
|
||||
tempFrame.timedelta = tempFrame.timeStamp().microSeconds() - filteredFrames[i].timeStamp().microSeconds();
|
||||
filteredFrames.replace(i, tempFrame);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
frames.append(tempFrame);
|
||||
if (!found)
|
||||
{
|
||||
frames.append(tempFrame);
|
||||
//frames.append(tempFrame);
|
||||
if (filters[tempFrame.frameId()] && busFilters[tempFrame.bus])
|
||||
{
|
||||
if (autoRefresh) beginInsertRows(QModelIndex(), filteredFrames.count(), filteredFrames.count());
|
||||
@@ -750,16 +768,20 @@ void CANFrameModel::addFrames(const CANConnection*, const QVector<CANFrame>& pFr
|
||||
{
|
||||
if(frames.length() > frames.capacity() * 0.99)
|
||||
{
|
||||
mutex.lock();
|
||||
qDebug() << "Frames count: " << frames.length() << " of " << frames.capacity() << " capacity, removing first " << (int)(frames.capacity() * 0.05) << " frames";
|
||||
frames.remove(0, (int)(frames.capacity() * 0.05));
|
||||
qDebug() << "Frames removed, new count: " << frames.length();
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
if(filteredFrames.length() > filteredFrames.capacity() * 0.99)
|
||||
{
|
||||
mutex.lock();
|
||||
qDebug() << "filteredFrames count: " << filteredFrames.length() << " of " << filteredFrames.capacity() << " capacity, removing first " << (int)(filteredFrames.capacity() * 0.05) << " frames";
|
||||
filteredFrames.remove(0, (int)(filteredFrames.capacity() * 0.05));
|
||||
qDebug() << "filteredFrames removed, new count: " << filteredFrames.length();
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
foreach(const CANFrame& frame, pFrames)
|
||||
@@ -775,25 +797,33 @@ void CANFrameModel::addFrames(const CANConnection*, const QVector<CANFrame>& pFr
|
||||
|
||||
void CANFrameModel::sendRefresh()
|
||||
{
|
||||
qDebug() << "Sending mass refresh";
|
||||
QVector<CANFrame> tempContainer;
|
||||
int count = frames.count();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (filters[frames[i].frameId()] && busFilters[frames[i].bus])
|
||||
{
|
||||
tempContainer.append(frames[i]);
|
||||
}
|
||||
}
|
||||
mutex.lock();
|
||||
beginResetModel();
|
||||
filteredFrames.clear();
|
||||
filteredFrames.append(tempContainer);
|
||||
filteredFrames.reserve(preallocSize);
|
||||
qDebug() << "Sending mass refresh";
|
||||
|
||||
lastUpdateNumFrames = 0;
|
||||
endResetModel();
|
||||
mutex.unlock();
|
||||
if(overwriteDups)
|
||||
{
|
||||
recalcOverwrite();
|
||||
}
|
||||
else
|
||||
{
|
||||
QVector<CANFrame> tempContainer;
|
||||
int count = frames.count();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (filters[frames[i].frameId()] && busFilters[frames[i].bus])
|
||||
{
|
||||
tempContainer.append(frames[i]);
|
||||
}
|
||||
}
|
||||
|
||||
mutex.lock();
|
||||
beginResetModel();
|
||||
filteredFrames.clear();
|
||||
filteredFrames.append(tempContainer);
|
||||
filteredFrames.reserve(preallocSize);
|
||||
lastUpdateNumFrames = 0;
|
||||
endResetModel();
|
||||
mutex.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
void CANFrameModel::sendRefresh(int pos)
|
||||
@@ -811,7 +841,7 @@ int CANFrameModel::sendBulkRefresh()
|
||||
if (lastUpdateNumFrames <= 0) return 0;
|
||||
|
||||
if (lastUpdateNumFrames == 0 && !overwriteDups) return 0;
|
||||
if (filteredFrames.count() == 0) return 0;
|
||||
//if (filteredFrames.count() == 0) return 0;
|
||||
|
||||
//qDebug() << "Bulk refresh of " << lastUpdateNumFrames;
|
||||
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ signals:
|
||||
private:
|
||||
void qSortCANFrameAsc(QVector<CANFrame>* frames, Column column, int lowerBound, int upperBound);
|
||||
void qSortCANFrameDesc(QVector<CANFrame>* frames, Column column, int lowerBound, int upperBound);
|
||||
uint64_t getCANFrameVal(int row, Column col);
|
||||
uint64_t getCANFrameVal(QVector<CANFrame> *frames, int row, Column col);
|
||||
bool any_filters_are_configured(void);
|
||||
bool any_busfilters_are_configured(void);
|
||||
|
||||
|
||||
@@ -228,10 +228,44 @@ bool CANConManager::sendFrame(const CANFrame& pFrame)
|
||||
workingFrame.setTimeStamp(QCanBusFrame::TimeStamp(0, mElapsedTimer.nsecsElapsed() / 1000));
|
||||
//workingFrame.timestamp -= mTimestampBasis;
|
||||
}
|
||||
txFrame = conn->getQueue().get();
|
||||
//txFrame = conn->getQueue().get();
|
||||
QCoreApplication::processEvents();
|
||||
*txFrame = workingFrame;
|
||||
conn->getQueue().queue();
|
||||
//*txFrame = workingFrame;
|
||||
//conn->getQueue().queue();
|
||||
|
||||
|
||||
|
||||
//copy pframe so the stack can be used while we send, prevents needing BlockingQueuedConnection
|
||||
// CANFrame frameCopy;
|
||||
// frameCopy.bus = workingFrame.bus;
|
||||
// //cFrame.timedelta
|
||||
|
||||
// /////////////////////////////////////////////
|
||||
// QByteArray copiedData;
|
||||
// for(int i=0; i<workingFrame.payload().length(); i++)
|
||||
// copiedData.append(workingFrame.payload()[i]);
|
||||
// frameCopy.setPayload(copiedData);
|
||||
// //frameCopy.setPayload(pFrame.payload());
|
||||
// frameCopy.bus = workingFrame.bus;
|
||||
// if (workingFrame.frameType() == workingFrame.ErrorFrame)
|
||||
// {
|
||||
// frameCopy.setExtendedFrameFormat(workingFrame.hasExtendedFrameFormat());
|
||||
// frameCopy.setFrameId(workingFrame.frameId() + 0x20000000ull);
|
||||
// frameCopy.isReceived = true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// frameCopy.setExtendedFrameFormat(workingFrame.hasExtendedFrameFormat());
|
||||
// frameCopy.setFrameId(workingFrame.frameId());
|
||||
// }
|
||||
// frameCopy.setTimeStamp(workingFrame.timeStamp());
|
||||
// frameCopy.setFrameType(workingFrame.frameType());
|
||||
// frameCopy.setError(workingFrame.error());
|
||||
// ///* If recorded frame has a local echo, it is a Tx message, and thus should not be marked as Rx */
|
||||
// frameCopy.isReceived = workingFrame.isReceived;
|
||||
////////////////////////////////////////////
|
||||
|
||||
|
||||
return conn->sendFrame(workingFrame);
|
||||
}
|
||||
busBase += conn->getNumBuses();
|
||||
|
||||
@@ -173,6 +173,8 @@ bool CANConnection::sendFrame(const CANFrame& pFrame)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return piSendFrame(pFrame);
|
||||
}
|
||||
|
||||
|
||||
@@ -418,14 +418,12 @@ void ConnectionWindow::currentTabChanged(int newIdx)
|
||||
|
||||
void ConnectionWindow::currentRowChanged(const QModelIndex ¤t, const QModelIndex &previous)
|
||||
{
|
||||
Q_UNUSED(previous);
|
||||
|
||||
int selIdx = current.row();
|
||||
|
||||
disconnect(connModel->getAtIdx(previous.row()), SIGNAL(debugOutput(QString)), nullptr, nullptr);
|
||||
CANConnection* prevConn = connModel->getAtIdx(previous.row());
|
||||
if(prevConn != nullptr)
|
||||
disconnect(prevConn, SIGNAL(debugOutput(QString)), nullptr, nullptr);
|
||||
disconnect(this, SIGNAL(sendDebugData(QByteArray)), nullptr, nullptr);
|
||||
|
||||
|
||||
/* set parameters */
|
||||
if (selIdx == -1) {
|
||||
ui->groupBus->setEnabled(false);
|
||||
|
||||
@@ -64,7 +64,7 @@ void SocketCANd::sendBytesToTCP(const QByteArray &bytes, int busNum)
|
||||
byt = (unsigned char)byt;
|
||||
buildDebug = buildDebug % QString::number(byt, 16) % " ";
|
||||
}
|
||||
sendDebug(buildDebug);
|
||||
//sendDebug(buildDebug);
|
||||
|
||||
if (tcpClient[busNum]) tcpClient[busNum]->write(bytes);
|
||||
}
|
||||
@@ -77,9 +77,9 @@ void SocketCANd::sendStringToTCP(const char* data, int busNum)
|
||||
return;
|
||||
}
|
||||
|
||||
QString buildDebug;
|
||||
buildDebug = "Send data to " + hostIP.toString() + ":" + QString::number(hostPort) + " -> " + data;
|
||||
sendDebug(buildDebug);
|
||||
//QString buildDebug;
|
||||
//buildDebug = "Send data to " + hostIP.toString() + ":" + QString::number(hostPort) + " -> " + data;
|
||||
//sendDebug(buildDebug);
|
||||
//qInfo() << buildDebug;
|
||||
|
||||
if (tcpClient[busNum]) tcpClient[busNum]->write(data);
|
||||
@@ -300,6 +300,8 @@ QString SocketCANd::decodeFrames(QString data, int busNum)
|
||||
|
||||
int framelength = frameParsed[3].length() * 0.5;
|
||||
|
||||
|
||||
QByteArray buildData;
|
||||
buildData.resize(framelength);
|
||||
|
||||
int c;
|
||||
@@ -371,15 +373,15 @@ void SocketCANd::invokeReadTCPData()
|
||||
|
||||
void SocketCANd::readTCPData(int busNum)
|
||||
{
|
||||
QByteArray data;
|
||||
QString data;
|
||||
|
||||
if (tcpClient[busNum]) data = tcpClient[busNum]->readAll();
|
||||
if (tcpClient[busNum])
|
||||
data = QString(tcpClient[busNum]->readAll());
|
||||
//sendDebug("Got data from TCP. Len = " % QString::number(data.length()));
|
||||
//qDebug() << "Received datagramm: " << data;
|
||||
procRXData(data, busNum);
|
||||
}
|
||||
|
||||
|
||||
void SocketCANd::procRXData(QString data, int busNum)
|
||||
{
|
||||
if (data != "")
|
||||
|
||||
@@ -73,7 +73,6 @@ protected:
|
||||
int hostPort;
|
||||
QList<QString> hostCanIDs;
|
||||
int framesRapid;
|
||||
QByteArray buildData;
|
||||
QVarLengthArray<MODE> rx_state;
|
||||
CANFrame buildFrame;
|
||||
QVarLengthArray<QString> unprocessedData;
|
||||
|
||||
+66
-43
@@ -32,13 +32,13 @@ FrameSenderWindow::FrameSenderWindow(const QVector<CANFrame> *frames, QWidget *p
|
||||
createBlankRow();
|
||||
|
||||
connect(ui->tableSender, SIGNAL(cellChanged(int,int)), this, SLOT(onCellChanged(int,int)));
|
||||
connect(intervalTimer, SIGNAL(timeout()), this, SLOT(handleTick()));
|
||||
connect(intervalTimer, SIGNAL(timeout()), this, SLOT(handleTick()), Qt::QueuedConnection);
|
||||
connect(ui->btnClearGrid, SIGNAL(clicked(bool)), this, SLOT(clearGrid()));
|
||||
connect(ui->btnDisableAll, SIGNAL(clicked(bool)), this, SLOT(disableAll()));
|
||||
connect(ui->btnEnableAll, SIGNAL(clicked(bool)), this, SLOT(enableAll()));
|
||||
connect(ui->btnLoadGrid, SIGNAL(clicked(bool)), this, SLOT(loadGrid()));
|
||||
connect(ui->btnSaveGrid, SIGNAL(clicked(bool)), this, SLOT(saveGrid()));
|
||||
connect(MainWindow::getReference(), SIGNAL(framesUpdated(int)), this, SLOT(updatedFrames(int)));
|
||||
connect(MainWindow::getReference(), SIGNAL(framesUpdated(int)), this, SLOT(updatedFrames(int)), Qt::QueuedConnection);
|
||||
|
||||
intervalTimer->start();
|
||||
elapsedTimer.start();
|
||||
@@ -181,8 +181,8 @@ void FrameSenderWindow::processIncomingFrame(CANFrame *frame)
|
||||
for (int trig = 0; trig < sendingData[sd].triggers.count(); trig++)
|
||||
{
|
||||
Trigger *thisTrigger = &sendingData[sd].triggers[trig];
|
||||
qDebug() << "Trigger ID: " << thisTrigger->ID;
|
||||
qDebug() << "Frame ID: " << frame->frameId();
|
||||
//qDebug() << "Trigger ID: " << thisTrigger->ID;
|
||||
//qDebug() << "Frame ID: " << frame->frameId();
|
||||
if (thisTrigger->ID > 0 && (uint32_t)thisTrigger->ID == frame->frameId())
|
||||
{
|
||||
if (thisTrigger->bus == frame->bus || thisTrigger->bus == -1)
|
||||
@@ -195,7 +195,7 @@ void FrameSenderWindow::processIncomingFrame(CANFrame *frame)
|
||||
sendingData[sd].count++;
|
||||
doModifiers(sd);
|
||||
updateGridRow(sd);
|
||||
CANConManager::getInstance()->sendFrame(sendingData[sd]);
|
||||
CANConManager::getInstance()->sendFrame(CANFrame(sendingData[sd]));
|
||||
}
|
||||
else //delayed sending frame
|
||||
{
|
||||
@@ -290,6 +290,8 @@ void FrameSenderWindow::loadGrid()
|
||||
}
|
||||
}
|
||||
|
||||
createBlankRow();
|
||||
|
||||
setupGrid();
|
||||
}
|
||||
|
||||
@@ -424,44 +426,54 @@ void FrameSenderWindow::handleTick()
|
||||
{
|
||||
FrameSendData *sendData;
|
||||
Trigger *trigger;
|
||||
int elapsed = elapsedTimer.restart();
|
||||
if (elapsed == 0) elapsed = 1;
|
||||
//Modifier modifier;
|
||||
for (int i = 0; i < sendingData.count(); i++)
|
||||
if(mutex.tryLock())
|
||||
{
|
||||
sendData = &sendingData[i];
|
||||
if (!sendData->enabled)
|
||||
int elapsed = elapsedTimer.restart();
|
||||
if (elapsed == 0) elapsed = 1;
|
||||
//Modifier modifier;
|
||||
for (int i = 0; i < sendingData.count(); i++)
|
||||
{
|
||||
if (sendData->triggers.count() > 0)
|
||||
sendData = &sendingData[i];
|
||||
if (!sendData->enabled)
|
||||
{
|
||||
for (int j = 0; j < sendData->triggers.count(); j++) //resetting currCount when line is disabled
|
||||
if (sendData->triggers.count() > 0)
|
||||
{
|
||||
sendData->triggers[j].currCount = 0;
|
||||
for (int j = 0; j < sendData->triggers.count(); j++) //resetting currCount when line is disabled
|
||||
{
|
||||
sendData->triggers[j].currCount = 0;
|
||||
}
|
||||
}
|
||||
continue; //abort any processing on this if it is not enabled.
|
||||
}
|
||||
if (sendData->triggers.count() == 0) break;
|
||||
for (int j = 0; j < sendData->triggers.count(); j++)
|
||||
{
|
||||
trigger = &sendData->triggers[j];
|
||||
if (trigger->currCount >= trigger->maxCount) continue; //don't process if we've sent max frames we were supposed to
|
||||
if (!trigger->readyCount) continue; //don't tick if not ready to tick
|
||||
//is it time to fire?
|
||||
trigger->msCounter += elapsed; //gives proper tracking even if timer doesn't fire as fast as it should
|
||||
if (trigger->msCounter >= trigger->milliseconds)
|
||||
{
|
||||
trigger->msCounter = 0;
|
||||
sendData->count++;
|
||||
trigger->currCount++;
|
||||
doModifiers(i);
|
||||
updateGridRow(i);
|
||||
//qDebug() << "About to try to send a frame";
|
||||
CANConManager::getInstance()->sendFrame(sendingData[i]);
|
||||
if (trigger->ID > 0) trigger->readyCount = false; //reset flag if this is a timed ID trigger
|
||||
}
|
||||
}
|
||||
continue; //abort any processing on this if it is not enabled.
|
||||
}
|
||||
if (sendData->triggers.count() == 0) return;
|
||||
for (int j = 0; j < sendData->triggers.count(); j++)
|
||||
{
|
||||
trigger = &sendData->triggers[j];
|
||||
if (trigger->currCount >= trigger->maxCount) continue; //don't process if we've sent max frames we were supposed to
|
||||
if (!trigger->readyCount) continue; //don't tick if not ready to tick
|
||||
//is it time to fire?
|
||||
trigger->msCounter += elapsed; //gives proper tracking even if timer doesn't fire as fast as it should
|
||||
if (trigger->msCounter >= trigger->milliseconds)
|
||||
{
|
||||
trigger->msCounter = 0;
|
||||
sendData->count++;
|
||||
trigger->currCount++;
|
||||
doModifiers(i);
|
||||
updateGridRow(i);
|
||||
qDebug() << "About to try to send a frame";
|
||||
CANConManager::getInstance()->sendFrame(sendingData[i]);
|
||||
if (trigger->ID > 0) trigger->readyCount = false; //reset flag if this is a timed ID trigger
|
||||
}
|
||||
}
|
||||
|
||||
mutex.unlock();
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "framesenderwindow::handleTick() couldn't get mutex, elapsed is: " << elapsedTimer.elapsed();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -479,7 +491,7 @@ void FrameSenderWindow::doModifiers(int idx)
|
||||
|
||||
if (sendData->modifiers.count() == 0) return; //if no modifiers just leave right now
|
||||
|
||||
qDebug() << "Executing mods";
|
||||
//qDebug() << "Executing mods";
|
||||
|
||||
for (int i = 0; i < sendData->modifiers.count(); i++)
|
||||
{
|
||||
@@ -648,10 +660,10 @@ void FrameSenderWindow::processModifierText(int line)
|
||||
{
|
||||
thisOp.operation = parseOperation(operation);
|
||||
QString secondOp = Utility::grabAlphaNumeric(mods[i]);
|
||||
if (mods[i][0] == '~')
|
||||
if (secondOp.length() > 0 && secondOp[0] == '~')
|
||||
{
|
||||
thisOp.second.notOper = true;
|
||||
mods[i] = mods[i].remove(0, 1); //remove the ~ character
|
||||
secondOp = secondOp.remove(0, 1); //remove the ~ character
|
||||
}
|
||||
else thisOp.second.notOper = false;
|
||||
thisOp.second.bus = sendingData[line].bus;
|
||||
@@ -797,7 +809,7 @@ ModifierOperationType FrameSenderWindow::parseOperation(QString op)
|
||||
/// <param name="idx"></param>
|
||||
void FrameSenderWindow::updateGridRow(int idx)
|
||||
{
|
||||
qDebug() << "updateGridRow";
|
||||
//qDebug() << "updateGridRow";
|
||||
|
||||
inhibitChanged = true;
|
||||
FrameSendData *temp = &sendingData[idx];
|
||||
@@ -807,16 +819,27 @@ void FrameSenderWindow::updateGridRow(int idx)
|
||||
const unsigned char *data = reinterpret_cast<const unsigned char *>(temp->payload().constData());
|
||||
int dataLen = temp->payload().length();
|
||||
|
||||
if (item == nullptr) item = new QTableWidgetItem();
|
||||
item->setText(QString::number(temp->count));
|
||||
if (temp->frameType() != QCanBusFrame::RemoteRequestFrame) {
|
||||
if (item == nullptr)
|
||||
{
|
||||
//item = new QTableWidgetItem();
|
||||
//item->setText(QString::number(temp->count)); //crashes here ---qt_Static_metacall -> handleTick ->here
|
||||
}
|
||||
else
|
||||
{
|
||||
item->setText(QString::number(temp->count)); //crashes here ---qt_Static_metacall -> handleTick ->here
|
||||
}
|
||||
|
||||
if (temp->frameType() != QCanBusFrame::RemoteRequestFrame)
|
||||
{
|
||||
for (int i = 0; i < dataLen; i++)
|
||||
{
|
||||
dataString.append(Utility::formatNumber(data[i]));
|
||||
dataString.append(" ");
|
||||
}
|
||||
ui->tableSender->item(gridLine, 6)->setText(dataString);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->tableSender->item(gridLine, 6)->setText("");
|
||||
}
|
||||
inhibitChanged = false;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <QTimer>
|
||||
#include <QElapsedTimer>
|
||||
#include <QTime>
|
||||
#include <QMutex>
|
||||
#include "can_structs.h"
|
||||
#include "can_trigger_structs.h"
|
||||
|
||||
@@ -38,6 +39,7 @@ private:
|
||||
QTimer *intervalTimer;
|
||||
QElapsedTimer elapsedTimer;
|
||||
bool inhibitChanged = false;
|
||||
QMutex mutex;
|
||||
|
||||
void createBlankRow();
|
||||
void doModifiers(int);
|
||||
|
||||
@@ -24,6 +24,12 @@ public:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#ifdef QT_DEBUG
|
||||
qputenv("QT_FATAL_WARNINGS", "1");
|
||||
//qputenv("QT_MESSAGE_PATTERN", "Type: %{type}\nProduct Name: %{appname}\nFile: %{file}\nLine: %{line}\nMethod: %{function}\nThreadID: %{threadid}\nThreadPtr: %{qthreadptr}\nMessage: %{message}");
|
||||
qSetMessagePattern("Type: %{type}\nProduct Name: %{appname}\nFile: %{file}\nLine: %{line}\nMethod: %{function}\nThreadID: %{threadid}\nThreadPtr: %{qthreadptr}\nMessage: %{message}");
|
||||
#endif
|
||||
|
||||
SavvyCANApplication a(argc, argv);
|
||||
|
||||
//Add a local path for Qt extensions, to allow for per-application extensions.
|
||||
|
||||
+21
-5
@@ -441,6 +441,9 @@ void MainWindow::headerClicked(int logicalIndex)
|
||||
{
|
||||
//ui->canFramesView->sortByColumn(logicalIndex);
|
||||
model->sortByColumn(logicalIndex);
|
||||
|
||||
if(rowExpansionActive && model->getInterpretMode())
|
||||
ui->canFramesView->resizeRowsToContents();
|
||||
}
|
||||
|
||||
void MainWindow::expandAllRows()
|
||||
@@ -461,6 +464,8 @@ void MainWindow::expandAllRows()
|
||||
if (goAhead)
|
||||
{
|
||||
ui->canFramesView->resizeRowsToContents();
|
||||
|
||||
rowExpansionActive = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -482,6 +487,8 @@ void MainWindow::collapseAllRows()
|
||||
if (goAhead)
|
||||
{
|
||||
for (int i = 0; i < numRows; i++) ui->canFramesView->setRowHeight(i, normalRowHeight);
|
||||
|
||||
rowExpansionActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -679,6 +686,9 @@ void MainWindow::filterListItemChanged(QListWidgetItem *item)
|
||||
if (item->checkState() == Qt::Checked) isSet = true;
|
||||
|
||||
model->setFilterState(ID, isSet);
|
||||
|
||||
if(rowExpansionActive && model->getInterpretMode())
|
||||
ui->canFramesView->resizeRowsToContents();
|
||||
}
|
||||
|
||||
void MainWindow::busFilterListItemChanged(QListWidgetItem *item)
|
||||
@@ -692,6 +702,9 @@ void MainWindow::busFilterListItemChanged(QListWidgetItem *item)
|
||||
if (item->checkState() == Qt::Checked) isSet = true;
|
||||
|
||||
model->setBusFilterState(ID, isSet);
|
||||
|
||||
if(rowExpansionActive && model->getInterpretMode())
|
||||
ui->canFramesView->resizeRowsToContents();
|
||||
}
|
||||
|
||||
void MainWindow::filterSetAll()
|
||||
@@ -703,6 +716,9 @@ void MainWindow::filterSetAll()
|
||||
}
|
||||
inhibitFilterUpdate = false;
|
||||
model->setAllFilters(true);
|
||||
|
||||
if(rowExpansionActive && model->getInterpretMode())
|
||||
ui->canFramesView->resizeRowsToContents();
|
||||
}
|
||||
|
||||
void MainWindow::filterClearAll()
|
||||
@@ -794,7 +810,7 @@ void MainWindow::addFrameToDisplay(CANFrame &frame, bool autoRefresh = false)
|
||||
|
||||
//A sub-window is sending us a center on timestamp and ID signal
|
||||
//try to find the relevant frame in the list and focus on it.
|
||||
void MainWindow::gotCenterTimeID(int32_t ID, double timestamp)
|
||||
void MainWindow::gotCenterTimeID(uint32_t ID, double timestamp)
|
||||
{
|
||||
int idx = model->getIndexFromTimeID(ID, timestamp);
|
||||
if (idx > -1)
|
||||
@@ -1150,13 +1166,13 @@ void MainWindow::showGraphingWindow()
|
||||
lastGraphingWindow = new GraphingWindow(model->getListReference());
|
||||
graphWindows.append(lastGraphingWindow);
|
||||
|
||||
connect(lastGraphingWindow, SIGNAL(sendCenterTimeID(uint32_t,double)), this, SLOT(gotCenterTimeID(int32_t,double)));
|
||||
connect(this, SIGNAL(sendCenterTimeID(uint32_t,double)), lastGraphingWindow, SLOT(gotCenterTimeID(int32_t,double)));
|
||||
connect(lastGraphingWindow, SIGNAL(sendCenterTimeID(uint32_t,double)), this, SLOT(gotCenterTimeID(uint32_t,double)));
|
||||
connect(this, SIGNAL(sendCenterTimeID(uint32_t,double)), lastGraphingWindow, SLOT(gotCenterTimeID(uint32_t,double)));
|
||||
|
||||
if (flowViewWindow) //connect the two external windows together
|
||||
{
|
||||
connect(lastGraphingWindow, SIGNAL(sendCenterTimeID(uint32_t,double)), flowViewWindow, SLOT(gotCenterTimeID(int32_t,double)));
|
||||
connect(flowViewWindow, SIGNAL(sendCenterTimeID(uint32_t,double)), lastGraphingWindow, SLOT(gotCenterTimeID(int32_t,double)));
|
||||
connect(lastGraphingWindow, SIGNAL(sendCenterTimeID(uint32_t,double)), flowViewWindow, SLOT(gotCenterTimeID(uint32_t,double)));
|
||||
connect(flowViewWindow, SIGNAL(sendCenterTimeID(uint32_t,double)), lastGraphingWindow, SLOT(gotCenterTimeID(uint32_t,double)));
|
||||
}
|
||||
|
||||
lastGraphingWindow->show();
|
||||
|
||||
+2
-1
@@ -116,7 +116,7 @@ public slots:
|
||||
void gotFrames(int);
|
||||
void updateSettings();
|
||||
void readUpdateableSettings();
|
||||
void gotCenterTimeID(int32_t ID, double timestamp);
|
||||
void gotCenterTimeID(uint32_t ID, double timestamp);
|
||||
void updateConnectionSettings(QString connectionType, QString port, int speed0, int speed1);
|
||||
|
||||
signals:
|
||||
@@ -191,6 +191,7 @@ private:
|
||||
int normalRowHeight;
|
||||
bool isConnected;
|
||||
QPoint contextMenuPosition;
|
||||
bool rowExpansionActive = false;
|
||||
|
||||
//private methods
|
||||
QString getSignalNameFromPosition(QPoint pos);
|
||||
|
||||
@@ -298,7 +298,7 @@ void FlowViewWindow::plottableDoubleClick(QCPAbstractPlottable* plottable, QMous
|
||||
else emit sendCenterTimeID(id, coord / 1000000.0);
|
||||
}
|
||||
|
||||
void FlowViewWindow::gotCenterTimeID(int32_t ID, double timestamp)
|
||||
void FlowViewWindow::gotCenterTimeID(uint32_t ID, double timestamp)
|
||||
{
|
||||
int64_t t_stamp;
|
||||
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ private slots:
|
||||
void saveFileFlow();
|
||||
void saveFileGraph();
|
||||
void plottableDoubleClick(QCPAbstractPlottable* plottable, QMouseEvent* event);
|
||||
void gotCenterTimeID(int32_t ID, double timestamp);
|
||||
void gotCenterTimeID(uint32_t ID, double timestamp);
|
||||
void updateTriggerValues();
|
||||
void gotCellClick(int x, int y);
|
||||
void graphRangeChanged(int range);
|
||||
|
||||
@@ -281,7 +281,7 @@ void GraphingWindow::plottableDoubleClick(QCPAbstractPlottable* plottable, int d
|
||||
locationText->setText("X: " + QString::number(x) + " Y: " + QString::number(itemTracer->position->value()));
|
||||
}
|
||||
|
||||
void GraphingWindow::gotCenterTimeID(int32_t ID, double timestamp)
|
||||
void GraphingWindow::gotCenterTimeID(uint32_t ID, double timestamp)
|
||||
{
|
||||
Q_UNUSED(ID)
|
||||
//its problematic to try to highlight a graph since we get the ID
|
||||
|
||||
+1
-1
@@ -81,7 +81,7 @@ private slots:
|
||||
void appendToGraph(GraphParams ¶ms, CANFrame &frame, QVector<double> &x, QVector<double> &y);
|
||||
void editSelectedGraph();
|
||||
void updatedFrames(int);
|
||||
void gotCenterTimeID(int32_t ID, double timestamp);
|
||||
void gotCenterTimeID(uint32_t ID, double timestamp);
|
||||
void resetView();
|
||||
void zoomIn();
|
||||
void zoomOut();
|
||||
|
||||
Reference in New Issue
Block a user