diagnostic: throw OBD code P0641 if analog fails

This commit is contained in:
Andrey Gusakov 2024-12-12 00:47:30 +03:00 committed by rusefillc
parent f6936f8eb6
commit 55fed44508
4 changed files with 19 additions and 2 deletions

View File

@ -687,7 +687,7 @@ enum class ObdCode : uint16_t {
OBD_Throttle_Actuator_Control_Range_Performance_Bank_1 = 638,
//P0639 Throttle Actuator Control Range/Performance (Bank 2)
//P0640 Intake Air Heater Control Circuit
//P0641 Sensor Reference Voltage “A” Circuit/Open
OBD_Sensor_Refence_Voltate_A_Open = 641,
//P0642 Sensor Reference Voltage “A” Circuit Low
//P0643 Sensor Reference Voltage “A” Circuit High
//P0644 Driver Display Serial Communication Circuit

View File

@ -197,8 +197,9 @@ void SensorChecker::onSlowCallback() {
check(SensorType::FuelEthanolPercent);
#if EFI_PROD_CODE
// only bother checking these if we have GPIO chips actually capable of reporting an error
#if BOARD_EXT_GPIOCHIPS > 0 && EFI_PROD_CODE
#if BOARD_EXT_GPIOCHIPS > 0
TunerStudioOutputChannels *state = getTunerStudioOutputChannels();
// Check injectors
#if EFI_ENGINE_CONTROL
@ -248,6 +249,14 @@ void SensorChecker::onSlowCallback() {
state->ignitorDiagnostic[i] = getTSErrorCode(diag);
}
#endif // BOARD_EXT_GPIOCHIPS > 0
// Check ADC(s) and analog inputs
if (analogGetDiagnostic() < 0) {
/* TODO: map to more OBD codes? */
warning(ObdCode::OBD_Sensor_Refence_Voltate_A_Open, "Analog subsystem fault");
}
#endif // EFI_PROD_CODE
boardSensorChecker();
}

View File

@ -32,6 +32,13 @@ int PUBLIC_API_WEAK boardGetAnalogInputDiagnostic(adc_channel_e channel, float)
return 0;
}
/* Get analog part diagnostic */
int analogGetDiagnostic()
{
/* TODO: debounce? */
return boardGetAnalogDiagnostic();
}
#if HAL_USE_ADC
#include "adc_subscription.h"

View File

@ -38,6 +38,7 @@ inline bool isAdcChannelOffChip(adc_channel_e hwChannel) {
return (isAdcChannelValid(hwChannel) && (hwChannel > EFI_ADC_ONCHIP_LAST));
}
int analogGetDiagnostic();
#if !defined(GPT_FREQ_FAST) || !defined(GPT_PERIOD_FAST)