Several changes suggested in draft pull requests from llange. Fix some
ambiguous places, fix warnings, fix errors when trying to compile with QT6
This commit is contained in:
@@ -109,16 +109,16 @@ void ConnectionWindow::readPendingDatagrams()
|
||||
while(!CANBeaconXml.atEnd() && !CANBeaconXml.hasError())
|
||||
{
|
||||
CANBeaconXml.readNext();
|
||||
if(CANBeaconXml.name() == "CANBeacon" && !CANBeaconXml.isEndElement())
|
||||
if(CANBeaconXml.name() == QString("CANBeacon") && !CANBeaconXml.isEndElement())
|
||||
KayakHost.append(CANBeaconXml.attributes().value("name"));
|
||||
|
||||
if(CANBeaconXml.name() == "URL")
|
||||
if(CANBeaconXml.name() == QString("URL"))
|
||||
KayakHost.append(" (" + CANBeaconXml.readElementText() + ')');
|
||||
|
||||
//Kayak can theoretically send multiple busses over one ports
|
||||
//TODO: implement this case in socketcand.cpp
|
||||
if(CANBeaconXml.name() == "Bus" && !CANBeaconXml.isEndElement())
|
||||
KayakBus.append(CANBeaconXml.attributes().value("name") + ",");
|
||||
if(CANBeaconXml.name() == QString("Bus") && !CANBeaconXml.isEndElement())
|
||||
KayakBus.append(CANBeaconXml.attributes().value("name").toUtf8() + ",");
|
||||
|
||||
}
|
||||
KayakHost = KayakBus.left(KayakBus.length() - 1) + "@" + KayakHost;
|
||||
|
||||
@@ -266,7 +266,7 @@ QString SocketCANd::decodeFrames(QString data, int busNum)
|
||||
QString framePart = data.mid(firstIndex); //remove starting beginning of payload if not < frame >
|
||||
const QString frameStrConst = framePart.left(framePart.indexOf(">")+1);
|
||||
QString frameStr = frameStrConst;
|
||||
QStringList frameParsed = (frameStr.remove(QRegExp("^<")).remove(QRegExp(">$"))).simplified().split(' ');
|
||||
QStringList frameParsed = (frameStr.remove(QRegularExpression("^<")).remove(QRegularExpression(">$"))).simplified().split(' ');
|
||||
|
||||
if(frameParsed.length() < 3)
|
||||
{
|
||||
|
||||
+4
-4
@@ -2249,14 +2249,14 @@ DBCHandler::DBCHandler()
|
||||
qDebug() << "Previously loaded DBC file count: " << filecount;
|
||||
for (int i=0; i<filecount; i++)
|
||||
{
|
||||
QString filename = settings.value("DBC/Filename_" + QString(i),"").toString();
|
||||
QString filename = settings.value("DBC/Filename_" + QString::number(i),"").toString();
|
||||
DBCFile * file = loadDBCFile(filename);
|
||||
if (file)
|
||||
{
|
||||
int bus = settings.value("DBC/AssocBus_" + QString(i),0).toInt();
|
||||
int bus = settings.value("DBC/AssocBus_" + QString::number(i),0).toInt();
|
||||
file->setAssocBus(bus);
|
||||
|
||||
MatchingCriteria_t matchingCriteria = (MatchingCriteria_t)settings.value("DBC/MatchingCriteria_" + QString(i),0).toInt();
|
||||
MatchingCriteria_t matchingCriteria = (MatchingCriteria_t)settings.value("DBC/MatchingCriteria_" + QString::number(i),0).toInt();
|
||||
|
||||
DBC_ATTRIBUTE attr;
|
||||
|
||||
@@ -2270,7 +2270,7 @@ DBCHandler::DBCHandler()
|
||||
file->dbc_attributes.append(attr);
|
||||
file->messageHandler->setMatchingCriteria(matchingCriteria);
|
||||
|
||||
bool filterLabeling = settings.value("DBC/FilterLabeling_" + QString(i),0).toBool();
|
||||
bool filterLabeling = settings.value("DBC/FilterLabeling_" + QString::number(i),0).toBool();
|
||||
attr.attrType = ATTR_TYPE_MESSAGE;
|
||||
attr.defaultValue = filterLabeling;
|
||||
attr.enumVals.clear();
|
||||
|
||||
@@ -108,10 +108,10 @@ void DBCLoadSaveWindow::updateSettings()
|
||||
qDebug() << "Save DBC settings #" << i << " File: " << file->getFullFilename()
|
||||
<< "Bus: " << file->getAssocBus() << "MC: " << file->messageHandler->getMatchingCriteria()
|
||||
<< "Filter Labeling: " << (file->messageHandler->filterLabeling() ? "enabled" : "disabled");
|
||||
settings.setValue("DBC/Filename_" + QString(i), file->getFullFilename());
|
||||
settings.setValue("DBC/AssocBus_" + QString(i), file->getAssocBus());
|
||||
settings.setValue("DBC/MatchingCriteria_" + QString(i), file->messageHandler->getMatchingCriteria());
|
||||
settings.setValue("DBC/FilterLabeling_" + QString(i), file->messageHandler->filterLabeling());
|
||||
settings.setValue("DBC/Filename_" + QString::number(i), file->getFullFilename());
|
||||
settings.setValue("DBC/AssocBus_" + QString::number(i), file->getAssocBus());
|
||||
settings.setValue("DBC/MatchingCriteria_" + QString::number(i), file->messageHandler->getMatchingCriteria());
|
||||
settings.setValue("DBC/FilterLabeling_" + QString::number(i), file->messageHandler->filterLabeling());
|
||||
}
|
||||
}
|
||||
emit updatedDBCSettings();
|
||||
@@ -200,7 +200,7 @@ void DBCLoadSaveWindow::loadFile()
|
||||
|
||||
DBC_ATTRIBUTE *attr = file->findAttributeByName("matchingcriteria");
|
||||
QComboBox * mc_item = addMatchingCriteriaCombobox(idx);
|
||||
if (attr && attr->defaultValue > 0)
|
||||
if (attr && attr->defaultValue.toInt() > 0)
|
||||
{
|
||||
mc_item->setCurrentIndex(attr->defaultValue.toInt());
|
||||
}
|
||||
@@ -208,7 +208,7 @@ void DBCLoadSaveWindow::loadFile()
|
||||
attr = file->findAttributeByName("filterlabeling");
|
||||
QTableWidgetItem *item = new QTableWidgetItem("");
|
||||
ui->tableFiles->setItem(idx, 3, item);
|
||||
if (attr && attr->defaultValue > 0)
|
||||
if (attr && attr->defaultValue.toInt() > 0)
|
||||
{
|
||||
item->setCheckState(Qt::Checked);
|
||||
}
|
||||
|
||||
+41
-34
@@ -867,7 +867,7 @@ bool FrameFileIO::loadCARBUSAnalyzerFile(QString filename, QVector<CANFrame>* fr
|
||||
line = txt.readLine().simplified();
|
||||
if (line.length() > 2)
|
||||
{
|
||||
QList<QString> tokens = line.split(QRegExp("\\s+"));
|
||||
QList<QString> tokens = line.split(QRegularExpression("\\s+"));
|
||||
if (tokens.length() > 3)
|
||||
{
|
||||
QString time = tokens[0].replace(",", "");
|
||||
@@ -3507,9 +3507,9 @@ bool FrameFileIO::isCanDumpFile(QString filename)
|
||||
QFile *inFile = new QFile(filename);
|
||||
QByteArray line;
|
||||
QList<QByteArray> tokens;
|
||||
QRegExp timeExp("^\\((\\S+)\\)$");
|
||||
QRegExp IdValExp("^(\\S+)#(\\S+)$");
|
||||
QRegExp valExp("(\\S{2})");
|
||||
QRegularExpression timeExp(QRegularExpression::anchoredPattern("^\\((\\S+)\\)$")); //anchored pattern causes exact match
|
||||
QRegularExpression IdValExp(QRegularExpression::anchoredPattern("^(\\S+)#(\\S+)$"));
|
||||
QRegularExpression valExp("(\\S{2})");
|
||||
int lineCounter = 0;
|
||||
int pos = 0;
|
||||
bool isMatch = true;
|
||||
@@ -3534,11 +3534,13 @@ bool FrameFileIO::isCanDumpFile(QString filename)
|
||||
tokens = line.simplified().split(' ');
|
||||
if(tokens.count() < 3) isMatch = false;
|
||||
|
||||
/* timestamp */
|
||||
ret = timeExp.exactMatch(tokens[0]);
|
||||
if(!ret) isMatch = false;
|
||||
/* timestamp */
|
||||
QRegularExpressionMatch timeExpMatched = timeExp.match(tokens[0]);
|
||||
if(!timeExpMatched.hasMatch()) {
|
||||
isMatch = false;
|
||||
}
|
||||
|
||||
/*uint64_t timestamp = (uint64_t)*/(timeExp.cap(1).toDouble(&ret) /** (double)1000000.0*/);
|
||||
/*uint64_t timestamp = (uint64_t)*/(timeExpMatched.captured(1).toDouble(&ret) /** (double)1000000.0*/);
|
||||
if(!ret) isMatch = false;
|
||||
|
||||
if (line.contains('[')) //the expanded format
|
||||
@@ -3568,17 +3570,19 @@ bool FrameFileIO::isCanDumpFile(QString filename)
|
||||
isMatch = false;
|
||||
continue;
|
||||
}
|
||||
ret = IdValExp.exactMatch(tokens[2]);
|
||||
if(!ret)
|
||||
|
||||
|
||||
QRegularExpressionMatch IdValExpMatched = IdValExp.match(tokens[2]);
|
||||
if(!IdValExpMatched.hasMatch())
|
||||
{
|
||||
isMatch = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* ID */
|
||||
/*int ID = */IdValExp.cap(1).toInt(&ret, 16);
|
||||
/*int ID = */IdValExpMatched.captured(1).toInt(&ret, 16);
|
||||
|
||||
QString val= IdValExp.cap(2);
|
||||
QString val= IdValExpMatched.captured(2);
|
||||
|
||||
pos = 0;
|
||||
int len = 0;
|
||||
@@ -3592,22 +3596,23 @@ bool FrameFileIO::isCanDumpFile(QString filename)
|
||||
} else {
|
||||
/* val byte per byte */
|
||||
int lng = 0;
|
||||
while ((pos = valExp.indexIn(val, pos)) != -1)
|
||||
{
|
||||
QRegularExpressionMatch valExpMatch;
|
||||
QRegularExpressionMatchIterator i = valExp.globalMatch(val);
|
||||
while (i.hasNext()) {
|
||||
valExpMatch = i.next();
|
||||
lng++;
|
||||
if (lng > 8)
|
||||
{
|
||||
isMatch = false;
|
||||
break;
|
||||
}
|
||||
/*int data = */valExp.cap(1).toInt(&ret, 16);
|
||||
/*int data = */valExpMatch.captured(1).toInt(&ret, 16);
|
||||
if(!ret)
|
||||
{
|
||||
isMatch = false;
|
||||
break;
|
||||
}
|
||||
|
||||
pos += valExp.matchedLength();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3634,11 +3639,10 @@ bool FrameFileIO::loadCanDumpFile(QString filename, QVector<CANFrame>* frames)
|
||||
CANFrame thisFrame;
|
||||
QByteArray line;
|
||||
QList<QByteArray> tokens;
|
||||
QRegExp timeExp("^\\((\\S+)\\)$");
|
||||
QRegExp IdValExp("^(\\S+)#(\\S+)$");
|
||||
QRegExp valExp("(\\S{2})");
|
||||
QRegularExpression timeExp(QRegularExpression::anchoredPattern("^\\((\\S+)\\)$")); //anchored pattern causes exact match
|
||||
QRegularExpression IdValExp(QRegularExpression::anchoredPattern("^(\\S+)#(\\S+)$"));
|
||||
QRegularExpression valExp("(\\S{2})");
|
||||
int lineCounter = 0;
|
||||
int pos = 0;
|
||||
bool ret;
|
||||
|
||||
if (!inFile->open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
@@ -3664,8 +3668,8 @@ bool FrameFileIO::loadCanDumpFile(QString filename, QVector<CANFrame>* frames)
|
||||
if(tokens.count()<3) continue;
|
||||
|
||||
/* timestamp */
|
||||
ret = timeExp.exactMatch(tokens[0]);
|
||||
if(!ret) continue;
|
||||
QRegularExpressionMatch timeExpMatched = timeExp.match(tokens[0]);
|
||||
if(!timeExpMatched.hasMatch()) continue;
|
||||
|
||||
//Sort out the bus
|
||||
std::string busString = tokens[1].toStdString();
|
||||
@@ -3686,7 +3690,7 @@ bool FrameFileIO::loadCanDumpFile(QString filename, QVector<CANFrame>* frames)
|
||||
|
||||
thisFrame.bus = busNum;
|
||||
|
||||
thisFrame.setTimeStamp(QCanBusFrame::TimeStamp(0, (uint64_t)(timeExp.cap(1).toDouble(&ret) * (double)1000000.0)));
|
||||
thisFrame.setTimeStamp(QCanBusFrame::TimeStamp(0, (uint64_t)(timeExpMatched.captured(1).toDouble(&ret) * (double)1000000.0)));
|
||||
if(!ret) continue;
|
||||
|
||||
if (line.contains('[')) //the expanded format (second one from the above list)
|
||||
@@ -3709,24 +3713,26 @@ bool FrameFileIO::loadCanDumpFile(QString filename, QVector<CANFrame>* frames)
|
||||
{
|
||||
/* ID & value */
|
||||
//qDebug() << tokens[2];
|
||||
ret = IdValExp.exactMatch(tokens[2]);
|
||||
if(!ret)
|
||||
QRegularExpressionMatch IdValExpMatched = IdValExp.match(tokens[2]);
|
||||
if(!IdValExpMatched.hasMatch())
|
||||
{
|
||||
qDebug() << "ID regex didn't match!";
|
||||
continue;
|
||||
}
|
||||
|
||||
/* ID */
|
||||
thisFrame.setFrameId(static_cast<uint32_t>(IdValExp.cap(1).toInt(&ret, 16)));
|
||||
if (IdValExp.cap(1).length() > 3) {
|
||||
thisFrame.setFrameId(static_cast<uint32_t>(IdValExpMatched.captured(1).toInt(&ret, 16)));
|
||||
if (IdValExpMatched.captured(1).length() > 3)
|
||||
{
|
||||
thisFrame.setExtendedFrameFormat(true);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
thisFrame.setExtendedFrameFormat(false);
|
||||
}
|
||||
|
||||
QString val= IdValExp.cap(2);
|
||||
QString val = IdValExpMatched.captured(2);
|
||||
|
||||
pos = 0;
|
||||
QByteArray bytes;
|
||||
if (val.startsWith("R") && val.at(1).isDigit()) {
|
||||
thisFrame.payload().resize( val.at(1).toLatin1() - '0' );
|
||||
@@ -3734,12 +3740,13 @@ bool FrameFileIO::loadCanDumpFile(QString filename, QVector<CANFrame>* frames)
|
||||
} else {
|
||||
thisFrame.setFrameType(QCanBusFrame::DataFrame);
|
||||
/* val byte per byte */
|
||||
while ((pos = valExp.indexIn(val, pos)) != -1)
|
||||
QRegularExpressionMatch valExpMatch;
|
||||
QRegularExpressionMatchIterator i = valExp.globalMatch(val);
|
||||
while (i.hasNext())
|
||||
{
|
||||
bytes.append((char)valExp.cap(1).toInt(&ret, 16));
|
||||
valExpMatch = i.next();
|
||||
bytes.append((char)valExpMatch.captured(1).toInt(&ret, 16));
|
||||
if(!ret) continue;
|
||||
|
||||
pos += valExp.matchedLength();
|
||||
}
|
||||
}
|
||||
thisFrame.setPayload(bytes);
|
||||
|
||||
+3
-3
@@ -263,7 +263,7 @@ void CANScriptHelper::gotTargettedFrame(const CANFrame &frame)
|
||||
if (filters[i].checkFilter(frame.frameId(), frame.bus))
|
||||
{
|
||||
QJSValueList args;
|
||||
args << frame.bus << frame.frameId() << frame.payload().length();
|
||||
args << frame.bus << frame.frameId() << static_cast<uint>(frame.payload().length());
|
||||
QJSValue dataBytes = scriptEngine->newArray(dataLen);
|
||||
|
||||
for (int j = 0; j < dataLen; j++) dataBytes.setProperty(j, QJSValue(data[j]));
|
||||
@@ -341,7 +341,7 @@ void ISOTPScriptHelper::newISOMessage(ISOTP_MESSAGE msg)
|
||||
//qDebug() << "Got frame in script interface";
|
||||
|
||||
QJSValueList args;
|
||||
args << msg.bus << msg.frameId() << msg.payload().length();
|
||||
args << msg.bus << msg.frameId() << static_cast<uint>(msg.payload().length());
|
||||
QJSValue dataBytes = scriptEngine->newArray(static_cast<uint>(msg.payload().length()));
|
||||
|
||||
for (int j = 0; j < msg.payload().length(); j++) dataBytes.setProperty(static_cast<quint32>(j), QJSValue((unsigned char)msg.payload()[j]));
|
||||
@@ -420,7 +420,7 @@ void UDSScriptHelper::newUDSMessage(UDS_MESSAGE msg)
|
||||
qDebug() << "Got frame in script interface";
|
||||
|
||||
QJSValueList args;
|
||||
args << msg.bus << msg.frameId() << msg.service << msg.subFunc << msg.payload().length();
|
||||
args << msg.bus << msg.frameId() << msg.service << msg.subFunc << static_cast<uint>(msg.payload().length());
|
||||
QJSValue dataBytes = scriptEngine->newArray(static_cast<unsigned int>(msg.payload().length()));
|
||||
|
||||
for (int j = 0; j < msg.payload().length(); j++) dataBytes.setProperty(static_cast<quint32>(j), QJSValue((unsigned char)msg.payload()[j]));
|
||||
|
||||
Reference in New Issue
Block a user