Closes #12
This commit is contained in:
1 parent
3dd9230fca
commit
8bf5dcff30
5 files changed
+120
-9
No files matched your search
@@ -39,6 +39,8 @@ public:
|
||||
* @return Parsed database.
|
||||
* @throws std::runtime_error on file or parse errors.
|
||||
* 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.
|
||||
*/
|
||||
DbcDatabase ParseFile(const std::string &filePath) const;
|
||||
|
||||
|
||||
@@ -340,7 +340,11 @@ namespace {
|
||||
}// namespace
|
||||
|
||||
void DbcFrameHandler::Handle(const std::string &line, DbcParseContext &context) const {
|
||||
context.database.frames.push_back(ParseFrameLine(line));
|
||||
FrameInfo frame = ParseFrameLine(line);
|
||||
if (FindFrameById(context.database, frame.canId, frame.isExtended) != nullptr)
|
||||
throw std::runtime_error("Duplicate " + std::string(frame.isExtended ? "extended" : "standard") +
|
||||
" frame CAN ID: " + std::to_string(frame.canId));
|
||||
context.database.frames.push_back(std::move(frame));
|
||||
context.currentFrame = &context.database.frames.back();
|
||||
context.signalLines.emplace_back();
|
||||
}
|
||||
@@ -349,6 +353,9 @@ void DbcSignalHandler::Handle(const std::string &line, DbcParseContext &context)
|
||||
if (context.currentFrame == nullptr)
|
||||
throw std::runtime_error("Signal found before any frame definition.");
|
||||
SignalInfo signal = ParseSignalLine(line);
|
||||
if (FindSignalByName(*context.currentFrame, signal.name) != nullptr)
|
||||
throw std::runtime_error("Duplicate signal name '" + signal.name +
|
||||
"' in frame '" + context.currentFrame->name + "'.");
|
||||
const std::uint64_t payloadBits = static_cast<std::uint64_t>(context.currentFrame->dlc) * 8U;
|
||||
std::uint64_t bit = signal.startBit;
|
||||
for (std::uint32_t index = 0U; index < signal.length; ++index) {
|
||||
|
||||
Reference in new issue
Block a user