27#include "can_common.h"
62#if (BOARD_TLE8888_COUNT > 0)
79#define BENCH_MSG "bench"
82 output->
setValue(BENCH_MSG,
true,
true);
86#if EFI_PROD_CODE && (BOARD_EXT_GPIOCHIPS > 0)
87 static char pin_error[64];
90 if (diag == PIN_UNKNOWN) {
91 efiPrintf(
"No Diag on this pin");
94 efiPrintf(
"Diag says %s", pin_error);
97 output->
setValue(BENCH_MSG,
false,
true);
101 int onTimeUs = MS2US(std::max(0.1f, onTimeMs));
102 int offTimeUs = MS2US(std::max(0.1f, offTimeMs));
104 if (onTimeUs > TOO_FAR_INTO_FUTURE_US) {
109 efiPrintf(
"Running bench: ON_TIME=%d us OFF_TIME=%d us Counter=%d", onTimeUs, offTimeUs,
count);
119 efitick_t startTime = nowNt + US2NT(50);
120 efitick_t endTime = startTime + US2NT(onTimeUs);
122 auto const bstartAction{
swapOnOff ? action_s::make<benchOff>(output) : action_s::make<benchOn>(output) };
123 auto const bendAction{
swapOnOff ? action_s::make<benchOn>(output) : action_s::make<benchOff>(output) };
130 chThdSleepMicroseconds(onTimeUs + offTimeUs);
159static void pinbench(
float ontimeMs,
float offtimeMs,
int iterations,
160 OutputPin* pinParam,
bool p_swapOnOff =
false)
184 efiPrintf(
"Invalid index: %d", humanIndex);
193 efiPrintf(
"Invalid index: %d", humanIndex);
200 if (humanIndex < 1 || humanIndex > TCU_SOLENOID_COUNT) {
201 efiPrintf(
"Invalid index: %d", humanIndex);
208 if (humanIndex < 1 || humanIndex > LUA_PWM_COUNT) {
209 efiPrintf(
"Invalid index: %d", humanIndex);
328 #if EFI_WIDEBAND_FIRMWARE_UPDATE && EFI_CAN_SUPPORT
458 criticalError(
"Unexpected bench function %d", index);
468 UNUSED(durationsInStateMs);
489 #if (BOARD_TLE8888_COUNT > 0)
494 #if EFI_PROD_CODE && (BOARD_MC33810_COUNT > 0)
498#if EFI_SHAFT_POSITION_INPUT
506 #if EFI_CONFIGURATION_STORAGE
511 #if EFI_EMULATE_POSITION_SENSORS == TRUE
516 #if EFI_EMULATE_POSITION_SENSORS == TRUE
521 #if EFI_EMULATE_POSITION_SENSORS == TRUE
534#if EFI_ELECTRONIC_THROTTLE_BODY
573#if EFI_PROD_CODE && EFI_FILE_LOGGING
592 criticalError(
"Unexpected bench x14 %d", index);
622 union FloatIntBytes {
625 uint8_t bytes[
sizeof(
float)];
641 efiPrintf(
"processCanRequestCalibration=%x", hash);
646 for (
size_t i = 0;i<
sizeof(
float);i++) {
647 msg[4 + i] = fb.bytes[i];
652 for (
size_t i = 0;i<
sizeof(
float);i++) {
653 msg[i] = fb.bytes[i];
659 if (frame.
data8[0] != (
int)bench_test_magic_numbers_e::BENCH_HEADER) {
663 int eid = CAN_EID(frame);
664 if (eid == (
int)bench_test_packet_ids_e::ECU_SET_CALIBRATION) {
666 }
else if (eid == (
int)bench_test_packet_ids_e::ECU_REQ_CALIBRATION) {
668 }
else if (eid == (
int)bench_test_packet_ids_e::ECU_CAN_BUS_USER_CONTROL) {
676 efiPrintf(
"IO test subsystem=%d index=%d", subsystem, index);
726 uint8_t hwIndex = index >> 8;
727 uint8_t canIndex = index & 0xff;
731 hwIndex = hwIndex < 8 ? hwIndex : 0xff;
737 uint8_t hwIndex = index >> 8;
738 uint8_t sensType = index & 0xff;
742 hwIndex = hwIndex < 8 ? hwIndex : 0xff;
752 uint8_t hwIndex = index >> 8;
782#if EFI_PROD_CODE && EFI_DFU_JUMP
801 criticalError(
"Unexpected bench subsystem %d %d", subsystem, index);
841#if EFI_WIDEBAND_FIRMWARE_UPDATE
860 if (index < 0 || index > LUA_BUTTON_COUNT)
void jump_to_bootloader()
int luaCommandCounters[LUA_BUTTON_COUNT]
static void processCanRequestCalibration(const CANRxFrame &frame)
static void requestWidebandUpdate(int hwIndex)
static float globalOnTimeMs
static scheduling_s benchSchedStart
void executeTSCommand(uint16_t subsystem, uint16_t index)
static void runBench(OutputPin *output, float onTimeMs, float offTimeMs, int count, bool swapOnOff)
static void sparkBenchExt(float humanIndex, float onTime, float offTimeMs, float count)
PUBLIC_API_WEAK void boardTsAction(uint16_t index)
static volatile bool isBenchTestPending
int getSavedBenchTestPinStates(uint32_t durationsInStateMs[2])
static void benchOff(OutputPin *output)
static void doRunFuelInjBench(size_t humanIndex, float onTimeMs, float offTimeMs, int count)
static void handleCommandX14(uint16_t index)
static void doRunSolenoidBench(size_t humanIndex, float onTime, float offTime, int count)
static void sparkBench(float onTime, float offTimeMs, float count)
void processCanEcuControl(const CANRxFrame &frame)
static void processCanSetCalibration(const CANRxFrame &frame)
static void cancelBenchTest()
static void fanBenchExt(float onTimeMs)
static void doRunSparkBench(size_t humanIndex, float onTime, float offTime, int count)
static uint8_t widebandUpdateHwId
static void pinbench(float ontimeMs, float offtimeMs, int iterations, OutputPin *pinParam, bool p_swapOnOff=false)
static bool isRunningBench
static chibios_rt::CounterSemaphore benchSemaphore(0)
static void hdAcrBench(int index)
static void hpfpValveBench()
void onConfigurationChangeBenchTest()
static float globalOffTimeMs
bool isRunningBenchTest()
static void mainRelayBench()
static void doRunBenchTestLuaOutput(size_t humanIndex, float onTimeMs, float offTimeMs, int count)
static uint32_t savedDurationsInStateMs[2]
static void auxOutBench(int index)
static OutputPin * outputOnTheBenchTest
bool rebootForPresetPending
const OutputPin * getOutputOnTheBenchTest()
static bool widebandUpdatePending
static void fuelInjBench(float onTimeMs, float offTimeMs, float count)
static void processCanUserControl(const CANRxFrame &frame)
static void fuelInjBenchExt(float humanIndex, float onTimeMs, float offTimeMs, float count)
void handleBenchCategory(uint16_t index)
static int savedPinToggleCounter
static scheduling_s benchSchedEnd
static void vvtValveBench(int vvtIndex)
static void tcuSolenoidBench(float humanIndex, float onTime, float offTimeMs, float count)
static void benchOn(OutputPin *output)
static BenchController instance
static void fuelPumpBenchExt(float durationMs)
static void applyPreset(int index)
Utility methods related to bench testing.
uint16_t getTwoBytesLsb(const CANRxFrame &frame, int offset)
uint32_t getFourBytesLsb(const CANRxFrame &frame, int offset)
bool etbIgnoreJamProtection
SingleTimerExecutor scheduler
RpmCalculator rpmCalculator
TunerStudioOutputChannels outputChannels
RegisteredOutputPin harleyAcr2
RegisteredNamedOutputPin harleyAcr
RegisteredOutputPin mainRelay
OutputPin tcuSolenoids[TCU_SOLENOID_COUNT]
RegisteredOutputPin fanRelay
RegisteredOutputPin starterControl
OutputPin luaOutputPins[LUA_PWM_COUNT]
RegisteredOutputPin fanRelay2
InjectorOutputPin injectors[MAX_CYLINDER_COUNT]
RegisteredOutputPin fuelPumpRelay
RegisteredOutputPin acRelay
IgnitionOutputPin coils[MAX_CYLINDER_COUNT]
RegisteredOutputPin checkEnginePin
RegisteredNamedOutputPin hpfpValve
Single output pin reference and state.
brain_pin_diag_e getDiag() const
uint32_t durationsInStateMs[2]
void setValue(const char *msg, int logicValue, bool isForce=false)
bool isStopped() const override
void schedule(const char *msg, scheduling_s *scheduling, efitick_t timeNt, action_s const &action) override
Schedule an action to be executed in the future.
A base class for a controller that requires its own thread.
virtual void ThreadTask()=0
void addConsoleActionF(const char *token, VoidFloat callback)
void addConsoleAction(const char *token, Void callback)
Register console action without parameters.
void addConsoleActionII(const char *token, VoidIntInt callback)
Register a console command with two Integer parameters.
void addConsoleActionI(const char *token, VoidInt callback)
Register a console command with one Integer parameter.
void addConsoleActionFFFF(const char *token, VoidFloatFloatFloatFloat callback)
void addConsoleActionFFF(const char *token, VoidFloatFloatFloat callback)
void etbAutocal(dc_function_e function, bool reportToTs)
static EngineAccessor engine
static constexpr engine_configuration_s * engineConfiguration
@ TS_TRIGGER_STIMULATOR_ENABLE
@ TS_ETB_DISABLE_JAM_DETECT
@ TS_TRIGGER_STIMULATOR_DISABLE
@ TS_EXTERNAL_TRIGGER_STIMULATOR_ENABLE
@ BENCH_AC_COMPRESSOR_RELAY
@ BENCH_CHECK_ENGINE_LIGHT
@ BENCH_STARTER_ENABLE_RELAY
@ TS_WIDEBAND_SET_IDX_BY_ID
@ TS_WIDEBAND_SET_SENS_BY_ID
@ TS_WIDEBAND_FLASH_BY_ID
void firmwareError(ObdCode code, const char *fmt,...)
void startIdleBench(void)
UNUSED(samplingTimeSeconds)
void applyLongTermFuelTrimToVe()
void resetLongTermFuelTrim()
void devPokeLongTermFuelTrim()
This data structure holds current malfunction codes.
void sdCardRemoveReportFiles()
void sdCardRequestMode(SD_MODE mode)
void pinDiag2string(char *buffer, size_t size, brain_pin_diag_e pin_diag)
const char * hwPortname(brain_pin_e brainPin)
void setWidebandSensorType(uint8_t hwIndex, uint8_t type)
void pingWideband(uint8_t hwIndex)
void setWidebandOffset(uint8_t hwIndex, uint8_t index)
void updateWidebandFirmware(uint8_t hwIndex)
running("running", SensorCategory.SENSOR_INPUTS, FieldType.INT, 892, 1.0, -1.0, -1.0, "")
void setEngineType(int value, bool isWriteToFlash)
void doScheduleStopEngine(StopRequestedReason reason)
void startStopButtonToggle()
uint8_t data8[8]
Frame data.
scaled_channel< uint16_t, 100, 1 > benchTestOnTime
scaled_channel< uint16_t, 10, 1 > benchTestOffTime
void grapTps1PrimaryIsClosed()
void grapTps1PrimaryIsOpen()
void grabPedalIsWideOpen()
void disableTriggerStimulator()
void enableExternalTriggerStimulator()
void enableTriggerStimulator(bool incGlobalConfiguration)
void tsCalibrationSetIdle()
maintainConstantValue implementation header
float getConfigValueByHash(const int hash)
OutputPin * getVvtOutputPin(int index)