Fixed several DBC related bugs, expanded support for FD frames in the

DBC editor windows. Should more or less function now even for FD frames.
This commit is contained in:
Collin Kidder
2022-12-07 21:51:44 -05:00
parent 8c19e6f123
commit 8ff3459c75
6 changed files with 81 additions and 40 deletions
+2 -2
View File
@@ -166,7 +166,7 @@ bool DBC_SIGNAL::processAsText(const CANFrame &frame, QString &outString, bool o
} }
//like the above, this is rotten and evil and wrong in so many ways. Force //like the above, this is rotten and evil and wrong in so many ways. Force
//calculation of a 64 bit integer and then cast it into a double. //calculation of a 64 bit integer and then cast it into a double.
result = Utility::processIntegerSignal(frame.payload(), 0, 64, intelByteOrder, false); result = Utility::processIntegerSignal(frame.payload(), startBit, 64, intelByteOrder, false);
endResult = (*((double *)(&result)) * factor) + bias; endResult = (*((double *)(&result)) * factor) + bias;
} }
@@ -306,7 +306,7 @@ bool DBC_SIGNAL::processAsDouble(const CANFrame &frame, double &outValue)
} }
//like the above, this is rotten and evil and wrong in so many ways. Force //like the above, this is rotten and evil and wrong in so many ways. Force
//calculation of a 64 bit integer and then cast it into a double. //calculation of a 64 bit integer and then cast it into a double.
result = Utility::processIntegerSignal(frame.payload(), 0, 64, false, false); result = Utility::processIntegerSignal(frame.payload(), startBit, 64, false, false);
endResult = (*((double *)(&result)) * factor) + bias; endResult = (*((double *)(&result)) * factor) + bias;
} }
cachedValue = endResult; cachedValue = endResult;
+19 -17
View File
@@ -460,7 +460,7 @@ DBC_MESSAGE* DBCFile::parseMessageLine(QString line)
DBC_MESSAGE *msgPtr; DBC_MESSAGE *msgPtr;
qDebug() << "Found a BO line"; qDebug() << "Found a BO line";
regex.setPattern("^BO\\_ (\\w+) (\\w+) *: (\\w+) (\\w+)"); regex.setPattern("^BO\\_ (\\w+) ([-\\w]+) *: (\\w+) ([-\\w]+)");
match = regex.match(line); match = regex.match(line);
//captured 1 = the ID in decimal //captured 1 = the ID in decimal
//captured 2 = The message name //captured 2 = The message name
@@ -499,7 +499,7 @@ DBC_SIGNAL* DBCFile::parseSignalLine(QString line, DBC_MESSAGE *msg)
sig.isMultiplexor = false; sig.isMultiplexor = false;
qDebug() << "Found a SG line"; qDebug() << "Found a SG line";
regex.setPattern("^SG\\_ *(\\w+) +M *: *(\\d+)\\|(\\d+)@(\\d+)([\\+|\\-]) \\(([0-9.+\\-eE]+),([0-9.+\\-eE]+)\\) \\[([0-9.+\\-eE]+)\\|([0-9.+\\-eE]+)\\] \\\"(.*)\\\" (.*)"); regex.setPattern("^SG\\_ *([-\\w]+) +M *: *(\\d+)\\|(\\d+)@(\\d+)([\\+|\\-]) \\(([0-9.+\\-eE]+),([0-9.+\\-eE]+)\\) \\[([0-9.+\\-eE]+)\\|([0-9.+\\-eE]+)\\] \\\"(.*)\\\" (.*)");
match = regex.match(line); match = regex.match(line);
if (match.hasMatch()) if (match.hasMatch())
@@ -510,7 +510,7 @@ DBC_SIGNAL* DBCFile::parseSignalLine(QString line, DBC_MESSAGE *msg)
} }
else else
{ {
regex.setPattern("^SG\\_ *(\\w+) +m(\\d+) *: *(\\d+)\\|(\\d+)@(\\d+)([\\+|\\-]) \\(([0-9.+\\-eE]+),([0-9.+\\-eE]+)\\) \\[([0-9.+\\-eE]+)\\|([0-9.+\\-eE]+)\\] \\\"(.*)\\\" (.*)"); regex.setPattern("^SG\\_ *([-\\w]+) +m(\\d+) *: *(\\d+)\\|(\\d+)@(\\d+)([\\+|\\-]) \\(([0-9.+\\-eE]+),([0-9.+\\-eE]+)\\) \\[([0-9.+\\-eE]+)\\|([0-9.+\\-eE]+)\\] \\\"(.*)\\\" (.*)");
match = regex.match(line); match = regex.match(line);
if (match.hasMatch()) if (match.hasMatch())
{ {
@@ -523,7 +523,7 @@ DBC_SIGNAL* DBCFile::parseSignalLine(QString line, DBC_MESSAGE *msg)
} }
else else
{ {
regex.setPattern("^SG\\_ *(\\w+) +m(\\d+)M *: *(\\d+)\\|(\\d+)@(\\d+)([\\+|\\-]) \\(([0-9.+\\-eE]+),([0-9.+\\-eE]+)\\) \\[([0-9.+\\-eE]+)\\|([0-9.+\\-eE]+)\\] \\\"(.*)\\\" (.*)"); regex.setPattern("^SG\\_ *([-\\w]+) +m(\\d+)M *: *(\\d+)\\|(\\d+)@(\\d+)([\\+|\\-]) \\(([0-9.+\\-eE]+),([0-9.+\\-eE]+)\\) \\[([0-9.+\\-eE]+)\\|([0-9.+\\-eE]+)\\] \\\"(.*)\\\" (.*)");
match = regex.match(line); match = regex.match(line);
if (match.hasMatch()) if (match.hasMatch())
{ {
@@ -537,7 +537,7 @@ DBC_SIGNAL* DBCFile::parseSignalLine(QString line, DBC_MESSAGE *msg)
else else
{ {
qDebug() << "standard signal"; qDebug() << "standard signal";
regex.setPattern("^SG\\_ *(\\w+) *: *(\\d+)\\|(\\d+)@(\\d+)([\\+|\\-]) \\(([0-9.+\\-eE]+),([0-9.+\\-eE]+)\\) \\[([0-9.+\\-eE]+)\\|([0-9.+\\-eE]+)\\] \\\"(.*)\\\" (.*)"); regex.setPattern("^SG\\_ *([-\\w]+) *: *(\\d+)\\|(\\d+)@(\\d+)([\\+|\\-]) \\(([0-9.+\\-eE]+),([0-9.+\\-eE]+)\\) \\[([0-9.+\\-eE]+)\\|([0-9.+\\-eE]+)\\] \\\"(.*)\\\" (.*)");
match = regex.match(line); match = regex.match(line);
sig.isMultiplexed = false; sig.isMultiplexed = false;
sig.isMultiplexor = false; sig.isMultiplexor = false;
@@ -629,7 +629,7 @@ bool DBCFile::parseSignalMultiplexValueLine(QString line)
QRegularExpressionMatch match; QRegularExpressionMatch match;
qDebug() << "Found a multiplex definition line"; qDebug() << "Found a multiplex definition line";
regex.setPattern("^SG\\_MUL\\_VAL\\_ (\\d+) (\\w+) (\\w+) (\\d+)\\-(\\d+);"); regex.setPattern("^SG\\_MUL\\_VAL\\_ (\\d+) ([-\\w]+) ([-\\w]+) (\\d+)\\-(\\d+);");
match = regex.match(line); match = regex.match(line);
//captured 1 is message ID //captured 1 is message ID
//Captured 2 is signal name //Captured 2 is signal name
@@ -650,6 +650,8 @@ bool DBCFile::parseSignalMultiplexValueLine(QString line)
//now need to add "thisSignal" to the children multiplexed signals of "parentSignal" //now need to add "thisSignal" to the children multiplexed signals of "parentSignal"
parentSignal->multiplexedChildren.append(thisSignal); parentSignal->multiplexedChildren.append(thisSignal);
thisSignal->multiplexParent = parentSignal; thisSignal->multiplexParent = parentSignal;
thisSignal->multiplexLowValue = match.captured(4).toInt();
thisSignal->multiplexHighValue = match.captured(5).toInt();
return true; return true;
} }
} }
@@ -664,7 +666,7 @@ bool DBCFile::parseValueLine(QString line)
QRegularExpressionMatch match; QRegularExpressionMatch match;
qDebug() << "Found a value definition line"; qDebug() << "Found a value definition line";
regex.setPattern("^VAL\\_ (\\w+) (\\w+) (.*);"); regex.setPattern("^VAL\\_ (\\w+) ([-\\w]+) (.*);");
match = regex.match(line); match = regex.match(line);
//captured 1 is the ID to match against //captured 1 is the ID to match against
//captured 2 is the signal name to match against //captured 2 is the signal name to match against
@@ -709,7 +711,7 @@ bool DBCFile::parseAttributeLine(QString line)
QRegularExpression regex; QRegularExpression regex;
QRegularExpressionMatch match; QRegularExpressionMatch match;
regex.setPattern("^BA\\_ \\\"*(\\w+)\\\"* BO\\_ (\\d+) \\\"*([#\\w]+)\\\"*"); regex.setPattern("^BA\\_ \\\"*([-\\w]+)\\\"* BO\\_ (\\d+) \\\"*([#\\w]+)\\\"*");
match = regex.match(line); match = regex.match(line);
//captured 1 is the attribute name //captured 1 is the attribute name
//captured 2 is the message ID number (frame ID) //captured 2 is the message ID number (frame ID)
@@ -740,7 +742,7 @@ bool DBCFile::parseAttributeLine(QString line)
} }
} }
regex.setPattern("^BA\\_ \\\"*(\\w+)\\\"* SG\\_ (\\d+) \\\"*(\\w+)\\\"* \\\"*([#\\w]+)\\\"*"); regex.setPattern("^BA\\_ \\\"*([-\\w]+)\\\"* SG\\_ (\\d+) \\\"*([-\\w]+)\\\"* \\\"*([#\\w]+)\\\"*");
match = regex.match(line); match = regex.match(line);
//captured 1 is the attribute name //captured 1 is the attribute name
//captured 2 is the message ID number (frame ID) //captured 2 is the message ID number (frame ID)
@@ -774,7 +776,7 @@ bool DBCFile::parseAttributeLine(QString line)
} }
} }
regex.setPattern("^BA\\_ \\\"*(\\w+)\\\"* BU\\_ \\\"*(\\w+)\\\"* \\\"*([#\\w]+)\\\"*"); regex.setPattern("^BA\\_ \\\"*([-\\w]+)\\\"* BU\\_ \\\"*([-\\w]+)\\\"* \\\"*([#\\w]+)\\\"*");
match = regex.match(line); match = regex.match(line);
//captured 1 is the attribute name //captured 1 is the attribute name
//captured 2 is the name of the node //captured 2 is the name of the node
@@ -812,7 +814,7 @@ bool DBCFile::parseDefaultAttrLine(QString line)
QRegularExpression regex; QRegularExpression regex;
QRegularExpressionMatch match; QRegularExpressionMatch match;
regex.setPattern("^BA\\_DEF\\_DEF\\_ \\\"*(\\w+)\\\"* \\\"*([#\\w]*)\\\"*"); regex.setPattern("^BA\\_DEF\\_DEF\\_ \\\"*([-\\w]+)\\\"* \\\"*([#\\w]*)\\\"*");
match = regex.match(line); match = regex.match(line);
//captured 1 is the name of the attribute //captured 1 is the name of the attribute
//captured 2 is the default value for that attribute //captured 2 is the default value for that attribute
@@ -949,7 +951,7 @@ bool DBCFile::loadFile(QString fileName)
if (line.startsWith("CM_ SG_ ")) if (line.startsWith("CM_ SG_ "))
{ {
qDebug() << "Found an SG comment line"; qDebug() << "Found an SG comment line";
regex.setPattern("^CM\\_ SG\\_ *(\\w+) *(\\w+) *\\\"(.*)\\\";"); regex.setPattern("^CM\\_ SG\\_ *(\\w+) *([-\\w]+) *\\\"(.*)\\\";");
match = regex.match(line); match = regex.match(line);
//captured 1 is the ID to match against to get to the message //captured 1 is the ID to match against to get to the message
//captured 2 is the signal name from that message //captured 2 is the signal name from that message
@@ -988,7 +990,7 @@ bool DBCFile::loadFile(QString fileName)
if (line.startsWith("CM_ BU_ ")) if (line.startsWith("CM_ BU_ "))
{ {
qDebug() << "Found a BU comment line"; qDebug() << "Found a BU comment line";
regex.setPattern("^CM\\_ BU\\_ *(\\w+) *\\\"(.*)\\\";"); regex.setPattern("^CM\\_ BU\\_ *([-\\w]+) *\\\"(.*)\\\";");
match = regex.match(line); match = regex.match(line);
//captured 1 is the Node name //captured 1 is the Node name
//captured 2 is the comment itself //captured 2 is the comment itself
@@ -1361,7 +1363,7 @@ bool DBCFile::saveFile(QString fileName)
attrValOutput.append("BA_ \"" + val.attrName + "\" BU_ "); attrValOutput.append("BA_ \"" + val.attrName + "\" BU_ ");
switch (val.value.type()) switch (val.value.type())
{ {
case QMetaType::QString: case QVariant::Type::String:
attrValOutput.append("\"" + val.value.toString() + "\";\n"); attrValOutput.append("\"" + val.value.toString() + "\";\n");
break; break;
default: default:
@@ -1406,7 +1408,7 @@ bool DBCFile::saveFile(QString fileName)
attrValOutput.append("BA_ \"" + val.attrName + "\" BO_ " + QString::number(ID) + " "); attrValOutput.append("BA_ \"" + val.attrName + "\" BO_ " + QString::number(ID) + " ");
switch (val.value.type()) switch (val.value.type())
{ {
case QMetaType::QString: case QVariant::Type::String:
attrValOutput.append("\"" + val.value.toString() + "\";\n"); attrValOutput.append("\"" + val.value.toString() + "\";\n");
break; break;
default: default:
@@ -1483,7 +1485,7 @@ bool DBCFile::saveFile(QString fileName)
attrValOutput.append("BA_ \"" + val.attrName + "\" SG_ " + QString::number(ID) + " " + sig->name + " "); attrValOutput.append("BA_ \"" + val.attrName + "\" SG_ " + QString::number(ID) + " " + sig->name + " ");
switch (val.value.type()) switch (val.value.type())
{ {
case QMetaType::QString: case QVariant::Type::String:
attrValOutput.append("\"" + val.value.toString() + "\";\n"); attrValOutput.append("\"" + val.value.toString() + "\";\n");
break; break;
default: default:
@@ -1600,7 +1602,7 @@ bool DBCFile::saveFile(QString fileName)
if (sig->isMultiplexed) if (sig->isMultiplexed)
{ {
msgOutput.append("SG_MUL_VAL_ " + QString::number(ID) + " "); msgOutput.append("SG_MUL_VAL_ " + QString::number(ID) + " ");
msgOutput.append(sig->name + " " + sig->parentMessage->name + " "); msgOutput.append(sig->name + " " + sig->multiplexParent->name + " ");
msgOutput.append(QString::number(sig->multiplexLowValue) + "-" + QString::number(sig->multiplexHighValue) + ";"); msgOutput.append(QString::number(sig->multiplexLowValue) + "-" + QString::number(sig->multiplexHighValue) + ";");
msgOutput.append("\n"); msgOutput.append("\n");
outFile->write(msgOutput.toUtf8()); outFile->write(msgOutput.toUtf8());
+1 -1
View File
@@ -860,7 +860,7 @@ void DBCMainEditor::deleteCurrentTreeItem()
} }
else else
{ {
qDebug() << "WTF, could not find the signal in the map. That should not happen."; qDebug() << "Could not find the signal in the map. That should not happen.";
} }
} }
break; break;
+56 -17
View File
@@ -37,7 +37,7 @@ DBCSignalEditor::DBCSignalEditor(QWidget *parent) :
ui->bitfield->setMode(GridMode::SIGNAL_VIEW); ui->bitfield->setMode(GridMode::SIGNAL_VIEW);
connect(ui->bitfield, SIGNAL(gridClicked(int,int)), this, SLOT(bitfieldClicked(int,int))); connect(ui->bitfield, SIGNAL(gridClicked(int)), this, SLOT(bitfieldClicked(int)));
connect(ui->valuesTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onCustomMenuValues(QPoint))); connect(ui->valuesTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onCustomMenuValues(QPoint)));
ui->valuesTable->setContextMenuPolicy(Qt::CustomContextMenu); ui->valuesTable->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->valuesTable, SIGNAL(cellChanged(int,int)), this, SLOT(onValuesCellChanged(int,int))); connect(ui->valuesTable, SIGNAL(cellChanged(int,int)), this, SLOT(onValuesCellChanged(int,int)));
@@ -74,12 +74,23 @@ DBCSignalEditor::DBCSignalEditor(QWidget *parent) :
break; break;
case 2: case 2:
currentSignal->valType = SP_FLOAT; currentSignal->valType = SP_FLOAT;
if (currentSignal->startBit > 39) currentSignal->startBit = 39; if (dbcMessage) //if we have a good msg reference we can use it to get the # of bytes expected.
{
int maxBit = ((dbcMessage->len * 8) - 32 + 7);
if (maxBit < 0) maxBit = 0;
if (currentSignal->startBit > maxBit) currentSignal->startBit = maxBit;
}
else if (currentSignal->startBit > 39) currentSignal->startBit = 39;
currentSignal->signalSize = 32; currentSignal->signalSize = 32;
break; break;
case 3: case 3:
currentSignal->valType = DP_FLOAT; currentSignal->valType = DP_FLOAT;
currentSignal->startBit = 7; //has to be! if (dbcMessage)
{
int maxBit = ((dbcMessage->len * 8) - 64 + 7);
if (currentSignal->startBit > maxBit) currentSignal->startBit = maxBit;
}
else currentSignal->startBit = 7; //has to be!
currentSignal->signalSize = 64; currentSignal->signalSize = 64;
break; break;
case 4: case 4:
@@ -166,7 +177,11 @@ DBCSignalEditor::DBCSignalEditor(QWidget *parent) :
int temp; int temp;
temp = Utility::ParseStringToNum(ui->txtBitLength->text()); temp = Utility::ParseStringToNum(ui->txtBitLength->text());
if (temp < 1) return; if (temp < 1) return;
if (temp > 64) return; if (dbcMessage)
{
if (temp > (int)(dbcMessage->len * 8)) return;
}
else if (temp > 64) return;
if (currentSignal->signalSize != temp) dbcFile->setDirtyFlag(); if (currentSignal->signalSize != temp) dbcFile->setDirtyFlag();
if (currentSignal->valType != SP_FLOAT && currentSignal->valType != DP_FLOAT) if (currentSignal->valType != SP_FLOAT && currentSignal->valType != DP_FLOAT)
currentSignal->signalSize = temp; currentSignal->signalSize = temp;
@@ -197,7 +212,7 @@ DBCSignalEditor::DBCSignalEditor(QWidget *parent) :
connect(ui->txtMultiplexHigh, &QLineEdit::editingFinished, connect(ui->txtMultiplexHigh, &QLineEdit::editingFinished,
[=]() [=]()
{ {
if (currentSignal == nullptr) return; if (!currentSignal) return;
int temp; int temp;
temp = Utility::ParseStringToNum(ui->txtMultiplexHigh->text()); temp = Utility::ParseStringToNum(ui->txtMultiplexHigh->text());
if (currentSignal->multiplexHighValue != temp) dbcFile->setDirtyFlag(); if (currentSignal->multiplexHighValue != temp) dbcFile->setDirtyFlag();
@@ -208,6 +223,7 @@ DBCSignalEditor::DBCSignalEditor(QWidget *parent) :
connect(ui->rbExtended, &QRadioButton::toggled, connect(ui->rbExtended, &QRadioButton::toggled,
[=](bool state) [=](bool state)
{ {
if (!currentSignal) return;
if (state && currentSignal) //signal is now set as an extended multiplex/multiplexor if (state && currentSignal) //signal is now set as an extended multiplex/multiplexor
{ {
currentSignal->isMultiplexed = true; currentSignal->isMultiplexed = true;
@@ -224,6 +240,7 @@ DBCSignalEditor::DBCSignalEditor(QWidget *parent) :
connect(ui->rbMultiplexed, &QRadioButton::toggled, connect(ui->rbMultiplexed, &QRadioButton::toggled,
[=](bool state) [=](bool state)
{ {
if (!currentSignal) return;
if (state && currentSignal) //signal is now set as a multiplexed signal if (state && currentSignal) //signal is now set as a multiplexed signal
{ {
currentSignal->isMultiplexed = true; currentSignal->isMultiplexed = true;
@@ -240,6 +257,7 @@ DBCSignalEditor::DBCSignalEditor(QWidget *parent) :
connect(ui->rbMultiplexor, &QRadioButton::toggled, connect(ui->rbMultiplexor, &QRadioButton::toggled,
[=](bool state) [=](bool state)
{ {
if (!currentSignal) return;
if (state && currentSignal) //signal is now set as a multiplexed signal if (state && currentSignal) //signal is now set as a multiplexed signal
{ {
//don't allow this signal to be a multiplexor if there is already one for this message. //don't allow this signal to be a multiplexor if there is already one for this message.
@@ -258,6 +276,7 @@ DBCSignalEditor::DBCSignalEditor(QWidget *parent) :
connect(ui->rbNotMulti, &QRadioButton::toggled, connect(ui->rbNotMulti, &QRadioButton::toggled,
[=](bool state) [=](bool state)
{ {
if (!currentSignal) return;
if (state && currentSignal) //signal is now set as a multiplexed signal if (state && currentSignal) //signal is now set as a multiplexed signal
{ {
currentSignal->isMultiplexed = false; currentSignal->isMultiplexed = false;
@@ -448,7 +467,7 @@ void DBCSignalEditor::deleteCurrentValue()
/* WARNING: fillSignalForm can be called recursively since it is in the listener of cbIntelFormat */ /* WARNING: fillSignalForm can be called recursively since it is in the listener of cbIntelFormat */
void DBCSignalEditor::fillSignalForm(DBC_SIGNAL *sig) void DBCSignalEditor::fillSignalForm(DBC_SIGNAL *sig)
{ {
unsigned char bitpattern[8]; unsigned char bitpattern[64];
inhibitMsgProc = true; inhibitMsgProc = true;
@@ -467,7 +486,7 @@ void DBCSignalEditor::fillSignalForm(DBC_SIGNAL *sig)
ui->rbMultiplexed->setChecked(false); ui->rbMultiplexed->setChecked(false);
ui->rbMultiplexor->setChecked(false); ui->rbMultiplexor->setChecked(false);
ui->rbNotMulti->setChecked(true); ui->rbNotMulti->setChecked(true);
memset(bitpattern, 0, 8); //clear it out memset(bitpattern, 0, 64); //clear it out
ui->bitfield->setReference(bitpattern, false); ui->bitfield->setReference(bitpattern, false);
ui->bitfield->updateData(bitpattern, true); ui->bitfield->updateData(bitpattern, true);
ui->comboReceiver->setCurrentIndex(0); ui->comboReceiver->setCurrentIndex(0);
@@ -522,7 +541,7 @@ void DBCSignalEditor::fillSignalForm(DBC_SIGNAL *sig)
ui->txtMultiplexHigh->setEnabled(sig->isMultiplexed); ui->txtMultiplexHigh->setEnabled(sig->isMultiplexed);
ui->cbMultiplexParent->setEnabled(sig->isMultiplexed); ui->cbMultiplexParent->setEnabled(sig->isMultiplexed);
memset(bitpattern, 0, 8); //clear it out first. memset(bitpattern, 0, 64); //clear it out first.
int startBit, endBit; int startBit, endBit;
@@ -535,7 +554,7 @@ void DBCSignalEditor::fillSignalForm(DBC_SIGNAL *sig)
{ {
endBit = startBit + sig->signalSize - 1; endBit = startBit + sig->signalSize - 1;
if (startBit < 0) startBit = 0; if (startBit < 0) startBit = 0;
if (endBit > 63) endBit = 63; if (endBit > 511) endBit = 511;
for (int y = startBit; y <= endBit; y++) for (int y = startBit; y <= endBit; y++)
{ {
int byt = y / 8; int byt = y / 8;
@@ -553,7 +572,7 @@ void DBCSignalEditor::fillSignalForm(DBC_SIGNAL *sig)
size--; size--;
if ((startBit % 8) == 0) startBit += 15; if ((startBit % 8) == 0) startBit += 15;
else startBit--; else startBit--;
if (startBit > 63) startBit = 63; if (startBit > 511) startBit = 511;
} }
} }
@@ -625,26 +644,43 @@ void DBCSignalEditor::fillValueTable(DBC_SIGNAL *sig)
inhibitCellChanged = false; inhibitCellChanged = false;
} }
void DBCSignalEditor::bitfieldClicked(int x, int y) void DBCSignalEditor::bitfieldClicked(int bit)
{ {
int bit = (7 - x) + (y * 8);
if (currentSignal == nullptr) return; if (currentSignal == nullptr) return;
currentSignal->startBit = bit; currentSignal->startBit = bit;
if (currentSignal->valType == SP_FLOAT) if (currentSignal->valType == SP_FLOAT)
{ {
if (currentSignal->startBit > 31) currentSignal->startBit = 39; if (dbcMessage)
{
int maxBit = ((dbcMessage->len * 8) - 32 + 7);
if (maxBit < 0) maxBit = 0;
if (currentSignal->startBit > maxBit) currentSignal->startBit = maxBit;
}
else if (currentSignal->startBit > 31) currentSignal->startBit = 39;
} }
if (currentSignal->valType == DP_FLOAT) if (currentSignal->valType == DP_FLOAT)
currentSignal->startBit = 7; {
if (dbcMessage)
{
int maxBit = ((dbcMessage->len * 8) - 64 + 7);
if (maxBit < 0) maxBit = 0;
if (currentSignal->startBit > maxBit) currentSignal->startBit = maxBit;
}
else currentSignal->startBit = 7;
}
fillSignalForm(currentSignal); fillSignalForm(currentSignal);
} }
void DBCSignalEditor::generateUsedBits() void DBCSignalEditor::generateUsedBits()
{ {
uint8_t usedBits[8] = {0,0,0,0,0,0,0,0}; uint8_t usedBits[64];
int startBit, endBit; int startBit, endBit;
memset(usedBits, 0, 64);
if (!dbcMessage || !dbcMessage->sigHandler) return;
for (int x = 0; x < dbcMessage->sigHandler->getCount(); x++) for (int x = 0; x < dbcMessage->sigHandler->getCount(); x++)
{ {
DBC_SIGNAL *sig = dbcMessage->sigHandler->findSignalByIdx(x); DBC_SIGNAL *sig = dbcMessage->sigHandler->findSignalByIdx(x);
@@ -663,7 +699,8 @@ void DBCSignalEditor::generateUsedBits()
{ {
endBit = startBit + sig->signalSize - 1; endBit = startBit + sig->signalSize - 1;
if (startBit < 0) startBit = 0; if (startBit < 0) startBit = 0;
if (endBit > 63) endBit = 63; int maxBit = (dbcMessage->len * 8) - 1;
if (endBit > maxBit) endBit = maxBit;
for (int y = startBit; y <= endBit; y++) for (int y = startBit; y <= endBit; y++)
{ {
int byt = y / 8; int byt = y / 8;
@@ -683,9 +720,11 @@ void DBCSignalEditor::generateUsedBits()
size--; size--;
if ((startBit % 8) == 0) startBit += 15; if ((startBit % 8) == 0) startBit += 15;
else startBit--; else startBit--;
if (startBit > 63) startBit = 63; int maxBit = (dbcMessage->len * 8) - 1;
if (startBit > maxBit) startBit = maxBit;
} }
} }
} }
ui->bitfield->setUsed(usedBits, false); ui->bitfield->setUsed(usedBits, false);
ui->bitfield->setBytesToDraw(dbcMessage->len);
} }
+1 -1
View File
@@ -26,7 +26,7 @@ signals:
void updatedTreeInfo(DBC_SIGNAL *sig); void updatedTreeInfo(DBC_SIGNAL *sig);
private slots: private slots:
void bitfieldClicked(int x, int y); void bitfieldClicked(int bit);
void onValuesCellChanged(int row,int col); void onValuesCellChanged(int row,int col);
void onCustomMenuValues(QPoint); void onCustomMenuValues(QPoint);
void deleteCurrentValue(); void deleteCurrentValue();
+2 -2
View File
@@ -256,7 +256,7 @@ public:
bit = startBit; bit = startBit;
for (int bitpos = 0; bitpos < sigSize; bitpos++) for (int bitpos = 0; bitpos < sigSize; bitpos++)
{ {
if (bit < 64) { if (bit < 512) {
int bytePos = bit / 8; int bytePos = bit / 8;
if (bytePos >= data.count()) return 0; //error! if (bytePos >= data.count()) return 0; //error!
if (data[bit / 8] & (1 << (bit % 8))) if (data[bit / 8] & (1 << (bit % 8)))
@@ -271,7 +271,7 @@ public:
bit = startBit; bit = startBit;
for (int bitpos = 0; bitpos < sigSize; bitpos++) for (int bitpos = 0; bitpos < sigSize; bitpos++)
{ {
if (bit < 64) { if (bit < 512) {
int bytePos = bit / 8; int bytePos = bit / 8;
if (bytePos >= data.count()) return 0; //error! if (bytePos >= data.count()) return 0; //error!
if (data[bit / 8] & (1 << (bit % 8))) if (data[bit / 8] & (1 << (bit % 8)))