DBC Framework
DBC parsing and CAN signal decoding framework
Loading...
Searching...
No Matches
DbcDecoder Class Reference

Runtime CAN decoder using prebuilt decode database. More...

#include <dbc_decoder.h>

Public Member Functions

std::shared_ptr< const DecodeFrame > FindFrame (const DecodeDatabase &database, std::uint32_t canId, bool isExtended) const
 Find exact CAN ID first, then unique PGN among explicitly J1939 definitions.
 
DecodedFrameValue Decode (const DecodeDatabase &database, const RawCanFrame &frame) const
 Decode one raw CAN frame.
 
DecodedFrameValue Decode (const DecodeDatabase &database, const RawCanFrame &frame, const std::vector< SignalKey > &selection) const
 Decode selected signals in selection order using stable keys. An empty selection returns no signals. Multiplex selectors are read internally. Frame status summarizes selected signals; short payload still takes precedence. Unknown/ambiguous frames return before checking the selection. For PGN matches, selection keys must belong to the matched DBC definition.
 

Detailed Description

Runtime CAN decoder using prebuilt decode database.

Definition at line 86 of file dbc_decoder.h.

Member Function Documentation

◆ FindFrame()

std::shared_ptr< const DecodeFrame > DbcDecoder::FindFrame ( const DecodeDatabase &  database,
std::uint32_t  canId,
bool  isExtended 
) const

Find exact CAN ID first, then unique PGN among explicitly J1939 definitions.

Parameters
databaseRuntime decode database.
canIdNormalized CAN ID.
isExtendedtrue for extended frame.
Returns
Owning immutable handle, or nullptr for missing/ambiguous matches. Safe across reload.

Definition at line 20 of file dbc_decoder.cpp.

References PgnLookupResult::definition.

◆ Decode() [1/2]

DecodedFrameValue DbcDecoder::Decode ( const DecodeDatabase &  database,
const RawCanFrame &  frame 
) const

Decode one raw CAN frame.

Parameters
databaseRuntime decode database.
frameRaw CAN frame. Short payloads decode available signals; bytes beyond declared DLC are ignored.
Returns
Decoded frame value.

Definition at line 36 of file dbc_decoder.cpp.

Referenced by main().

◆ Decode() [2/2]

DecodedFrameValue DbcDecoder::Decode ( const DecodeDatabase &  database,
const RawCanFrame &  frame,
const std::vector< SignalKey > &  selection 
) const

Decode selected signals in selection order using stable keys. An empty selection returns no signals. Multiplex selectors are read internally. Frame status summarizes selected signals; short payload still takes precedence. Unknown/ambiguous frames return before checking the selection. For PGN matches, selection keys must belong to the matched DBC definition.

Exceptions
std::invalid_argumentfor a foreign frame key, unknown signal, or duplicate key.

Definition at line 41 of file dbc_decoder.cpp.


The documentation for this class was generated from the following files: