From 720ba01d045d5a1f24798bf49aca281559ad901a Mon Sep 17 00:00:00 2001 From: rusefi Date: Tue, 29 Aug 2023 00:24:46 -0400 Subject: [PATCH] proteus fails to start while powered by stim board #5545 only:proteus_f7 --- firmware/console/status_loop.cpp | 6 +++--- firmware/controllers/core/error_handling.cpp | 2 +- firmware/controllers/system/efi_gpio.cpp | 10 +++++----- firmware/controllers/system/efi_output.h | 4 ++-- unit_tests/mocks.h | 2 +- unit_tests/tests/actuators/test_dc_motor.cpp | 10 +++++----- unit_tests/tests/actuators/test_gppwm.cpp | 12 ++++++------ 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index 6fbb0338be..29967c7e64 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -290,7 +290,7 @@ class CommunicationBlinkingTask : public PeriodicTimerController { // make sure we do not turn the critical LED off if already have // critical error by now for (uint32_t i = 0; !hasFirmwareError() && i < sizeof(leds) / sizeof(leds[0]); i++) { - leds[i]->setValue(value); + leds[i]->setValue(value, /*force*/true); } } @@ -306,7 +306,7 @@ class CommunicationBlinkingTask : public PeriodicTimerController { // second invocation of BlinkingTask setAllLeds(0); } else if (counter % 2 == 0) { - enginePins.communicationLedPin.setValue(0); + enginePins.communicationLedPin.setValue(0, /*force*/true); #if HW_CHECK_SD extern int totalLoggedBytes; if (totalLoggedBytes > 2000) { @@ -342,7 +342,7 @@ extern int totalLoggedBytes; offTimeMs = 0.6 * onTimeMs; } - enginePins.communicationLedPin.setValue(1); + enginePins.communicationLedPin.setValue(1, /*force*/true); //#if HW_CHECK_MODE // // we have to do anything possible to help users notice FACTORY MODE // enginePins.errorLedPin.setValue(0); diff --git a/firmware/controllers/core/error_handling.cpp b/firmware/controllers/core/error_handling.cpp index 4dabeca2b8..71ef084430 100644 --- a/firmware/controllers/core/error_handling.cpp +++ b/firmware/controllers/core/error_handling.cpp @@ -252,7 +252,7 @@ void firmwareError(ObdCode code, const char *fmt, ...) { va_end(ap); #endif criticalShutdown(); - enginePins.communicationLedPin.setValue(1); + enginePins.communicationLedPin.setValue(1, /*force*/true); hasFirmwareErrorFlag = true; if (indexOf(fmt, '%') == -1) { diff --git a/firmware/controllers/system/efi_gpio.cpp b/firmware/controllers/system/efi_gpio.cpp index 57ef8868b4..179e6bd3fa 100644 --- a/firmware/controllers/system/efi_gpio.cpp +++ b/firmware/controllers/system/efi_gpio.cpp @@ -492,14 +492,14 @@ void OutputPin::setOnchipValue(int electricalValue) { } #endif // EFI_PROD_CODE -void OutputPin::setValue(int logicValue) { - setValue(nullptr, logicValue); +void OutputPin::setValue(int logicValue, bool isForce) { + setValue(nullptr, logicValue, isForce); } extern bool qcDirectPinControlMode; -void OutputPin::setValue(const char *msg, int logicValue) { - if (qcDirectPinControlMode) { +void OutputPin::setValue(const char *msg, int logicValue, bool isForce) { + if (qcDirectPinControlMode && !isForce) { return; } @@ -553,7 +553,7 @@ bool OutputPin::getLogicValue() const { void OutputPin::setDefaultPinState(pin_output_mode_e outputMode) { assertOMode(mode); this->mode = outputMode; - setValue(false); // initial state + setValue(false, /*force*/true); // initial state } brain_pin_diag_e OutputPin::getDiag() const { diff --git a/firmware/controllers/system/efi_output.h b/firmware/controllers/system/efi_output.h index 1789afafe8..34a343c95a 100644 --- a/firmware/controllers/system/efi_output.h +++ b/firmware/controllers/system/efi_output.h @@ -53,8 +53,8 @@ public: bool isInitialized(); bool getAndSet(int logicValue); - void setValue(const char *msg, int logicValue); - TEST_VIRTUAL void setValue(int logicValue); + void setValue(const char *msg, int logicValue, bool isForce = false); + TEST_VIRTUAL void setValue(int logicValue, bool isForce = false); void toggle(); bool getLogicValue() const; diff --git a/unit_tests/mocks.h b/unit_tests/mocks.h index e093523d09..0e2cd8ab8b 100644 --- a/unit_tests/mocks.h +++ b/unit_tests/mocks.h @@ -71,7 +71,7 @@ public: MockOutputPin(); virtual ~MockOutputPin(); - MOCK_METHOD(void, setValue, (int value), (override)); + MOCK_METHOD(void, setValue, (int value, bool isForce), (override)); }; class MockExecutor : public TestExecutor { diff --git a/unit_tests/tests/actuators/test_dc_motor.cpp b/unit_tests/tests/actuators/test_dc_motor.cpp index 96c1a461ad..4a1ea848b1 100644 --- a/unit_tests/tests/actuators/test_dc_motor.cpp +++ b/unit_tests/tests/actuators/test_dc_motor.cpp @@ -9,7 +9,7 @@ using ::testing::StrictMock; TEST(DcMotor, Disable) { StrictMock dpin; - EXPECT_CALL(dpin, setValue(1)) + EXPECT_CALL(dpin, setValue(1, testing::_)) .Times(2); // happens twice - once for initial disable, once for set(0) TwoPinDcMotor dut(dpin); @@ -18,7 +18,7 @@ TEST(DcMotor, Disable) { TEST(DcMotor, Disable2) { StrictMock dpin; - EXPECT_CALL(dpin, setValue(1)).Times(4); + EXPECT_CALL(dpin, setValue(1, testing::_)).Times(4); TwoPinDcMotor dut(dpin); @@ -32,10 +32,10 @@ TEST(DcMotor, Enable) { InSequence is; // Construction disables - EXPECT_CALL(dpin, setValue(1)).Times(2); + EXPECT_CALL(dpin, setValue(1, testing::_)).Times(2); // Then enable - EXPECT_CALL(dpin, setValue(0)); + EXPECT_CALL(dpin, setValue(0, testing::_)); } TwoPinDcMotor dut(dpin); @@ -44,7 +44,7 @@ TEST(DcMotor, Enable) { TEST(DcMotor, SetUnconfigured) { StrictMock dpin; - EXPECT_CALL(dpin, setValue(1)).Times(3); + EXPECT_CALL(dpin, setValue(1, testing::_)).Times(3); TwoPinDcMotor dut(dpin); EXPECT_FLOAT_EQ(dut.get(), 0); diff --git a/unit_tests/tests/actuators/test_gppwm.cpp b/unit_tests/tests/actuators/test_gppwm.cpp index 29a635f0be..dfb8878a17 100644 --- a/unit_tests/tests/actuators/test_gppwm.cpp +++ b/unit_tests/tests/actuators/test_gppwm.cpp @@ -50,14 +50,14 @@ TEST(GpPwm, OutputOnOff) { InSequence i; // Rising edge test - EXPECT_CALL(pin, setValue(0)); - EXPECT_CALL(pin, setValue(1)); - EXPECT_CALL(pin, setValue(1)); + EXPECT_CALL(pin, setValue(0, false)); + EXPECT_CALL(pin, setValue(1, false)); + EXPECT_CALL(pin, setValue(1, false)); // Falling edge test - EXPECT_CALL(pin, setValue(1)); - EXPECT_CALL(pin, setValue(0)); - EXPECT_CALL(pin, setValue(0)); + EXPECT_CALL(pin, setValue(1, false)); + EXPECT_CALL(pin, setValue(0, false)); + EXPECT_CALL(pin, setValue(0, false)); } ch.init(false, nullptr, &pin, nullptr, &cfg);