Skip to content

Commit

Permalink
fine inside
Browse files Browse the repository at this point in the history
  • Loading branch information
sshane committed Jul 14, 2023
1 parent 617d816 commit 66564a4
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions can/packer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@ std::vector<uint8_t> CANPacker::pack(uint32_t address, const std::vector<SignalP

// For signals with offsets, leaving bytes at zero results in non-zero parsed values.
// Require those signals to be explicitly set
for (const auto& dbc_signal : msg_it->second.sigs) {
if (dbc_signal.offset != 0 && enforce_checks) {
auto sig_it = std::find_if(values.begin(), values.end(), [&dbc_signal](const SignalPackValue& spv) { return spv.name == dbc_signal.name; });
if (sig_it == values.end()) {
throw std::runtime_error("CANPacker::pack(): missing signal with non-zero offset: " + dbc_signal.name + " in address " + std::to_string(address));
if (enforce_checks) {
for (const auto& dbc_signal : msg_it->second.sigs) {
if (dbc_signal.offset != 0) {
auto sig_it = std::find_if(values.begin(), values.end(), [&dbc_signal](const SignalPackValue& spv) { return spv.name == dbc_signal.name; });
if (sig_it == values.end()) {
throw std::runtime_error("CANPacker::pack(): missing signal with non-zero offset: " + dbc_signal.name + " in address " + std::to_string(address));
}
}
}
}
Expand Down

0 comments on commit 66564a4

Please sign in to comment.