Closes #16
This commit is contained in:
1 parent
7022c84941
commit
c3d3bd51fb
72 files changed
+3703
-2484
No files matched your search
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
#include "dbc_decoder.h"
|
||||
#include "signal_layout.h"
|
||||
#include <cmath>
|
||||
#include <utility>
|
||||
|
||||
@@ -58,11 +59,8 @@ bool DbcDecoder::IsValidDefinition(const DecodeSignal &signal, std::uint8_t dlc)
|
||||
signal.multiplexing.role != MultiplexRole::Branch))
|
||||
return false;
|
||||
|
||||
// Use widened coordinates to avoid overflow on malformed start bits.
|
||||
const std::uint64_t start = signal.byteOrder == ByteOrder::Intel
|
||||
? signal.startBit
|
||||
: std::uint64_t(signal.startBit / 8U) * 8U + 7U - signal.startBit % 8U;
|
||||
return start + signal.length <= std::uint64_t(dlc) * 8U;
|
||||
return IsValidSignalLayout(signal.startBit, signal.length,
|
||||
signal.byteOrder == ByteOrder::Intel, dlc);
|
||||
}
|
||||
|
||||
DbcDecoder::SelectorState DbcDecoder::ReadSelector(const DecodeFrame &definition,
|
||||
@@ -154,8 +152,8 @@ bool DbcDecoder::ExtractIntel(const std::vector<std::uint8_t> &data,
|
||||
value = 0U;
|
||||
|
||||
for (std::uint32_t bitIndex = 0U; bitIndex < length; ++bitIndex) {
|
||||
const std::uint32_t absoluteBit = startBit + bitIndex;
|
||||
const std::uint32_t byteIndex = absoluteBit / 8U;
|
||||
const std::uint64_t absoluteBit = std::uint64_t(startBit) + bitIndex;
|
||||
const std::uint64_t byteIndex = absoluteBit / 8U;
|
||||
const std::uint32_t bitInByte = absoluteBit % 8U;
|
||||
|
||||
if (byteIndex >= data.size())
|
||||
|
||||
Reference in new issue
Block a user