- Save DBC file configuration when changed, and restore it when restarting the application (no need for manual entry everytime app is launched)
- Add GMLAN 29bit filtering feature. In addition to J1939 matching, it is now possible to match DBC messages using only the Arbitration Id (bits 14-26 of CAN Address), since Priority id (higher bits) and Sender Id (lowest 13 bits) are not relevant when interpreting the CAN message content. This allows to use the excellent GM Global A DBC files on https://github.com/commaai/opendbc. Just remember to select the "GMLAN" matching criteria on DBC File manager. - Add "Filter labeling" feature. Using loaded DBC files, it matches the filter Ids with DBC messages and shows them in filter windows. Labeling works in the main window (no need to set "Frame interpret" on, since this is a separate feature), as well as in Flow view, Frame data analysis, Playback and Fuzzzing windows. This makes it so much easier to concentrate on those CAN messages that matter. To use this feature, select global "Label filters using messages from DBC files" on Main Configuration page, and then enable the feature on individual DBC files (on DBC file manager) as needed. This is needed if there's overlap in CAN addresses between DBC files, and because the filter labeler cannot tell apart anymore which Filter ID is associated to which bus, it might label them incorrectly. But usually it's ok to just enable the labeling with all the DBC files. - In Frame data analysis window, in addition to J1939 decoding show also GMLAN (Priority bits, Arbitration Id, Sender Id) decoding. - FilterUtility static class used for centralized ListWidgetItem creation and for other helper functions - DBC handler: To allow setting bus numbers even before connection is configured, do not enforce "valid" bus numbers
This commit is contained in:
+124
-19
@@ -87,7 +87,7 @@ DBC_MESSAGE* DBCMessageHandler::findMsgByID(uint32_t id)
|
||||
if (messages.count() == 0) return nullptr;
|
||||
for (int i = 0; i < messages.count(); i++)
|
||||
{
|
||||
if (isJ1939Handler)
|
||||
if (matchingCriteria == J1939)
|
||||
{
|
||||
// include data page and extended data page in the pgn
|
||||
uint32_t pgn = (id & 0x3FFFF00) >> 8;
|
||||
@@ -109,6 +109,13 @@ DBC_MESSAGE* DBCMessageHandler::findMsgByID(uint32_t id)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (matchingCriteria == GMLAN)
|
||||
{
|
||||
// Match the bits 14-26 (Arbitration Id) of GMLAN 29bit header
|
||||
uint32_t arbId = id &0x3FFE000;
|
||||
if ( (arbId != 0) && (messages[i].ID & 0x3FFE000) == arbId )
|
||||
return &messages[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( messages[i].ID == id )
|
||||
@@ -203,20 +210,31 @@ int DBCMessageHandler::getCount()
|
||||
return messages.count();
|
||||
}
|
||||
|
||||
bool DBCMessageHandler::isJ1939()
|
||||
bool DBCMessageHandler::filterLabeling()
|
||||
{
|
||||
return isJ1939Handler;
|
||||
return filterLabelingEnabled;
|
||||
}
|
||||
|
||||
void DBCMessageHandler::setJ1939(bool j1939)
|
||||
void DBCMessageHandler::setFilterLabeling(bool filterLabeling)
|
||||
{
|
||||
isJ1939Handler = j1939;
|
||||
filterLabelingEnabled = filterLabeling;
|
||||
}
|
||||
|
||||
MatchingCriteria_t DBCMessageHandler::getMatchingCriteria()
|
||||
{
|
||||
return matchingCriteria;
|
||||
}
|
||||
|
||||
void DBCMessageHandler::setMatchingCriteria(MatchingCriteria_t _matchingCriteria)
|
||||
{
|
||||
matchingCriteria = _matchingCriteria;
|
||||
}
|
||||
|
||||
DBCFile::DBCFile()
|
||||
{
|
||||
messageHandler = new DBCMessageHandler;
|
||||
messageHandler->setJ1939(false);
|
||||
messageHandler->setMatchingCriteria(EXACT);
|
||||
messageHandler->setFilterLabeling(false);
|
||||
}
|
||||
|
||||
DBCFile::DBCFile(const DBCFile& cpy) : QObject()
|
||||
@@ -225,7 +243,8 @@ DBCFile::DBCFile(const DBCFile& cpy) : QObject()
|
||||
for (int i = 0 ; i < cpy.messageHandler->getCount() ; i++)
|
||||
messageHandler->addMessage(*cpy.messageHandler->findMsgByIdx(i));
|
||||
|
||||
messageHandler->setJ1939(cpy.messageHandler->isJ1939());
|
||||
messageHandler->setMatchingCriteria(cpy.messageHandler->getMatchingCriteria());
|
||||
messageHandler->setFilterLabeling(cpy.messageHandler->filterLabeling());
|
||||
fileName = cpy.fileName;
|
||||
filePath = cpy.filePath;
|
||||
assocBuses = cpy.assocBuses;
|
||||
@@ -293,9 +312,10 @@ int DBCFile::getAssocBus()
|
||||
|
||||
void DBCFile::setAssocBus(int bus)
|
||||
{
|
||||
int numBuses = CANConManager::getInstance()->getNumBuses();
|
||||
if (bus < -1) return;
|
||||
if (bus >= numBuses) return;
|
||||
// To allow setting bus numbers even before connection is configured, do not enforce "valid" bus numbers
|
||||
//int numBuses = CANConManager::getInstance()->getNumBuses();
|
||||
//if (bus >= numBuses) return;
|
||||
assocBuses = bus;
|
||||
}
|
||||
|
||||
@@ -690,7 +710,8 @@ void DBCFile::loadFile(QString fileName)
|
||||
qDebug() << "Starting DBC load";
|
||||
dbc_nodes.clear();
|
||||
messageHandler->removeAllMessages();
|
||||
messageHandler->setJ1939(false);
|
||||
messageHandler->setMatchingCriteria(EXACT);
|
||||
messageHandler->setFilterLabeling(false);
|
||||
|
||||
DBC_NODE falseNode;
|
||||
falseNode.name = "Vector__XXX";
|
||||
@@ -884,14 +905,24 @@ void DBCFile::loadFile(QString fileName)
|
||||
fgAttr = findAttributeByName("GenMsgForegroundColor");
|
||||
}
|
||||
|
||||
DBC_ATTRIBUTE *j1939attr = findAttributeByName("isj1939dbc");
|
||||
if (j1939attr)
|
||||
DBC_ATTRIBUTE *mc_attr = findAttributeByName("matchingcriteria");
|
||||
if (mc_attr)
|
||||
{
|
||||
messageHandler->setJ1939(j1939attr->defaultValue > 0);
|
||||
messageHandler->setMatchingCriteria((MatchingCriteria_t)mc_attr->defaultValue.toInt());
|
||||
}
|
||||
else
|
||||
{
|
||||
messageHandler->setJ1939(false);
|
||||
messageHandler->setMatchingCriteria(EXACT);
|
||||
}
|
||||
|
||||
DBC_ATTRIBUTE *fl_attr = findAttributeByName("filterlabeling");
|
||||
if (fl_attr)
|
||||
{
|
||||
messageHandler->setFilterLabeling(fl_attr->defaultValue.toInt());
|
||||
}
|
||||
else
|
||||
{
|
||||
messageHandler->setFilterLabeling(false);
|
||||
}
|
||||
|
||||
QColor DefaultBG = QColor(bgAttr->defaultValue.toString());
|
||||
@@ -1397,7 +1428,16 @@ int DBCHandler::createBlankFile()
|
||||
attr.enumVals.clear();
|
||||
attr.lower = 0;
|
||||
attr.upper = 0;
|
||||
attr.name = "isj1939dbc";
|
||||
attr.name = "matchingcriteria";
|
||||
attr.valType = QINT;
|
||||
newFile.dbc_attributes.append(attr);
|
||||
|
||||
attr.attrType = MESSAGE;
|
||||
attr.defaultValue = 0;
|
||||
attr.enumVals.clear();
|
||||
attr.lower = 0;
|
||||
attr.upper = 0;
|
||||
attr.name = "filterlabeling";
|
||||
attr.valType = QINT;
|
||||
newFile.dbc_attributes.append(attr);
|
||||
|
||||
@@ -1405,6 +1445,14 @@ int DBCHandler::createBlankFile()
|
||||
return loadedFiles.count();
|
||||
}
|
||||
|
||||
DBCFile* DBCHandler::loadDBCFile(QString filename)
|
||||
{
|
||||
DBCFile newFile;
|
||||
newFile.loadFile(filename);
|
||||
loadedFiles.append(newFile);
|
||||
return &loadedFiles.last();
|
||||
}
|
||||
|
||||
//the only reason to even bother sending the index is to see if
|
||||
//the user wants to replace an already loaded DBC.
|
||||
//Otherwise add a new one. Well, always add a new one.
|
||||
@@ -1430,11 +1478,8 @@ DBCFile* DBCHandler::loadDBCFile(int idx)
|
||||
{
|
||||
filename = dialog.selectedFiles()[0];
|
||||
//right now there is only one file type that can be loaded here so just do it.
|
||||
DBCFile newFile;
|
||||
newFile.loadFile(filename);
|
||||
loadedFiles.append(newFile);
|
||||
settings.setValue("DBC/LoadSaveDirectory", dialog.directory().path());
|
||||
return &loadedFiles.last();
|
||||
return loadDBCFile(filename);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
@@ -1483,6 +1528,29 @@ DBC_MESSAGE* DBCHandler::findMessage(const CANFrame &frame)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
// This function won't care which bus the DBC file is associated, but will return any message as long as ID matches and the file
|
||||
// has filter labeling enabled.
|
||||
// Returns the found message as well as the matching criteria (exact/J1939/GMLAN)
|
||||
// Used for quickly populating the Frame Filtering section with interpreted values
|
||||
DBC_MESSAGE* DBCHandler::findMessageForFilter(uint32_t id, MatchingCriteria_t * matchingCriteria)
|
||||
{
|
||||
for(int i = 0; i < loadedFiles.count(); i++)
|
||||
{
|
||||
if (loadedFiles[i].messageHandler->filterLabeling())
|
||||
{
|
||||
DBC_MESSAGE* msg = loadedFiles[i].messageHandler->findMsgByID(id);
|
||||
if (msg != nullptr)
|
||||
{
|
||||
*matchingCriteria = loadedFiles[i].messageHandler->getMatchingCriteria();
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* As above, a real shortcut function that searches all files in order to try to find a message with the given name
|
||||
*/
|
||||
@@ -1526,7 +1594,44 @@ DBCFile* DBCHandler::getFileByName(QString name)
|
||||
|
||||
DBCHandler::DBCHandler()
|
||||
{
|
||||
// Load previously saved DBC file settings
|
||||
QSettings settings;
|
||||
int filecount = settings.value("DBC/FileCount", 0).toInt();
|
||||
for (int i=0; i<filecount; i++)
|
||||
{
|
||||
QString filename = settings.value("DBC/Filename_" + QString(i),"").toString();
|
||||
DBCFile * file = loadDBCFile(filename);
|
||||
int bus = settings.value("DBC/AssocBus_" + QString(i),0).toInt();
|
||||
file->setAssocBus(bus);
|
||||
|
||||
MatchingCriteria_t matchingCriteria = (MatchingCriteria_t)settings.value("DBC/MatchingCriteria_" + QString(i),0).toInt();
|
||||
|
||||
DBC_ATTRIBUTE attr;
|
||||
|
||||
attr.attrType = MESSAGE;
|
||||
attr.defaultValue = matchingCriteria;
|
||||
attr.enumVals.clear();
|
||||
attr.lower = 0;
|
||||
attr.upper = 0;
|
||||
attr.name = "matchingcriteria";
|
||||
attr.valType = QINT;
|
||||
file->dbc_attributes.append(attr);
|
||||
file->messageHandler->setMatchingCriteria(matchingCriteria);
|
||||
|
||||
bool filterLabeling = settings.value("DBC/FilterLabeling_" + QString(i),0).toBool();
|
||||
attr.attrType = MESSAGE;
|
||||
attr.defaultValue = filterLabeling;
|
||||
attr.enumVals.clear();
|
||||
attr.lower = 0;
|
||||
attr.upper = 0;
|
||||
attr.name = "filterlabeling";
|
||||
attr.valType = QINT;
|
||||
file->dbc_attributes.append(attr);
|
||||
file->messageHandler->setFilterLabeling(filterLabeling);
|
||||
|
||||
qInfo() << "Loaded DBC file" << filename << " (bus:" << bus
|
||||
<< ", Matching Criteria:" << (int)matchingCriteria << "Filter labeling: " << (filterLabeling?"enabled":"disabled") << ")";
|
||||
}
|
||||
}
|
||||
|
||||
DBCHandler* DBCHandler::getReference()
|
||||
|
||||
Reference in New Issue
Block a user