diff --git a/firmware/controllers/actuators/dc_motors.cpp b/firmware/controllers/actuators/dc_motors.cpp index 5524fe3f1b..3ab6588061 100644 --- a/firmware/controllers/actuators/dc_motors.cpp +++ b/firmware/controllers/actuators/dc_motors.cpp @@ -113,9 +113,9 @@ void setDcMotorDuty(size_t index, float duty) { } -void showDcMotorInfo(Logging* logger, int i) { +void showDcMotorInfo(int i) { DcHardware *dc = &dcHardware[i]; - scheduleMsg(logger, " motor: dir=%d DC=%f", dc->dcMotor.isOpenDirection(), dc->dcMotor.get()); + efiPrintf(" motor: dir=%d DC=%f", dc->dcMotor.isOpenDirection(), dc->dcMotor.get()); } diff --git a/firmware/controllers/actuators/dc_motors.h b/firmware/controllers/actuators/dc_motors.h index 8210fbb212..56ec8f5ab1 100644 --- a/firmware/controllers/actuators/dc_motors.h +++ b/firmware/controllers/actuators/dc_motors.h @@ -11,7 +11,6 @@ #include "global.h" class DcMotor; -class Logger; DcMotor* initDcMotor(const dc_io& io, size_t index, bool useTwoWires DECLARE_ENGINE_PARAMETER_SUFFIX); @@ -19,5 +18,5 @@ DcMotor* initDcMotor(const dc_io& io, size_t index, bool useTwoWires DECLARE_ENG void setDcMotorFrequency(size_t index, int hz); void setDcMotorDuty(size_t index, float duty); -void showDcMotorInfo(Logging* logger, int i); +void showDcMotorInfo(int i); diff --git a/firmware/controllers/actuators/electronic_throttle.cpp b/firmware/controllers/actuators/electronic_throttle.cpp index 86a70b4f8e..399da21e7b 100644 --- a/firmware/controllers/actuators/electronic_throttle.cpp +++ b/firmware/controllers/actuators/electronic_throttle.cpp @@ -225,8 +225,8 @@ void EtbController::onConfigurationChange(pid_s* previousConfiguration) { } } -void EtbController::showStatus(Logging* logger) { - m_pid.showPidStatus(logger, "ETB"); +void EtbController::showStatus() { + m_pid.showPidStatus("ETB"); } expected EtbController::observePlant() const { @@ -540,7 +540,7 @@ void EtbController::update() { m_pid.iTermMax = engineConfiguration->etb_iTermMax; if (engineConfiguration->isVerboseETB) { - m_pid.showPidStatus(&logger, "ETB"); + m_pid.showPidStatus("ETB"); } // Update local state about autotune @@ -714,7 +714,7 @@ static void showEthInfo(void) { scheduleMsg(&logger, " dir2=%s", hwPortname(CONFIG(etbIo[i].directionPin2))); scheduleMsg(&logger, " control=%s", hwPortname(CONFIG(etbIo[i].controlPin1))); scheduleMsg(&logger, " disable=%s", hwPortname(CONFIG(etbIo[i].disablePin))); - showDcMotorInfo(&logger, i); + showDcMotorInfo(i); } #endif /* EFI_PROD_CODE */ diff --git a/firmware/controllers/actuators/electronic_throttle_impl.h b/firmware/controllers/actuators/electronic_throttle_impl.h index a23a0c7e0b..613b08a419 100644 --- a/firmware/controllers/actuators/electronic_throttle_impl.h +++ b/firmware/controllers/actuators/electronic_throttle_impl.h @@ -23,8 +23,6 @@ #define ETB_LOOP_FREQUENCY 500 #define DEFAULT_ETB_PWM_FREQUENCY 800 -class Logging; - class EtbController : public IEtbController { public: bool init(etb_function_e function, DcMotor *motor, pid_s *pidParameters, const ValueProvider3D* pedalMap, bool initializeThrottles) override; @@ -40,7 +38,7 @@ public: void onConfigurationChange(pid_s* previousConfiguration); // Print this throttle's status. - void showStatus(Logging* logger); + void showStatus(); // Helpers for individual parts of throttle control expected observePlant() const override; diff --git a/firmware/controllers/actuators/idle_thread.cpp b/firmware/controllers/actuators/idle_thread.cpp index 6f96e27e5d..5b5bfebe90 100644 --- a/firmware/controllers/actuators/idle_thread.cpp +++ b/firmware/controllers/actuators/idle_thread.cpp @@ -142,11 +142,11 @@ static void showIdleInfo(DECLARE_ENGINE_PARAMETER_SIGNATURE) { scheduleMsg(logger, "Coil A:"); scheduleMsg(logger, " pin1=%s", hwPortname(CONFIG(stepperDcIo[0].directionPin1))); scheduleMsg(logger, " pin2=%s", hwPortname(CONFIG(stepperDcIo[0].directionPin2))); - showDcMotorInfo(logger, 2); + showDcMotorInfo(2); scheduleMsg(logger, "Coil B:"); scheduleMsg(logger, " pin1=%s", hwPortname(CONFIG(stepperDcIo[1].directionPin1))); scheduleMsg(logger, " pin2=%s", hwPortname(CONFIG(stepperDcIo[1].directionPin2))); - showDcMotorInfo(logger, 3); + showDcMotorInfo(3); } else { scheduleMsg(logger, "directionPin=%s reactionTime=%.2f", hwPortname(CONFIG(idle).stepperDirectionPin), engineConfiguration->idleStepperReactionTime); @@ -167,7 +167,7 @@ static void showIdleInfo(DECLARE_ENGINE_PARAMETER_SIGNATURE) { } if (engineConfiguration->idleMode == IM_AUTO) { - getIdlePid(PASS_ENGINE_PARAMETER_SIGNATURE)->showPidStatus(logger, "idle"); + getIdlePid(PASS_ENGINE_PARAMETER_SIGNATURE)->showPidStatus("idle"); } } @@ -479,8 +479,8 @@ static percent_t automaticIdleController(float tpsPos, float rpm, int targetRpm, engine->engineState.isAutomaticIdle = tps.Valid && engineConfiguration->idleMode == IM_AUTO; if (engineConfiguration->isVerboseIAC && engine->engineState.isAutomaticIdle) { - scheduleMsg(logger, "Idle state %s", getIdle_state_e(engine->engineState.idle.idleState)); - getIdlePid(PASS_ENGINE_PARAMETER_SIGNATURE)->showPidStatus(logger, "idle"); + efiPrintf("Idle state %s", getIdle_state_e(engine->engineState.idle.idleState)); + getIdlePid(PASS_ENGINE_PARAMETER_SIGNATURE)->showPidStatus("idle"); } finishIdleTestIfNeeded(); diff --git a/firmware/controllers/bench_test.cpp b/firmware/controllers/bench_test.cpp index 66ee5498cc..6cea36775c 100644 --- a/firmware/controllers/bench_test.cpp +++ b/firmware/controllers/bench_test.cpp @@ -285,7 +285,7 @@ private: if (widebandUpdatePending) { #if EFI_WIDEBAND_FIRMWARE_UPDATE && EFI_CAN_SUPPORT - updateWidebandFirmware(logger); + updateWidebandFirmware(); #endif widebandUpdatePending = false; } @@ -437,7 +437,7 @@ void executeTSCommand(uint16_t subsystem, uint16_t index) { break; #ifdef EFI_WIDEBAND_FIRMWARE_UPDATE case 0x15: - setWidebandOffset(logger, index); + setWidebandOffset(index); break; #endif // EFI_WIDEBAND_FIRMWARE_UPDATE case CMD_TS_BENCH_CATEGORY: @@ -506,7 +506,7 @@ void initBenchTest(Logging *sharedLogger) { #if EFI_WIDEBAND_FIRMWARE_UPDATE addConsoleAction("update_wideband", []() { widebandUpdatePending = true; }); - addConsoleActionI("set_wideband_index", [](int index) { setWidebandOffset(logger, index); }); + addConsoleActionI("set_wideband_index", [](int index) { setWidebandOffset(index); }); #endif // EFI_WIDEBAND_FIRMWARE_UPDATE addConsoleAction(CMD_STARTER_BENCH, starterRelayBench); diff --git a/firmware/controllers/can/can.h b/firmware/controllers/can/can.h index 8203a5ad57..9bda7166b8 100644 --- a/firmware/controllers/can/can.h +++ b/firmware/controllers/can/can.h @@ -30,9 +30,9 @@ void registerCanSensor(CanSensorBase& sensor); // Indicate that an ack response was received from the wideband bootloader void handleWidebandBootloaderAck(); // Update the firmware on any connected wideband controller -void updateWidebandFirmware(Logging*); +void updateWidebandFirmware(); // Set the CAN index offset of any attached wideband controller -void setWidebandOffset(Logging* logging, uint8_t index); +void setWidebandOffset(uint8_t index); class CanWrite final : public PeriodicController<512> { public: diff --git a/firmware/controllers/can/wideband_bootloader.cpp b/firmware/controllers/can/wideband_bootloader.cpp index 761630d63f..c71ea58ce3 100644 --- a/firmware/controllers/can/wideband_bootloader.cpp +++ b/firmware/controllers/can/wideband_bootloader.cpp @@ -24,17 +24,17 @@ bool waitAck() { return chEvtWaitAnyTimeout(EVT_BOOTLOADER_ACK, TIME_MS2I(1000)) != 0; } -void updateWidebandFirmware(Logging* logging) { +void updateWidebandFirmware() { // Clear any pending acks for this thread chEvtGetAndClearEvents(EVT_BOOTLOADER_ACK); // Send messages to the current thread when acks come in waitingBootloaderThread = chThdGetSelfX(); - scheduleMsg(logging, "***************************************"); - scheduleMsg(logging, " WIDEBAND FIRMWARE UPDATE"); - scheduleMsg(logging, "***************************************"); - scheduleMsg(logging, "Wideband Update: Rebooting to bootloader..."); + efiPrintf("***************************************"); + efiPrintf(" WIDEBAND FIRMWARE UPDATE"); + efiPrintf("***************************************"); + efiPrintf("Wideband Update: Rebooting to bootloader..."); // The first request will reboot the chip (if necessary), and the second one will enable bootloader mode // If the chip was already in bootloader (aka manual mode), then that's ok - the second request will @@ -46,7 +46,7 @@ void updateWidebandFirmware(Logging* logging) { } if (!waitAck()) { - scheduleMsg(logging, "Wideband Update ERROR: Expected ACK from entry to bootloader, didn't get one."); + efiPrintf("Wideband Update ERROR: Expected ACK from entry to bootloader, didn't get one."); return; } @@ -54,7 +54,7 @@ void updateWidebandFirmware(Logging* logging) { chThdSleepMilliseconds(200); } - scheduleMsg(logging, "Wideband Update: in update mode, erasing flash..."); + efiPrintf("Wideband Update: in update mode, erasing flash..."); { // Erase flash - opcode 1, magic value 0x5A5A @@ -62,13 +62,13 @@ void updateWidebandFirmware(Logging* logging) { } if (!waitAck()) { - scheduleMsg(logging, "Wideband Update ERROR: Expected ACK from flash erase command, didn't get one."); + efiPrintf("Wideband Update ERROR: Expected ACK from flash erase command, didn't get one."); return; } size_t totalSize = sizeof(build_wideband_image_bin); - scheduleMsg(logging, "Wideband Update: Flash erased! Sending %d bytes...", totalSize); + efiPrintf("Wideband Update: Flash erased! Sending %d bytes...", totalSize); // Send flash data 8 bytes at a time for (size_t i = 0; i < totalSize; i += 8) { @@ -78,12 +78,12 @@ void updateWidebandFirmware(Logging* logging) { } if (!waitAck()) { - scheduleMsg(logging, "Wideband Update ERROR: Expected ACK from data write, didn't get one."); + efiPrintf("Wideband Update ERROR: Expected ACK from data write, didn't get one."); return; } } - scheduleMsg(logging, "Wideband Update: Update complete! Rebooting controller."); + efiPrintf("Wideband Update: Update complete! Rebooting controller."); { // Reboot to firmware! @@ -95,17 +95,17 @@ void updateWidebandFirmware(Logging* logging) { waitingBootloaderThread = nullptr; } -void setWidebandOffset(Logging* logging, uint8_t index) { +void setWidebandOffset(uint8_t index) { // Clear any pending acks for this thread chEvtGetAndClearEvents(EVT_BOOTLOADER_ACK); // Send messages to the current thread when acks come in waitingBootloaderThread = chThdGetSelfX(); - scheduleMsg(logging, "***************************************"); - scheduleMsg(logging, " WIDEBAND INDEX SET"); - scheduleMsg(logging, "***************************************"); - scheduleMsg(logging, "Setting all connected widebands to index %d...", index); + efiPrintf("***************************************"); + efiPrintf(" WIDEBAND INDEX SET"); + efiPrintf("***************************************"); + efiPrintf("Setting all connected widebands to index %d...", index); { CanTxMessage m(0xEF4'0000, 1, true); diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index 98f810bc98..b7d7fd98aa 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -565,7 +565,7 @@ void commonInitEngineController(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_S #if !EFI_UNIT_TEST // This is tested independently - don't configure sensors for tests. // This lets us selectively mock them for each test. - initNewSensors(sharedLogger); + initNewSensors(); #endif /* EFI_UNIT_TEST */ initSensors(sharedLogger PASS_ENGINE_PARAMETER_SUFFIX); diff --git a/firmware/controllers/engine_cycle/rpm_calculator.h b/firmware/controllers/engine_cycle/rpm_calculator.h index 80c394b57a..98a25cf565 100644 --- a/firmware/controllers/engine_cycle/rpm_calculator.h +++ b/firmware/controllers/engine_cycle/rpm_calculator.h @@ -122,7 +122,7 @@ public: protected: // Print sensor info - current RPM state - void showInfo(Logging* logger, const char* sensorName) const override; + void showInfo(const char* sensorName) const override; private: /** diff --git a/firmware/controllers/sensors/Lps25Sensor.h b/firmware/controllers/sensors/Lps25Sensor.h index bdb9c83047..115696a865 100644 --- a/firmware/controllers/sensors/Lps25Sensor.h +++ b/firmware/controllers/sensors/Lps25Sensor.h @@ -8,7 +8,7 @@ public: explicit Lps25Sensor(Lps25& sensor); void update(); - void showInfo(Logging* logger, const char* sensorName) const override; + void showInfo(const char* sensorName) const override; private: Lps25* m_sensor; diff --git a/firmware/controllers/sensors/can_sensor.h b/firmware/controllers/sensors/can_sensor.h index 2d640bce61..f4394e1acb 100644 --- a/firmware/controllers/sensors/can_sensor.h +++ b/firmware/controllers/sensors/can_sensor.h @@ -26,7 +26,7 @@ public: { } - void showInfo(Logging* logger, const char* sensorName) const override; + void showInfo(const char* sensorName) const override; }; template diff --git a/firmware/controllers/sensors/converters/func_chain.h b/firmware/controllers/sensors/converters/func_chain.h index 164d5bd349..700bf7846a 100644 --- a/firmware/controllers/sensors/converters/func_chain.h +++ b/firmware/controllers/sensors/converters/func_chain.h @@ -25,9 +25,8 @@ protected: return input; } - void showInfo(Logging* logger, float testInputValue) const { + void showInfo(float testInputValue) const { // base case does nothing - (void)logger; (void)testInputValue; } }; @@ -64,14 +63,14 @@ public: return TBase::template get(); } - void showInfo(Logging* logger, float testInputValue) const { + void showInfo(float testInputValue) const { // Print info about this level - m_f.showInfo(logger, testInputValue); + m_f.showInfo(testInputValue); // If valid, recurse down auto res = m_f.convert(testInputValue); if (res.Valid) { - TBase::showInfo(logger, res.Value); + TBase::showInfo(res.Value); } } @@ -94,8 +93,8 @@ public: return m_fs.template get(); } - void showInfo(Logging* logger, float testInputValue) const override { - m_fs.showInfo(logger, testInputValue); + void showInfo(float testInputValue) const override { + m_fs.showInfo(testInputValue); } private: diff --git a/firmware/controllers/sensors/converters/linear_func.h b/firmware/controllers/sensors/converters/linear_func.h index 1081df708a..e6647fae56 100644 --- a/firmware/controllers/sensors/converters/linear_func.h +++ b/firmware/controllers/sensors/converters/linear_func.h @@ -10,7 +10,7 @@ public: SensorResult convert(float inputValue) const override; - void showInfo(Logging* logger, float testRawValue) const override; + void showInfo(float testRawValue) const override; float getDivideInput() const { return m_divideInput; diff --git a/firmware/controllers/sensors/converters/resistance_func.h b/firmware/controllers/sensors/converters/resistance_func.h index 4afef36994..812834c6bf 100644 --- a/firmware/controllers/sensors/converters/resistance_func.h +++ b/firmware/controllers/sensors/converters/resistance_func.h @@ -16,7 +16,7 @@ public: SensorResult convert(float inputValue) const override; - void showInfo(Logging* logger, float testInputValue) const override; + void showInfo(float testInputValue) const override; private: float m_supplyVoltage = 5.0f; diff --git a/firmware/controllers/sensors/converters/sensor_converter_func.h b/firmware/controllers/sensors/converters/sensor_converter_func.h index b2f25f9b7b..fa82b4308c 100644 --- a/firmware/controllers/sensors/converters/sensor_converter_func.h +++ b/firmware/controllers/sensors/converters/sensor_converter_func.h @@ -2,8 +2,6 @@ #include "sensor.h" -class Logging; - struct SensorConverter { // Trying to copy a converter func by value is almost guaranteed to be a bug - disallow it SensorConverter(const SensorConverter&) = delete; @@ -11,9 +9,8 @@ struct SensorConverter { SensorConverter() = default; virtual SensorResult convert(float raw) const = 0; - virtual void showInfo(Logging* logger, float testRawValue) const { + virtual void showInfo(float testRawValue) const { // Unused base - nothing to print - (void)logger; (void)testRawValue; } }; diff --git a/firmware/controllers/sensors/converters/table_func.h b/firmware/controllers/sensors/converters/table_func.h index 409cc4e814..44c1e5dadf 100644 --- a/firmware/controllers/sensors/converters/table_func.h +++ b/firmware/controllers/sensors/converters/table_func.h @@ -26,7 +26,7 @@ public: return interpolate2d(inputValue, m_bins, m_values) * TOutputScale::asFloat(); } - void showInfo(Logging* /*logger*/, float /*testInputValue*/) const override { } + void showInfo(float /*testInputValue*/) const override { } private: TBin (&m_bins)[TSize]; diff --git a/firmware/controllers/sensors/converters/thermistor_func.h b/firmware/controllers/sensors/converters/thermistor_func.h index 5e1a62972f..e6a6caefa5 100644 --- a/firmware/controllers/sensors/converters/thermistor_func.h +++ b/firmware/controllers/sensors/converters/thermistor_func.h @@ -16,7 +16,7 @@ public: void configure(thermistor_conf_s &cfg); - void showInfo(Logging* logger, float testRawValue) const override; + void showInfo(float testRawValue) const override; // Steinhart-Hart coefficients float m_a = 0; diff --git a/firmware/controllers/sensors/flex_sensor.h b/firmware/controllers/sensors/flex_sensor.h index be7379794c..2bc244b650 100644 --- a/firmware/controllers/sensors/flex_sensor.h +++ b/firmware/controllers/sensors/flex_sensor.h @@ -11,7 +11,7 @@ public: void onEdge(efitick_t nowNt); - void showInfo(Logging* /*logger*/, const char* /*sensorName*/) const override { } + void showInfo(const char* /*sensorName*/) const override { } private: Timer m_edgeTimer; diff --git a/firmware/controllers/sensors/function_pointer_sensor.h b/firmware/controllers/sensors/function_pointer_sensor.h index a79f032762..cfaddacdd6 100644 --- a/firmware/controllers/sensors/function_pointer_sensor.h +++ b/firmware/controllers/sensors/function_pointer_sensor.h @@ -33,7 +33,7 @@ public: return result; } - void showInfo(Logging* /*logger*/, const char* /*sensorName*/) const override {} + void showInfo(const char* /*sensorName*/) const override {} private: float (*m_func)(); diff --git a/firmware/controllers/sensors/functional_sensor.h b/firmware/controllers/sensors/functional_sensor.h index 0a51374b88..1879c687ab 100644 --- a/firmware/controllers/sensors/functional_sensor.h +++ b/firmware/controllers/sensors/functional_sensor.h @@ -38,7 +38,7 @@ public: return m_rawValue; } - void showInfo(Logging* logger, const char* sensorName) const override; + void showInfo(const char* sensorName) const override; private: // Conversion function for this sensor diff --git a/firmware/controllers/sensors/proxy_sensor.h b/firmware/controllers/sensors/proxy_sensor.h index 67251c4d91..7e660d89b1 100644 --- a/firmware/controllers/sensors/proxy_sensor.h +++ b/firmware/controllers/sensors/proxy_sensor.h @@ -21,7 +21,7 @@ public: m_proxiedSensor = proxiedSensor; } - void showInfo(Logging* logger, const char* sensorName) const override; + void showInfo(const char* sensorName) const override; private: SensorResult get() const override { diff --git a/firmware/controllers/sensors/redundant_ford_tps.h b/firmware/controllers/sensors/redundant_ford_tps.h index 0e3f2da361..560562ff74 100644 --- a/firmware/controllers/sensors/redundant_ford_tps.h +++ b/firmware/controllers/sensors/redundant_ford_tps.h @@ -19,7 +19,7 @@ public: return true; } - void showInfo(Logging* logger, const char* sensorName) const override; + void showInfo(const char* sensorName) const override; private: // The two sensors we interpret to form one redundant sensor diff --git a/firmware/controllers/sensors/redundant_sensor.h b/firmware/controllers/sensors/redundant_sensor.h index fa3b052564..770e8e0c36 100644 --- a/firmware/controllers/sensors/redundant_sensor.h +++ b/firmware/controllers/sensors/redundant_sensor.h @@ -20,7 +20,7 @@ public: return !m_ignoreSecond; } - void showInfo(Logging* logger, const char* sensorName) const override; + void showInfo(const char* sensorName) const override; private: // The two sensors we interpret to form one redundant sensor diff --git a/firmware/controllers/sensors/sensor.cpp b/firmware/controllers/sensors/sensor.cpp index 802fdda8af..9263720165 100644 --- a/firmware/controllers/sensors/sensor.cpp +++ b/firmware/controllers/sensors/sensor.cpp @@ -110,16 +110,16 @@ public: return unexpected; } - void showInfo(Logging* logger, const char* sensorName) const { + void showInfo(const char* sensorName) const { if (m_useMock) { - scheduleMsg(logger, "Sensor \"%s\" mocked with value %.2f", sensorName, m_mockValue); + efiPrintf("Sensor \"%s\" mocked with value %.2f", sensorName, m_mockValue); } else { const auto sensor = m_sensor; if (sensor) { - sensor->showInfo(logger, sensorName); + sensor->showInfo(sensorName); } else { - scheduleMsg(logger, "Sensor \"%s\" is not configured.", sensorName); + efiPrintf("Sensor \"%s\" is not configured.", sensorName); } } } @@ -258,20 +258,20 @@ bool Sensor::Register() { } // Print information about all sensors -/*static*/ void Sensor::showAllSensorInfo(Logging* logger) { +/*static*/ void Sensor::showAllSensorInfo() { for (size_t i = 1; i < efi::size(s_sensorRegistry); i++) { auto& entry = s_sensorRegistry[i]; const char* name = s_sensorNames[i]; - entry.showInfo(logger, name); + entry.showInfo(name); } } // Print information about a particular sensor -/*static*/ void Sensor::showInfo(Logging* logger, SensorType type) { +/*static*/ void Sensor::showInfo(SensorType type) { auto entry = getEntryForType(type); if (entry) { - entry->showInfo(logger, getSensorName(type)); + entry->showInfo(getSensorName(type)); } } diff --git a/firmware/controllers/sensors/sensor.h b/firmware/controllers/sensors/sensor.h index 396b58b0fd..5a5f5745d2 100644 --- a/firmware/controllers/sensors/sensor.h +++ b/firmware/controllers/sensors/sensor.h @@ -56,7 +56,6 @@ using SensorResult = expected; // Fwd declare - nobody outside of Sensor.cpp needs to see inside this type class SensorRegistryEntry; -class Logging; class Sensor { public: @@ -66,13 +65,13 @@ public: bool Register(); // Print information about this sensor - virtual void showInfo(Logging* logger, const char* sensorName) const = 0; + virtual void showInfo(const char* sensorName) const = 0; // Print information about all sensors - static void showAllSensorInfo(Logging* logger); + static void showAllSensorInfo(); // Print information about a particular sensor - static void showInfo(Logging* logger, SensorType type); + static void showInfo(SensorType type); // Remove all sensors from the sensor registry - tread carefully if you use this outside of a unit test static void resetRegistry(); diff --git a/firmware/controllers/sensors/sensor_info_printing.cpp b/firmware/controllers/sensors/sensor_info_printing.cpp index de5b304e72..e14f4a4076 100644 --- a/firmware/controllers/sensors/sensor_info_printing.cpp +++ b/firmware/controllers/sensors/sensor_info_printing.cpp @@ -11,39 +11,39 @@ #include "efilib.h" #include "loggingcentral.h" -void ProxySensor::showInfo(Logging* logger, const char* sensorName) const { - scheduleMsg(logger, "Sensor \"%s\" proxied from sensor \"%s\"", sensorName, getSensorName(m_proxiedSensor)); +void ProxySensor::showInfo(const char* sensorName) const { + efiPrintf("Sensor \"%s\" proxied from sensor \"%s\"", sensorName, getSensorName(m_proxiedSensor)); } -void FunctionalSensor::showInfo(Logging* logger, const char* sensorName) const { +void FunctionalSensor::showInfo(const char* sensorName) const { const auto [valid, value] = get(); - scheduleMsg(logger, "Sensor \"%s\": Raw value: %.2f Valid: %s Converted value %.2f", sensorName, m_rawValue, boolToString(valid), value); + efiPrintf("Sensor \"%s\": Raw value: %.2f Valid: %s Converted value %.2f", sensorName, m_rawValue, boolToString(valid), value); // now print out the underlying function's info if (auto func = m_function) { - func->showInfo(logger, m_rawValue); + func->showInfo(m_rawValue); } } #if EFI_CAN_SUPPORT #include "can_sensor.h" -void CanSensorBase::showInfo(Logging* logger, const char* sensorName) const { +void CanSensorBase::showInfo(const char* sensorName) const { const auto [valid, value] = get(); - scheduleMsg(logger, "CAN Sensor \"%s\": valid: %s value: %.2f", sensorName, boolToString(valid), value); + efiPrintf("CAN Sensor \"%s\": valid: %s value: %.2f", sensorName, boolToString(valid), value); } #endif // EFI_CAN_SUPPORT -void RedundantSensor::showInfo(Logging* logger, const char* sensorName) const { - scheduleMsg(logger, "Sensor \"%s\" is redundant combining \"%s\" and \"%s\"", sensorName, getSensorName(m_first), getSensorName(m_second)); +void RedundantSensor::showInfo(const char* sensorName) const { + efiPrintf("Sensor \"%s\" is redundant combining \"%s\" and \"%s\"", sensorName, getSensorName(m_first), getSensorName(m_second)); } -void RedundantFordTps::showInfo(Logging* logger, const char* sensorName) const { - scheduleMsg(logger, "Sensor \"%s\" is Ford-type redundant TPS combining \"%s\" and \"%s\"", sensorName, getSensorName(m_first), getSensorName(m_second)); +void RedundantFordTps::showInfo(const char* sensorName) const { + efiPrintf("Sensor \"%s\" is Ford-type redundant TPS combining \"%s\" and \"%s\"", sensorName, getSensorName(m_first), getSensorName(m_second)); } -void RpmCalculator::showInfo(Logging* logger, const char* /*sensorName*/) const { - scheduleMsg(logger, "RPM sensor: stopped: %d spinning up: %d cranking: %d running: %d rpm: %f", +void RpmCalculator::showInfo(const char* /*sensorName*/) const { + efiPrintf("RPM sensor: stopped: %d spinning up: %d cranking: %d running: %d rpm: %f", isStopped(), isSpinningUp(), isCranking(), @@ -52,22 +52,22 @@ void RpmCalculator::showInfo(Logging* logger, const char* /*sensorName*/) const ); } -void Lps25Sensor::showInfo(Logging* logger, const char* sensorName) const { - scheduleMsg(logger, "%s: LPS25 baro %.2f kPa", sensorName, get().Value); +void Lps25Sensor::showInfo(const char* sensorName) const { + efiPrintf("%s: LPS25 baro %.2f kPa", sensorName, get().Value); } -void LinearFunc::showInfo(Logging* logger, float testRawValue) const { - scheduleMsg(logger, " Linear function slope: %.2f offset: %.2f min: %.1f max: %.1f", m_a, m_b, m_minOutput, m_maxOutput); +void LinearFunc::showInfo(float testRawValue) const { + efiPrintf(" Linear function slope: %.2f offset: %.2f min: %.1f max: %.1f", m_a, m_b, m_minOutput, m_maxOutput); const auto [valid, value] = convert(testRawValue); - scheduleMsg(logger, " raw value %.2f converts to %.2f valid: %s", testRawValue, value, boolToString(valid)); + efiPrintf(" raw value %.2f converts to %.2f valid: %s", testRawValue, value, boolToString(valid)); } -void ResistanceFunc::showInfo(Logging* logger, float testInputValue) const { +void ResistanceFunc::showInfo(float testInputValue) const { const auto result = convert(testInputValue); - scheduleMsg(logger, " %.2f volts -> %.1f ohms with supply voltage %.2f and pullup %.1f.", testInputValue, result.Value, m_supplyVoltage, m_pullupResistor); + efiPrintf(" %.2f volts -> %.1f ohms with supply voltage %.2f and pullup %.1f.", testInputValue, result.Value, m_supplyVoltage, m_pullupResistor); } -void ThermistorFunc::showInfo(Logging* logger, float testInputValue) const { +void ThermistorFunc::showInfo(float testInputValue) const { const auto [valid, value] = convert(testInputValue); - scheduleMsg(logger, " %.1f ohms -> valid: %s. %.1f deg C", testInputValue, boolToString(valid), value); + efiPrintf(" %.1f ohms -> valid: %s. %.1f deg C", testInputValue, boolToString(valid), value); } diff --git a/firmware/controllers/serial/serial.h b/firmware/controllers/serial/serial.h index 159c68cd2f..3e1876adb9 100644 --- a/firmware/controllers/serial/serial.h +++ b/firmware/controllers/serial/serial.h @@ -18,8 +18,6 @@ constexpr uint8_t lc2_header_mask = 162; constexpr uint16_t lc2_pcklen_mask = 383; -class Logging; - typedef enum {UNKNOWN, HEADER_FOUND, IDENTIFIED} innovate_serial_id_state_t; extern uint8_t ser_buffer[SERBUFFLEN]; //buffer for incoming serial data diff --git a/firmware/controllers/settings.cpp b/firmware/controllers/settings.cpp index 6a8871f5f3..4a71127540 100644 --- a/firmware/controllers/settings.cpp +++ b/firmware/controllers/settings.cpp @@ -331,7 +331,7 @@ void printTPSInfo(void) { static void printTemperatureInfo(void) { #if EFI_ANALOG_SENSORS - Sensor::showAllSensorInfo(&logger); + Sensor::showAllSensorInfo(); scheduleMsg(&logger, "fan=%s @ %s", boolToString(enginePins.fanRelay.getLogicValue()), hwPortname(engineConfiguration->fanPin)); diff --git a/firmware/hw_layer/sensors/cj125.cpp b/firmware/hw_layer/sensors/cj125.cpp index 0beef080fe..07157d994c 100644 --- a/firmware/hw_layer/sensors/cj125.cpp +++ b/firmware/hw_layer/sensors/cj125.cpp @@ -490,7 +490,7 @@ static bool cj125periodic(CJ125 *instance DECLARE_ENGINE_PARAMETER_SUFFIX) { float duty = globalInstance.heaterPid.getOutput(globalInstance.vUr, globalInstance.vUrCal, MS2SEC(CJ125_TICK_DELAY)); instance->SetHeater(duty PASS_ENGINE_PARAMETER_SUFFIX); if (engineConfiguration->isCJ125Verbose) { - globalInstance.heaterPid.showPidStatus(logger, "cj heater"); + globalInstance.heaterPid.showPidStatus("cj heater"); cjPrintData(); } instance->prevNt = nowNt; diff --git a/firmware/init/init.h b/firmware/init/init.h index 7270195779..fd431bacf1 100644 --- a/firmware/init/init.h +++ b/firmware/init/init.h @@ -6,10 +6,8 @@ #include "engine_ptr.h" -class Logging; - // Call this once at startup to initialize, configure, and subscribe sensors -void initNewSensors(Logging* logger DECLARE_ENGINE_PARAMETER_SUFFIX); +void initNewSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE); // Call this whenever the configuration may have changed, so any sensors // can be reconfigured with the new settings. diff --git a/firmware/init/sensor/init_sensors.cpp b/firmware/init/sensor/init_sensors.cpp index 9e1a4edb7a..911fe0b572 100644 --- a/firmware/init/sensor/init_sensors.cpp +++ b/firmware/init/sensor/init_sensors.cpp @@ -6,9 +6,9 @@ #include "cli_registry.h" #include "sensor.h" -static void initSensorCli(Logging* logger); +static void initSensorCli(); -void initNewSensors(Logging* logger DECLARE_ENGINE_PARAMETER_SUFFIX) { +void initNewSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE) { #if EFI_CAN_SUPPORT initCanSensors(); #endif @@ -27,7 +27,7 @@ void initNewSensors(Logging* logger DECLARE_ENGINE_PARAMETER_SUFFIX) { #endif // Init CLI functionality for sensors (mocking) - initSensorCli(logger); + initSensorCli(); } void reconfigureSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE) { @@ -37,17 +37,13 @@ void reconfigureSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE) { reconfigureThermistors(PASS_CONFIG_PARAMETER_SIGNATURE); } -static Logging* s_logger; - // Mocking/testing helpers -static void initSensorCli(Logging* logger) { - s_logger = logger; - +static void initSensorCli() { addConsoleActionIF("set_sensor_mock", Sensor::setMockValue); addConsoleAction("reset_sensor_mocks", Sensor::resetAllMocks); - addConsoleAction("show_sensors", []() { Sensor::showAllSensorInfo(s_logger); }); - addConsoleActionI("show_sensor", + addConsoleAction("show_sensors", Sensor::showAllSensorInfo); + addConsoleActionI("show_sensor", [](int idx) { - Sensor::showInfo(s_logger, static_cast(idx)); + Sensor::showInfo(static_cast(idx)); }); } diff --git a/firmware/util/math/pid.cpp b/firmware/util/math/pid.cpp index 423c068f6e..1fb0f56a7a 100644 --- a/firmware/util/math/pid.cpp +++ b/firmware/util/math/pid.cpp @@ -157,8 +157,8 @@ void Pid::sleep() { #endif /* EFI_UNIT_TEST */ } -void Pid::showPidStatus(Logging *logging, const char*msg) const { - scheduleMsg(logging, "%s settings: offset=%f P=%.5f I=%.5f D=%.5f period=%dms", +void Pid::showPidStatus(const char*msg) const { + efiPrintf("%s settings: offset=%f P=%.5f I=%.5f D=%.5f period=%dms", msg, getOffset(), parameters->pFactor, @@ -166,7 +166,7 @@ void Pid::showPidStatus(Logging *logging, const char*msg) const { parameters->dFactor, parameters->periodMs); - scheduleMsg(logging, "%s status: value=%.2f input=%.2f/target=%.2f iTerm=%.5f dTerm=%.5f", + efiPrintf("%s status: value=%.2f input=%.2f/target=%.2f iTerm=%.5f dTerm=%.5f", msg, output, input, diff --git a/firmware/util/math/pid.h b/firmware/util/math/pid.h index 329208facd..f76cb9b31c 100644 --- a/firmware/util/math/pid.h +++ b/firmware/util/math/pid.h @@ -30,7 +30,6 @@ #define MS2SEC(x) (x * 0.001) struct pid_s; -class Logging; /** * default basic implementation also known as PidParallelController @@ -69,7 +68,7 @@ public: void postState(TunerStudioOutputChannels *tsOutputChannels) const; void postState(TunerStudioOutputChannels *tsOutputChannels, int pMult) const; #endif /* EFI_TUNER_STUDIO */ - void showPidStatus(Logging *logging, const char*msg) const; + void showPidStatus(const char* msg) const; void sleep(); int resetCounter; // todo: move this to pid_s one day diff --git a/unit_tests/tests/sensor/mock/mock_sensor.h b/unit_tests/tests/sensor/mock/mock_sensor.h index feff272acd..154ad65a36 100644 --- a/unit_tests/tests/sensor/mock/mock_sensor.h +++ b/unit_tests/tests/sensor/mock/mock_sensor.h @@ -25,7 +25,7 @@ struct MockSensor final : public StoredValueSensor m_hasSensor = h; } - void showInfo(Logging* logger, const char* name) const override {} + void showInfo(const char* name) const override {} private: bool m_hasSensor = true;