CAN: do null check first (#3755)

Otherwise it will emit strange error if both can are disabled
This commit is contained in:
Andrey G 2022-01-08 18:25:21 +03:00 committed by GitHub
parent c74f6e7c29
commit 752802b0cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions

View File

@ -276,14 +276,14 @@ void initCan(void) {
auto device1 = detectCanDevice(engineConfiguration->canRxPin, engineConfiguration->canTxPin);
auto device2 = detectCanDevice(engineConfiguration->can2RxPin, engineConfiguration->can2TxPin);
// Devices can't be the same!
if (device1 == device2) {
firmwareError(OBD_PCM_Processor_Fault, "CAN pins must be set to different devices");
// If both devices are null, a firmware error was already thrown by detectCanDevice, but we shouldn't continue
if (!device1 && !device2) {
return;
}
// If both devices are null, a firmware error was already thrown by detectCanDevice, but we shouldn't continue
if (!device1 && !device2) {
// Devices can't be the same!
if (device1 == device2) {
firmwareError(OBD_PCM_Processor_Fault, "CAN pins must be set to different devices");
return;
}