Skip to content

Commit

Permalink
packer: log undefined address/signal as error (#1052)
Browse files Browse the repository at this point in the history
* LOGE

* no -
  • Loading branch information
sshane authored Jun 8, 2024
1 parent eb6af30 commit 8c46e7b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions can/packer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,21 @@ CANPacker::CANPacker(const std::string& dbc_name) {
}

std::vector<uint8_t> CANPacker::pack(uint32_t address, const std::vector<SignalPackValue> &signals) {
std::vector<uint8_t> ret(message_lookup[address].size, 0);
auto msg_it = message_lookup.find(address);
if (msg_it == message_lookup.end()) {
LOGE("undefined address %d", address);
return {};
}

std::vector<uint8_t> ret(msg_it->second.size, 0);

// set all values for all given signal/value pairs
bool counter_set = false;
for (const auto& sigval : signals) {
auto sig_it = signal_lookup.find(std::make_pair(address, sigval.name));
if (sig_it == signal_lookup.end()) {
// TODO: do something more here. invalid flag like CANParser?
WARN("undefined signal %s - %d\n", sigval.name.c_str(), address);
LOGE("undefined signal %s - %d\n", sigval.name.c_str(), address);
continue;
}
const auto &sig = sig_it->second;
Expand Down

0 comments on commit 8c46e7b

Please sign in to comment.