Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion j1939_parser/j1939_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ std::set<uint32_t> J1939Parser::pgnFor(const std::string & signal, const std::ma
for (const auto & it: dbc) {
if (it.second.signalByName(signal.c_str())) {
result.emplace(it.first);
break;
}
}
return result;
Expand Down
3 changes: 2 additions & 1 deletion j1939_parser/j1939_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ class J1939Parser {
return setSignalValue(name.c_str(), enum_name);
}

// Find all PGNs which may contain the given signal
// Return every database key whose message contains this signal name.
// Matches are by name; an unknown name returns an empty set.
static std::set<uint32_t> pgnFor(const std::string & signal, const std::map<uint32_t, PGN> &dbc);
};

Expand Down
8 changes: 8 additions & 0 deletions j1939_parser/j1939_parser_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,3 +529,11 @@ TEST_F(J1939ParserTest, SetValuesConfigBigEndianTest) {
EXPECT_EQ(frame_.buffer_[1], 6);
EXPECT_EQ(frame_.buffer_[2], 64);
}

TEST(J1939ParserLookupTest, FindsEveryMessageContainingTheName) {
const SPN shared{"Shared", 0, 8, false, true, 1, 0, 0, 255, {}};
const std::map<uint32_t, PGN> dbc{{100, {"First", 1, {shared}}},
{101, {"Second", 1, {shared}}},
{102, {"Empty", 1, {}}}};
EXPECT_EQ(J1939Parser::pgnFor("Shared", dbc), (std::set<uint32_t>{100, 101}));
}
Loading