LogViewer
A modern log viewer with AI-assisted analysis (Qt 6)
Loading...
Searching...
No Matches
CanDecoder.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "DbcParser.hpp"
4#include <cstdint>
5#include <string>
6#include <vector>
7
8namespace parser::dbc
9{
10
11// Decode all signals from a CAN frame and return them as key-value pairs.
12// canId — raw CAN frame ID (no extended-frame bit)
13// data — raw payload bytes (up to 8)
14// db — loaded DBC database
15// Returns vector of ("SIG:<signal_name>", "<physical_value> <unit>") pairs.
16// Returns empty vector if canId is not in the database.
17std::vector<std::pair<std::string, std::string>> DecodeFrame(
18 uint32_t canId,
19 const std::vector<uint8_t>& data,
20 const DbcDatabase& db);
21
22// Extract the raw integer value for a single signal from the payload.
23// Exposed for testing.
24int64_t ExtractRawValue(const DbcSignal& sig, const std::vector<uint8_t>& data);
25
26} // namespace parser::dbc
Database and data model components for the LogViewer application.
Definition EventsContainer.cpp:17
Definition CanDecoder.cpp:9
std::vector< std::pair< std::string, std::string > > DecodeFrame(uint32_t canId, const std::vector< uint8_t > &data, const DbcDatabase &db)
Definition CanDecoder.cpp:104
int64_t ExtractRawValue(const DbcSignal &sig, const std::vector< uint8_t > &data)
Definition CanDecoder.cpp:95