DBC Framework
DBC parsing and CAN signal decoding framework
dbc_decoder.h
Go to the documentation of this file.
1
12#ifndef DBC_DECODER_H
13#define DBC_DECODER_H
14
15#include <vector>
16#include <cstdint>
17
18#include "decode_database.h"
19
24 std::uint32_t canId;
26 std::vector<std::uint8_t> data;
29 : canId (0U)
30 , isExtended (false)
31 , data() {
32 }
33};
34
40 std::int64_t rawValue;
42 bool valid;
45 : definition (nullptr)
46 , rawValue (0)
47 , physicalValue (0.0)
48 , valid (false) {
49 }
50};
51
57 std::vector<DecodedSignalValue> signals;
58 bool valid;
61 : definition (nullptr)
62 , signals()
63 , valid (false) {
64 }
65};
66
71 public:
79 const DecodeFrame *FindFrame (const DecodeDatabase &database,
80 std::uint32_t canId,
81 bool isExtended) const;
82
90 const RawCanFrame &frame) const;
91
92 private:
93 static bool ExtractUnsigned (const std::vector<std::uint8_t> &data,
94 const DecodeSignal &signal,
95 std::uint64_t &value);
96
97 static bool ExtractIntel (const std::vector<std::uint8_t> &data,
98 std::uint32_t startBit,
99 std::uint32_t length,
100 std::uint64_t &value);
101
102 static bool ExtractMotorola (const std::vector<std::uint8_t> &data,
103 std::uint32_t startBit,
104 std::uint32_t length,
105 std::uint64_t &value);
106
107 static std::int64_t SignExtend (std::uint64_t value, std::uint32_t bitLength);
108};
109
110#endif /* DBC_DECODER_H */
Runtime CAN decoder using prebuilt decode database.
Definition: dbc_decoder.h:70
DecodedFrameValue Decode(const DecodeDatabase &database, const RawCanFrame &frame) const
Decode one raw CAN frame.
Definition: dbc_decoder.cpp:31
const DecodeFrame * FindFrame(const DecodeDatabase &database, std::uint32_t canId, bool isExtended) const
Find frame definition by CAN ID.
Definition: dbc_decoder.cpp:14
Created: 2026-03-13 Author: Deeaitch (Dim. Himro)
Runtime decode database with fast lookup by CAN ID.
Runtime-ready frame definition.
Runtime-ready signal definition.
Fully decoded frame.
Definition: dbc_decoder.h:55
const DecodeFrame * definition
Definition: dbc_decoder.h:56
One decoded signal value.
Definition: dbc_decoder.h:38
std::int64_t rawValue
Definition: dbc_decoder.h:40
const DecodeSignal * definition
Definition: dbc_decoder.h:39
Raw CAN frame used for runtime or trace decoding.
Definition: dbc_decoder.h:23
std::vector< std::uint8_t > data
Definition: dbc_decoder.h:26
std::uint32_t canId
Definition: dbc_decoder.h:24
bool isExtended
Definition: dbc_decoder.h:25