diff --git a/config.h b/config.h index 78ef3db..b2ee918 100644 --- a/config.h +++ b/config.h @@ -1,7 +1,7 @@ #ifndef CONFIG #define CONFIG -#define VERSION 136 +#define VERSION 137 //try to keep this in sync. //SavvyCAN will complain if you connect a GVRET board with a revision diff --git a/dbchandler.cpp b/dbchandler.cpp index 0c1dc71..c1f350e 100644 --- a/dbchandler.cpp +++ b/dbchandler.cpp @@ -87,12 +87,12 @@ void DBCHandler::loadDBCFile(QString filename) } switch (val) { - case 0: - sig.intelByteOrder = true; - break; - case 1: + case 0: //big endian mode sig.intelByteOrder = false; break; + case 1: //little endian mode + sig.intelByteOrder = true; + break; case 2: sig.valType = SP_FLOAT; break; @@ -344,12 +344,12 @@ void DBCHandler::saveDBCFile(QString filename) switch (sig.valType) { case UNSIGNED_INT: - if (sig.intelByteOrder) msgOutput.append("0+"); - else msgOutput.append("1+"); + if (sig.intelByteOrder) msgOutput.append("1+"); + else msgOutput.append("0+"); break; case SIGNED_INT: - if (sig.intelByteOrder) msgOutput.append("0-"); - else msgOutput.append("1-"); + if (sig.intelByteOrder) msgOutput.append("1-"); + else msgOutput.append("0-"); break; case SP_FLOAT: msgOutput.append("2-"); diff --git a/dbcsignaleditor.cpp b/dbcsignaleditor.cpp index 7008da8..40d4d09 100644 --- a/dbcsignaleditor.cpp +++ b/dbcsignaleditor.cpp @@ -345,33 +345,41 @@ void DBCSignalEditor::fillSignalForm(DBC_SIGNAL *sig) ui->txtUnitName->setText(sig->unitName); memset(bitpattern, 0, 8); //clear it out first. - int startBit, endBit, startByte, bitWithinByteStart; + + int startBit, endBit; startBit = sig->startBit; - startByte = startBit / 8; - bitWithinByteStart = startBit % 8; - if (!sig->intelByteOrder) - { - bitWithinByteStart = 7 - bitWithinByteStart; - startBit = (startByte * 8) + bitWithinByteStart; - } - endBit = startBit + sig->signalSize - 1; - if (endBit > 63) - { - endBit = 63; - } - - //bitpattern[startBit / 8] |= 1 << (startBit % 8); + bitpattern[startBit / 8] |= 1 << (startBit % 8); //make the start bit a different color to set it apart ui->bitfield->setReference(bitpattern, false); - for (int y = startBit; y <= endBit; y++) + if (sig->intelByteOrder) { - int byt = y / 8; - bitpattern[byt] |= 1 << (y % 8); - } - ui->bitfield->updateData(bitpattern, true); + endBit = startBit + sig->signalSize - 1; + if (startBit < 0) startBit = 0; + if (endBit > 63) endBit = 63; + for (int y = startBit; y <= endBit; y++) + { + int byt = y / 8; + bitpattern[byt] |= 1 << (y % 8); + } + } + else //big endian / motorola format + { + //much more irritating than the intel version... + int size = sig->signalSize; + while (size > 0) + { + int byt = startBit / 8; + bitpattern[byt] |= 1 << (startBit % 8); + size--; + if ((startBit % 8) == 0) startBit += 15; + else startBit--; + } + } + + ui->bitfield->updateData(bitpattern, true); ui->cbIntelFormat->setChecked(sig->intelByteOrder); switch (sig->valType) @@ -447,7 +455,7 @@ void DBCSignalEditor::clickSignalList(int row) void DBCSignalEditor::bitfieldClicked(int x, int y) { - int bit = (x) + (y * 8); + int bit = (7 - x) + (y * 8); if (currentSignal == NULL) return; currentSignal->startBit = bit; fillSignalForm(currentSignal);