Closes #24
This commit is contained in:
1 parent
fc97682b37
commit
e555ebb571
16 files changed
+337
-52
No files matched your search
+19
-3
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
#include "dbc_decoder.h"
|
||||
#include "j1939.h"
|
||||
#include "signal_layout.h"
|
||||
#include <cmath>
|
||||
#include <stdexcept>
|
||||
@@ -19,7 +20,17 @@
|
||||
std::shared_ptr<const DecodeFrame> DbcDecoder::FindFrame(const DecodeDatabase &database,
|
||||
std::uint32_t canId,
|
||||
bool isExtended) const {
|
||||
return database.FindFrame(FrameKey(canId, isExtended));
|
||||
return ResolveFrame(database, canId, isExtended).definition;
|
||||
}
|
||||
|
||||
PgnLookupResult DbcDecoder::ResolveFrame(const DecodeDatabase &database,
|
||||
std::uint32_t canId, bool isExtended) {
|
||||
const std::shared_ptr<const DecodeFrame> exact = database.FindFrame(FrameKey(canId, isExtended));
|
||||
if (exact)
|
||||
return {exact, false};
|
||||
if (!isExtended || canId > 0x1FFFFFFFU)
|
||||
return {};
|
||||
return database.FindFrameByPgn(ExtractJ1939Pgn(canId));
|
||||
}
|
||||
|
||||
DecodedFrameValue DbcDecoder::Decode(const DecodeDatabase &database,
|
||||
@@ -38,10 +49,15 @@ DecodedFrameValue DbcDecoder::DecodeImpl(const DecodeDatabase &database,
|
||||
const std::vector<SignalKey> *selection) const {
|
||||
DecodedFrameValue result;
|
||||
result.key = FrameKey(frame.canId, frame.isExtended);
|
||||
const std::shared_ptr<const DecodeFrame> definition = FindFrame(database, frame.canId, frame.isExtended);
|
||||
|
||||
const PgnLookupResult match = ResolveFrame(database, frame.canId, frame.isExtended);
|
||||
if (match.ambiguous) {
|
||||
result.status = FrameDecodeStatus::AmbiguousFrame;
|
||||
return result;
|
||||
}
|
||||
const std::shared_ptr<const DecodeFrame> definition = match.definition;
|
||||
if (definition == nullptr)
|
||||
return result;
|
||||
result.key = definition->GetKey();
|
||||
|
||||
std::vector<const DecodeSignal *> selected;
|
||||
if (selection != nullptr) {
|
||||
|
||||
Reference in new issue
Block a user