commaai / opendbc

democratize access to car decoder rings

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CAN parser: assert signals exist

sshane opened this issue · comments

We already assert messages exist, but signals are unchecked. This was the cause of commaai/openpilot#28404, CRUISE_INACTIVE inside SCC_CONTROL doesn't exist, but it never complained or gave a warning before. @deanlee see any reason not to check signals too?

Code to reproduce:

from opendbc.can.parser import CANParser
cp = CANParser('hyundai_canfd', [("ANYTHING123", "SCC_CONTROL")], [("SCC_CONTROL", 50)], 2)

Related to #500

This should absolutely have an assert.

The signal option name is passed all the way to the cpp code, which only loops through the DBC signals to find any matches, it doesn't check it finds one

opendbc/can/parser.cc

Lines 144 to 150 in e51a787

for (const auto& sig : msg->sigs) {
if (sig.name == sigop.name && sig.type == SignalType::DEFAULT) {
state.parse_sigs.push_back(sig);
state.vals.push_back(0);
state.all_vals.push_back({});
break;
}

how about check it in cython? #870