less violent error handling

This commit is contained in:
rusefi 2022-08-21 22:46:59 -04:00
parent 329edcddfc
commit b94195255c
3 changed files with 5 additions and 7 deletions

View File

@ -27,8 +27,8 @@ void resetLuaCanRx() {
}
void addLuaCanRxFilter(int32_t eid, uint32_t mask, int bus, int callback) {
if (bus != ANY_BUS) {
assertHwCanBusIndex(bus);
if (bus != ANY_BUS && !isValidHwCanBusIndex(bus)) {
efiPrintf("LUA CAN bus index %d is not valid", bus);
}
if (filterCount >= maxFilterCount) {

View File

@ -335,9 +335,7 @@ bool getIsCanEnabled(void) {
#endif /* EFI_CAN_SUPPORT */
void assertHwCanBusIndex(const size_t busIndex) {
bool isValidHwCanBusIndex(const size_t busIndex) {
// 'size_t' is an unsigned type so we are never below zero here
if (busIndex > 1) {
firmwareError(CUSTOM_OBD_70, "Invalid HW CAN bus index %d", busIndex);
}
return (busIndex <= 1);
}

View File

@ -26,4 +26,4 @@ void postCanState();
#endif /* EFI_CAN_SUPPORT */
void assertHwCanBusIndex(const size_t busIndex);
bool isValidHwCanBusIndex(const size_t busIndex);