use 2 cycles for pin bench_tests only for simulator

This commit is contained in:
andreika-git 2023-10-17 19:54:52 +03:00 committed by rusefillc
parent a7de8fd1b6
commit dec0b16e87
2 changed files with 6 additions and 0 deletions

View File

@ -136,7 +136,11 @@ static void pinbench(float p_ontimeMs, float p_offtimeMs, int iterations,
{
onTimeMs = p_ontimeMs;
offTimeMs = p_offtimeMs;
#if EFI_SIMULATOR
count = maxI(2, iterations);
#else
count = iterations;
#endif // EFI_SIMULATOR
pinX = pinParam;
// let's signal bench thread to wake up
isBenchTestPending = true;

View File

@ -184,6 +184,8 @@ private void testOutputPin(bench_mode_e pinId, int stateToggleTimeMs) throws Int
executeIoControlCommand(bench_test_io_control_e.CAN_BENCH_END_PIN_TEST,
new bench_test_packet_ids_e[] { }, (byte)pinId.ordinal());
// this check assumes that simulator makes 2 iterations for each pin
// (this magic is needed because we don't know the previous pin state before starting the test)
if (pinToggleCounter < defaultPinToggleCounter + 3 || pinToggleCounter > defaultPinToggleCounter + 4) {
throw new IllegalStateException("Unexpected pin toggle counter: before="
+ defaultPinToggleCounter + " after=" + pinToggleCounter);