logging cleanup 2: sensors, pid, etb, etc (#2567)

* ts logger

* sensors

* wideband too

* missed one

* init

* motors, pid, etc

Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
This commit is contained in:
Matthew Kennedy 2021-04-18 17:02:32 -07:00 committed by GitHub
parent e3fcbdc7c0
commit 5145ee4b62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 103 additions and 120 deletions

View File

@ -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());
}

View File

@ -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);

View File

@ -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<percent_t> 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 */

View File

@ -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<percent_t> observePlant() const override;

View File

@ -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();

View File

@ -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);

View File

@ -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:

View File

@ -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);

View File

@ -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);

View File

@ -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:
/**

View File

@ -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;

View File

@ -26,7 +26,7 @@ public:
{
}
void showInfo(Logging* logger, const char* sensorName) const override;
void showInfo(const char* sensorName) const override;
};
template <typename TStorage, int TScale>

View File

@ -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<TGet>();
}
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<TGet>();
}
void showInfo(Logging* logger, float testInputValue) const override {
m_fs.showInfo(logger, testInputValue);
void showInfo(float testInputValue) const override {
m_fs.showInfo(testInputValue);
}
private:

View File

@ -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;

View File

@ -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;

View File

@ -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;
}
};

View File

@ -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];

View File

@ -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;

View File

@ -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;

View File

@ -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)();

View File

@ -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

View File

@ -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 {

View File

@ -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

View File

@ -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

View File

@ -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));
}
}

View File

@ -56,7 +56,6 @@ using SensorResult = expected<float>;
// 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();

View File

@ -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);
}

View File

@ -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

View File

@ -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));

View File

@ -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;

View File

@ -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.

View File

@ -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<SensorType>(idx));
Sensor::showInfo(static_cast<SensorType>(idx));
});
}

View File

@ -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,

View File

@ -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

View File

@ -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;