This commit is contained in:
deeaitch committed 2026-10-23 20:53:05 -04:00
1 parent f60faea2e7
commit f03882d3f4
86 files changed
+3539 -2688

No files matched your search

+2 -1
View File
@@ -22,7 +22,8 @@ enum class DbcDiagnosticCode {
InvalidMultiplexing,
UnsupportedStatement,
InvalidAttribute,
UnsupportedAttribute
UnsupportedAttribute,
UnsupportedSignalType
};
/** @brief Diagnostic message and physical source location. */
+2
View File
@@ -83,6 +83,8 @@ namespace {
return DbcDiagnosticCode::InvalidMultiplexing;
if (keyword == "VAL_")
return DbcDiagnosticCode::InvalidValueDescription;
if (keyword == "SIG_VALTYPE_")
return DbcDiagnosticCode::UnsupportedSignalType;
return DbcDiagnosticCode::InvalidStatement;
}
}
+4 -2
View File
@@ -37,7 +37,9 @@ struct DbcParserOptions {
* Attribute statements support multiline fields and quoted strings, ending at
* a semicolon outside quoted text. Diagnostics use the first physical line.
*
* Reports unsupported statements as warnings. Invalid multiplexing is
* Rejects all SIG_VALTYPE_ declarations, including type 0, with
* UnsupportedSignalType errors; explicit signal value types are not implemented.
* Other unsupported statements produce warnings. Invalid multiplexing is
* an error. VERSION, NS_, BS_, BU_ and NS_ symbol declarations stay quiet.
*/
class DbcParser {
@@ -49,7 +51,7 @@ public:
* @brief Parse DBC file.
* @param filePath Path to input file.
* @return Parsed database.
* @throws std::runtime_error on file or parse errors.
* @throws std::runtime_error on file or parse errors, including SIG_VALTYPE_.
* Line parse errors include the file path and one-based line number.
* Duplicate normalized CAN IDs of the same frame type and duplicate signal
* names within a frame are rejected at the repeated definition's line.
+5
View File
@@ -411,6 +411,7 @@ DbcStatementDispatcher::DbcStatementDispatcher() {
RegisterType<DbcMultiplexingHandler>("SG_MUL_VAL_");
RegisterType<DbcFrameHandler>("BO_");
RegisterType<DbcSignalHandler>("SG_");
RegisterType<DbcUnsupportedSignalTypeHandler>("SIG_VALTYPE_");
RegisterType<DbcCommentHandler>("CM_");
RegisterType<DbcValueDescriptionHandler>("VAL_");
RegisterType<DbcAttributeHandler>("BA_DEF_");
@@ -418,6 +419,10 @@ DbcStatementDispatcher::DbcStatementDispatcher() {
RegisterType<DbcAttributeHandler>("BA_");
}
void DbcUnsupportedSignalTypeHandler::Handle(const std::string &, DbcParseContext &) const {
throw std::runtime_error("SIG_VALTYPE_ declarations are unsupported; refusing potentially incorrect integer decoding.");
}
void DbcHeaderHandler::Handle(const std::string &, DbcParseContext &) const {}
bool DbcStatementDispatcher::Dispatch(const std::string &line,
+6
View File
@@ -133,6 +133,12 @@ public:
void Handle(const std::string &line, DbcParseContext &context) const override;
};
/** Reject explicit signal value types instead of treating their bits as integers. */
class DbcUnsupportedSignalTypeHandler : public DbcStatementHandler {
public:
void Handle(const std::string &line, DbcParseContext &context) const override;
};
/** Common header metadata does not change the supported decode definitions. */
class DbcHeaderHandler : public DbcStatementHandler {
public: