27#include "can_common.h"
63#if (BOARD_TLE8888_COUNT > 0)
80#define BENCH_MSG "bench"
83 output->
setValue(BENCH_MSG,
true,
true);
87#if EFI_PROD_CODE && (BOARD_EXT_GPIOCHIPS > 0)
88 static char pin_error[64];
91 if (diag == PIN_UNKNOWN) {
92 efiPrintf(
"No Diag on this pin");
95 efiPrintf(
"Diag says %s", pin_error);
98 output->
setValue(BENCH_MSG,
false,
true);
102 int onTimeUs = MS2US(std::max(0.1f, onTimeMs));
103 int offTimeUs = MS2US(std::max(0.1f, offTimeMs));
105 if (onTimeUs > TOO_FAR_INTO_FUTURE_US) {
110 efiPrintf(
"Running bench: ON_TIME=%d us OFF_TIME=%d us Counter=%d", onTimeUs, offTimeUs,
count);
120 efitick_t startTime = nowNt + US2NT(50);
121 efitick_t endTime = startTime + US2NT(onTimeUs);
123 auto const bstartAction{
swapOnOff ? action_s::make<benchOff>(output) : action_s::make<benchOn>(output) };
124 auto const bendAction{
swapOnOff ? action_s::make<benchOn>(output) : action_s::make<benchOff>(output) };
131 chThdSleepMicroseconds(onTimeUs + offTimeUs);
160static void pinbench(
float ontimeMs,
float offtimeMs,
int iterations,
161 OutputPin* pinParam,
bool p_swapOnOff =
false)
185 efiPrintf(
"Invalid index: %d", humanIndex);
194 efiPrintf(
"Invalid index: %d", humanIndex);
201 if (humanIndex < 1 || humanIndex > TCU_SOLENOID_COUNT) {
202 efiPrintf(
"Invalid index: %d", humanIndex);
209 if (humanIndex < 1 || humanIndex > LUA_PWM_COUNT) {
210 efiPrintf(
"Invalid index: %d", humanIndex);
329 #if EFI_WIDEBAND_FIRMWARE_UPDATE && EFI_CAN_SUPPORT
459 criticalError(
"Unexpected bench function %d", index);
469 UNUSED(durationsInStateMs);
490 #if (BOARD_TLE8888_COUNT > 0)
495 #if EFI_PROD_CODE && (BOARD_MC33810_COUNT > 0)
499#if EFI_SHAFT_POSITION_INPUT
507 #if EFI_CONFIGURATION_STORAGE
512 #if EFI_EMULATE_POSITION_SENSORS == TRUE
517 #if EFI_EMULATE_POSITION_SENSORS == TRUE
522 #if EFI_EMULATE_POSITION_SENSORS == TRUE
535#if EFI_ELECTRONIC_THROTTLE_BODY
574#if EFI_PROD_CODE && EFI_FILE_LOGGING
593 criticalError(
"Unexpected bench x14 %d", index);
624 union FloatIntBytes {
627 uint8_t bytes[
sizeof(
float)];
643 efiPrintf(
"processCanRequestCalibration=%x", hash);
648 for (
size_t i = 0;i<
sizeof(
float);i++) {
649 msg[4 + i] = fb.bytes[i];
654 for (
size_t i = 0;i<
sizeof(
float);i++) {
655 msg[i] = fb.bytes[i];
661 if (frame.
data8[0] != (
int)bench_test_magic_numbers_e::BENCH_HEADER) {
665 int eid = CAN_EID(frame);
666 if (eid == (
int)bench_test_packet_ids_e::ECU_SET_CALIBRATION) {
668 }
else if (eid == (
int)bench_test_packet_ids_e::ECU_REQ_CALIBRATION) {
670 }
else if (eid == (
int)bench_test_packet_ids_e::ECU_CAN_BUS_USER_CONTROL) {
680 efiPrintf(
"IO test subsystem=%d index=%d", subsystem, index);
730 uint8_t hwIndex = index >> 8;
731 uint8_t canIndex = index & 0xff;
735 hwIndex = hwIndex < 8 ? hwIndex : 0xff;
741 uint8_t hwIndex = index >> 8;
742 uint8_t sensType = index & 0xff;
746 hwIndex = hwIndex < 8 ? hwIndex : 0xff;
756 uint8_t hwIndex = index >> 8;
789#if EFI_PROD_CODE && EFI_DFU_JUMP
808 criticalError(
"Unexpected bench subsystem %d %d", subsystem, index);
848#if EFI_WIDEBAND_FIRMWARE_UPDATE
867 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)
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)
std::optional< setup_custom_board_ts_command_override_type > custom_board_ts_command
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 boardTsAction(uint16_t index)
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, 888, 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)