rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
status_loop.cpp
Go to the documentation of this file.
1/**
2 * @file status_loop.cpp
3 * @brief Human-readable protocol status messages
4 *
5 * http://rusefi.com/forum/viewtopic.php?t=263 rusEfi console overview
6 * http://rusefi.com/forum/viewtopic.php?t=210 Commands overview
7 *
8 *
9 * @date Mar 15, 2013
10 * @author Andrey Belomutskiy, (c) 2012-2020
11 *
12 * This file is part of rusEfi - see http://rusefi.com
13 *
14 * rusEfi is free software; you can redistribute it and/or modify it under the terms of
15 * the GNU General Public License as published by the Free Software Foundation; either
16 * version 3 of the License, or (at your option) any later version.
17 *
18 * rusEfi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
19 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License along with this program.
23 * If not, see <http://www.gnu.org/licenses/>.
24 *
25 */
26
27#include "pch.h"
28#include "status_loop.h"
29#include "electronic_throttle.h"
30
31#if EFI_LOGIC_ANALYZER
32#include "logic_analyzer.h"
33#endif /* EFI_LOGIC_ANALYZER */
34
35#include "trigger_central.h"
36#include "sensor_reader.h"
37#include "mmc_card.h"
38#include "console_io.h"
39#include "malfunction_central.h"
40#include "speed_density.h"
41
42#include "tunerstudio.h"
44#include "fuel_math.h"
46#include "spark_logic.h"
47#include "idle_thread.h"
48#include "can_hw.h"
50#include "cdm_ion_sense.h"
51#include "binary_mlg_logging.h"
52#include "buffered_writer.h"
53#include "dynoview.h"
54#include "frequency_sensor.h"
55#include "digital_input_exti.h"
56#include "dc_motors.h"
57
58#if EFI_PROD_CODE
59// todo: move this logic to algo folder!
60#include "rtc_helper.h"
61#include "rusefi.h"
62#include "pin_repository.h"
63#include "max3185x.h"
65#include "periodic_task.h"
66#endif /* EFI_PROD_CODE */
67
68#if EFI_CONFIGURATION_STORAGE
69#include "storage.h"
70#include "flash_main.h"
71#endif
72
73#if EFI_MAP_AVERAGING && defined (MODULE_MAP_AVERAGING)
74#include "map_averaging.h"
75#endif
76
77#if (BOARD_TLE8888_COUNT > 0)
78#include "tle8888.h"
79#endif /* BOARD_TLE8888_COUNT */
80
81#if EFI_ENGINE_SNIFFER
82#include "engine_sniffer.h"
83extern WaveChart waveChart;
84#endif /* EFI_ENGINE_SNIFFER */
85
86extern int maxTriggerReentrant;
87extern uint32_t maxLockedDuration;
88
89/**
90 * Time when the firmware version was last reported
91 * TODO: implement a request/response instead of just constantly sending this out
92 */
93static Timer printVersionTimer;
94
95// todo: unify with handleGetVersion?
96static void printVersionForConsole(const char *engineTypeName, const char *firmwareBuildId) {
97 // VersionChecker in rusEFI console is parsing these version string, please follow the expected format
98 efiPrintfProto(PROTOCOL_VERSION_TAG, "%d@%u %s %s %ld",
99 getRusEfiVersion(), /*do we have a working way to print 64 bit values?!*/(unsigned int)SIGNATURE_HASH,
100 firmwareBuildId,
101 engineTypeName,
102 (uint32_t)getTimeNowS());
103}
104
105#if EFI_PROD_CODE
106// Inform the console about the mapping between a pin's logical name (for example, injector 3)
107// and the physical MCU pin backing that function (for example, PE3)
108static void printOutPin(const char *pinName, brain_pin_e hwPin) {
109 if (hwPin == Gpio::Unassigned || hwPin == Gpio::Invalid) {
110 return;
111 }
112 const char *hwPinName;
113 if (isBrainPinValid(hwPin)) {
114 hwPinName = hwPortname(hwPin);
115 } else {
116 hwPinName = "smart";
117 }
118
119 efiPrintfProto(PROTOCOL_OUTPIN, "%s@%s", pinName, hwPinName);
120}
121#endif // EFI_PROD_CODE
122
123// Print out the current mapping between logical and physical pins that
124// the engine sniffer cares about, so we can display a physical pin
125// in each engine sniffer row
127#if EFI_PROD_CODE
130 for (int i = 0;i<CAM_INPUTS_COUNT;i++) {
131 extern const char *vvtNames[];
133 }
134
135 int cylCount = minI(engineConfiguration->cylindersCount, MAX_CYLINDER_COUNT);
136 for (int i = 0; i < cylCount; i++) {
141 }
142#endif /* EFI_PROD_CODE */
143}
144
146#if EFI_ENGINE_SNIFFER
148#endif /* EFI_ENGINE_SNIFFER */
149
150
151 /**
152 * we report the version every second - this way the console does not need to
153 * request it and we will display it pretty soon
154 */
155 if (printVersionTimer.hasElapsedSec(1)) {
156 // we're sending, reset the timer
157 printVersionTimer.reset();
158
159 // Output the firmware version, board type, git hash, uptime in seconds, etc for rusEFI console
161
162 // Output the current engine sniffer pin mappings
164 }
165}
166
167#if !defined(LOGIC_ANALYZER_BUFFER_SIZE)
168// TODO: how small can this be?
169#define LOGIC_ANALYZER_BUFFER_SIZE 1000
170#endif /* LOGIC_ANALYZER_BUFFER_SIZE */
171
172#if EFI_LOGIC_ANALYZER
173static char logicAnalyzerBuffer[LOGIC_ANALYZER_BUFFER_SIZE];
175#endif // EFI_LOGIC_ANALYZER
176
177/**
178 * @brief Sends all pending data to rusEfi console
179 *
180 * This method is periodically invoked by the main loop
181 * todo: is this mostly dead code?
182 */
184#if EFI_PROD_CODE
185 // todo: unify with simulator!
186 if (hasFirmwareError()) {
187 efiPrintf("%s error: %s", CRITICAL_PREFIX, getCriticalErrorMessage());
188 return;
189 }
190#endif /* EFI_PROD_CODE */
191
192#if EFI_RTC
194#endif
195
196#if HAL_USE_ADC
198#endif /* HAL_USE_ADC */
199
200#if EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT
201 int currentCkpEventCounter = engine->triggerCentral.triggerState.getTotalEventCounter();
202 systime_t nowSeconds = getTimeNowS();
203static int prevCkpEventCounter = -1;
204static systime_t timeOfPreviousReport = (systime_t) -1;
205 if (prevCkpEventCounter == currentCkpEventCounter && timeOfPreviousReport == nowSeconds) {
206 return;
207 }
208 timeOfPreviousReport = nowSeconds;
209
210 prevCkpEventCounter = currentCkpEventCounter;
211#else
212 chThdSleepMilliseconds(200);
213#endif
214
215#if EFI_LOGIC_ANALYZER
218#endif /* EFI_LOGIC_ANALYZER */
219}
220
221#if EFI_PROD_CODE
224#endif // EFI_PROD_CODE
225
227#if EFI_PROD_CODE
228 // open question if we need warningLedPin and runningLedPin at all!
229 enginePins.warningLedPin.initPin("led: warning status", getWarningLedPin(), LED_PIN_MODE, true);
230 enginePins.runningLedPin.initPin("led: running status", getRunningLedPin(), LED_PIN_MODE, true);
231#endif /* EFI_PROD_CODE */
232}
233
234#if EFI_PROD_CODE
235static void initStatusLeds() {
236 enginePins.communicationLedPin.initPin("led: comm status", getCommsLedPin(), LED_PIN_MODE, true);
237 // checkEnginePin is already initialized by the time we get here
238}
239
240static bool isTriggerErrorNow() {
241#if EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT
243 return justHadError || engine->triggerCentral.isTriggerDecoderError();
244#else
245 return false;
246#endif /* EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT */
247}
248
249extern bool consoleByteArrived;
250
251class CommunicationBlinkingTask : public PeriodicTimerController {
252
253 int getPeriodMs() override {
254 return counter % 2 == 0 ? onTimeMs : offTimeMs;
255 }
256
257 void setAllLeds(int value) {
258 // make sure we do not turn the critical LED off if already have
259 // critical error by now
260 for (size_t i = 0; !hasFirmwareError() && i < efi::size(leds); i++) {
261 leds[i]->setValue(value, /*force*/true);
262 }
263 }
264
265 void PeriodicTask() override {
266 counter++;
267
268 if (counter == 1) {
269 // first invocation of BlinkingTask
270 setAllLeds(1);
271 } else if (counter == 2) {
272 // second invocation of BlinkingTask
273 setAllLeds(0);
274 } else if (counter % 2 == 0) {
275 enginePins.communicationLedPin.setValue(0, /*force*/true);
276
277#if EFI_FILE_LOGGING
278 extern bool needErrorReportFile;
279#else
280#define needErrorReportFile false
281#endif // EFI_FILE_LOGGING
282 // todo: properly encapsulate warning LED logic!
283 if (!needErrorReportFile) {
285 }
286 } else {
287#define BLINKING_PERIOD_MS 33
288
289 if (hasFirmwareError()) {
290 // special behavior in case of critical error - not equal on/off time
291 // this special behavior helps to notice that something is not right, also
292 // differentiates software firmware error from critical interrupt error with CPU halt.
293 offTimeMs = 50;
294 onTimeMs = 450;
295 } else if (consoleByteArrived) {
296 offTimeMs = 100;
297 onTimeMs = 33;
298#if EFI_CONFIGURATION_STORAGE
299 } else if (getNeedToWriteConfiguration()) {
300 offTimeMs = onTimeMs = 500;
301#endif /* EFI_CONFIGURATION_STORAGE */
302 } else {
303 onTimeMs =
304#if EFI_USB_SERIAL
305 is_usb_serial_ready() ? 3 * BLINKING_PERIOD_MS :
306#endif // EFI_USB_SERIAL
307 BLINKING_PERIOD_MS;
308 offTimeMs = 0.6 * onTimeMs;
309 }
310
311 enginePins.communicationLedPin.setValue(1, /*force*/true);
312
313 #if EFI_ENGINE_CONTROL
314 if (isTriggerErrorNow()) {
315 // todo: at the moment warning codes do not affect warning LED?!
317 }
318 #endif /* EFI_ENGINE_CONTROL */
319 }
320 }
321
322private:
323 int counter = 0;
324 int onTimeMs = 100;
325 int offTimeMs = 100;
326};
327
328static CommunicationBlinkingTask communicationsBlinkingTask;
329
330#endif /* EFI_PROD_CODE */
331
332
333#if EFI_TUNER_STUDIO
334
335/**
336 * This is useful if we are changing engine mode dynamically
337 * For example http://rusefi.com/forum/viewtopic.php?f=5&t=1085
338 */
339static int packEngineMode() {
340 return (Enum2Underlying(engineConfiguration->fuelAlgorithm) << 4) +
343}
344
373
375
376static void updateThrottles() {
378 engine->outputChannels.TPSValue = tps1.value_or(0);
381
383 engine->outputChannels.TPS2Value = tps2.value_or(0);
384 // If we don't have a TPS2 at all, don't turn on the failure light
386
389 // Only report fail if you have one (many people don't)
391
392 // TPS 1 pri/sec split
394 // TPS 2 pri/sec split
396 // TPS1 - TPS2 split
398 // Pedal pri/sec split
400
403}
404
420
431
442
443static void updateVvtSensors() {
444#if EFI_SHAFT_POSITION_INPUT
445 // 248
446 engine->outputChannels.vvtPositionB1I = engine->triggerCentral.getVVTPosition(/*bankIndex*/0, /*camIndex*/0);
447 engine->outputChannels.vvtPositionB1E = engine->triggerCentral.getVVTPosition(/*bankIndex*/0, /*camIndex*/1);
448 engine->outputChannels.vvtPositionB2I = engine->triggerCentral.getVVTPosition(/*bankIndex*/1, /*camIndex*/0);
449 engine->outputChannels.vvtPositionB2E = engine->triggerCentral.getVVTPosition(/*bankIndex*/1, /*camIndex*/1);
450#endif
451}
452
463
474
475static void updateRawSensors() {
502
503#if EFI_PROD_CODE
504extern int flexCallbackCounter;
506#endif // EFI_PROD_CODE
507
508 for (size_t i = 0;i<LUA_GAUGE_COUNT;i++) {
510 }
511
512 for (int i = 0; i < LUA_ANALOG_INPUT_COUNT; i++) {
515 engine->outputChannels.rawAnalogInput[i] = adcGetScaledVoltage("raw aux", channel).value_or(0);
516 }
517 }
518
519 // TODO: transition AFR to new sensor model
521}
541
558
571
575
576static void updateFuelResults() {
577#if EFI_VEHICLE_SPEED && defined (MODULE_ODOMETER)
578 engine->outputChannels.fuelFlowRate = engine->module<TripOdometer>()->getConsumptionGramPerSecond();
580 engine->outputChannels.ignitionOnTime = engine->module<TripOdometer>()->getIgnitionOnTime();
581 engine->outputChannels.engineRunTime = engine->module<TripOdometer>()->getEngineRunTime();
582
583 // output channel in km
584 engine->outputChannels.distanceTraveled = 0.001f * engine->module<TripOdometer>()->getDistanceMeters();
585#endif // EFI_VEHICLE_SPEED MODULE_ODOMETER
586}
587
588static void updateFuelInfo() {
591#if EFI_ENGINE_CONTROL
593 engine->outputChannels.wallFuelAmount = wallFuel.getWallFuel() * 1000; // Convert grams to mg
594 engine->outputChannels.wallFuelCorrectionValue = wallFuel.wallFuelCorrection * 1000; // Convert grams to mg
595
597#endif // EFI_ENGINE_CONTROL
598}
599
600static void updateIgnition(float rpm) {
601#if EFI_ENGINE_CONTROL
603#endif // EFI_ENGINE_CONTROL
604}
605
606static void updateFlags() {
608 // todo: eliminate state copy logic by giving DfcoController it's owm xxx.txt and leveraging LiveData
610
611#if EFI_LAUNCH_CONTROL
613#endif
614
615#if EFI_PROD_CODE
617#endif // EFI_PROD_CODE
618
619#if EFI_CONFIGURATION_STORAGE
621#endif /* EFI_CONFIGURATION_STORAGE */
622#if EFI_FILE_LOGGING
624#endif
625}
626
627// sensor state for EFI Analytics Tuner Studio
628// todo: the 'let's copy internal state for external consumers' approach is DEPRECATED
629// As of 2022 it's preferred to leverage LiveData where all state is exposed
630// this method is invoked ONLY if we SD card log or have serial connection with some frontend app
632 TunerStudioOutputChannels *tsOutputChannels = &engine->outputChannels;
633#if EFI_USB_SERIAL
634 // pretty much SD card logs know if specifically USB serial is active
636#endif // EFI_USB_SERIAL
637
638 float rpm = Sensor::get(SensorType::Rpm).value_or(0);
639
640
641 static Timer blinkIndicatorsTimer;
642 constexpr float blinkHalfPeriod = 0.3;
643 bool isBlinkPhase = blinkIndicatorsTimer.hasElapsedSec(blinkHalfPeriod);
644#if EFI_ELECTRONIC_THROTTLE_BODY
645 blinkEtbErrorCodes(isBlinkPhase);
646#endif // EFI_ELECTRONIC_THROTTLE_BODY
647 if (isBlinkPhase) {
650
651 if (blinkIndicatorsTimer.hasElapsedSec(2 * blinkHalfPeriod)) {
652 blinkIndicatorsTimer.reset();
653 }
654 } else {
657 }
658
659
660#if EFI_PROD_CODE
662#endif /* EFI_PROD_CODE */
663
666 engine->dc_motors.isEnabled0_int = dc->msg() == nullptr;
667
668 tsOutputChannels->RPMValue = rpm;
669#if EFI_SHAFT_POSITION_INPUT
673
675#endif // EFI_SHAFT_POSITION_INPUT
676
679 updateIgnition(rpm);
680 updateFlags();
681 // update calibration channel, reset to None state after timeout
683
684 // Output both the estimated air flow, and measured air flow (if available)
685 tsOutputChannels->mafMeasured = Sensor::getOrZero(SensorType::Maf);
687 tsOutputChannels->mafEstimate = engine->engineState.airflowEstimate;
688
689#if EFI_ENGINE_CONTROL
690 tsOutputChannels->injectorDutyCycle = minF(/*let's avoid scaled "uint8_t, 2" overflow*/127, getInjectorDutyCycle(rpm));
692#endif
693
694 tsOutputChannels->seconds = getTimeNowS();
695
696 tsOutputChannels->engineMode = packEngineMode();
697 tsOutputChannels->firmwareVersion = getRusEfiVersion();
698
699 tsOutputChannels->accelerationLat = engine->sensors.accelerometer.lat;
700 tsOutputChannels->accelerationLon = engine->sensors.accelerometer.lon;
701 tsOutputChannels->accelerationVert = engine->sensors.accelerometer.vert;
702 tsOutputChannels->gyroYaw = engine->sensors.accelerometer.yawRate;
703
704#if EFI_DYNO_VIEW
705 tsOutputChannels->hp = getDynoviewHP();
706 tsOutputChannels->torque = getDynoviewTorque();
707#else
708 tsOutputChannels->hp = -1;
709 tsOutputChannels->torque = -1;
710#endif
711
717
718 tsOutputChannels->hasCriticalError = hasFirmwareError() || hasConfigError() || engine->engineState.warnings.hasWarningMessage();
719 tsOutputChannels->hasFaultReportFile = hasErrorReportFile();
721
722 tsOutputChannels->isWarnNow = engine->engineState.warnings.isWarningNow();
723
724 tsOutputChannels->tpsAccelFuel = engine->engineState.tpsAccelEnrich;
725
726 tsOutputChannels->checkEngine = hasErrorCodes();
727
729
732
733
735
736#if EFI_CLOCK_LOCKS
737 tsOutputChannels->maxLockedDuration = NT2US(maxLockedDuration);
738#endif /* EFI_CLOCK_LOCKS */
739
740#if EFI_SHAFT_POSITION_INPUT
741 tsOutputChannels->maxTriggerReentrant = maxTriggerReentrant;
744
747
748#endif // EFI_SHAFT_POSITION_INPUT
749
750#if HAL_USE_PAL && EFI_PROD_CODE
751 tsOutputChannels->extiOverflowCount = getExtiOverflowCounter();
752#endif
753
755 case DBG_LOGIC_ANALYZER:
756#if EFI_LOGIC_ANALYZER
757 // used by HW CI
759#endif /* EFI_LOGIC_ANALYZER */
760 break;
761 default:
762 ;
763 }
764}
765
766#endif /* EFI_TUNER_STUDIO */
767
769 // todo: refactoring needed, this file should probably be split into pieces
770#if EFI_PROD_CODE
773#endif /* EFI_PROD_CODE */
774}
expected< float > adcGetScaledVoltage(const char *msg, adc_channel_e hwChannel)
void printFullAdcReportIfNeeded(void)
bool isAdcChannelValid(adc_channel_e hwChannel)
Definition adc_inputs.h:23
uint16_t channel
Definition adc_inputs.h:104
float getMCUInternalTemperature(void)
float getMCUVref(void)
Gpio getWarningLedPin()
Gpio getCommsLedPin()
Gpio getRunningLedPin()
const char * getEngine_type_e(engine_type_e value)
const char * msg()
Definition dc_motors.h:70
TwoPinDcMotor dcMotor
Definition dc_motors.h:63
FuelComputer fuelComputer
Definition engine.h:139
TriggerCentral triggerCentral
Definition engine.h:318
dc_motors_s dc_motors
Definition engine.h:346
FuelSchedule injectionEvents
Definition engine.h:288
LaunchControlBase launchController
Definition engine.h:220
EngineState engineState
Definition engine.h:344
RpmCalculator rpmCalculator
Definition engine.h:306
TunerStudioOutputChannels outputChannels
Definition engine.h:109
constexpr auto & module()
Definition engine.h:200
SensorsState sensors
Definition engine.h:353
InjectorOutputPin injectorsStage2[MAX_CYLINDER_COUNT]
Definition efi_gpio.h:128
OutputPin o2heater
Definition efi_gpio.h:99
IgnitionOutputPin trailingCoils[MAX_CYLINDER_COUNT]
Definition efi_gpio.h:130
OutputPin errorLedPin
Definition efi_gpio.h:105
RegisteredOutputPin starterControl
Definition efi_gpio.h:82
OutputPin runningLedPin
Definition efi_gpio.h:108
InjectorOutputPin injectors[MAX_CYLINDER_COUNT]
Definition efi_gpio.h:127
RegisteredOutputPin starterRelayDisable
Definition efi_gpio.h:84
OutputPin communicationLedPin
Definition efi_gpio.h:106
OutputPin warningLedPin
Definition efi_gpio.h:107
IgnitionOutputPin coils[MAX_CYLINDER_COUNT]
Definition efi_gpio.h:129
RegisteredOutputPin checkEnginePin
Definition efi_gpio.h:118
floatms_t tpsAccelEnrich
float airflowEstimate
WarningCodeState warnings
InjectionEvent elements[MAX_CYLINDER_COUNT]
WallFuel & getWallFuel()
const char * getShortName() const
Definition efi_gpio.cpp:430
Single output pin reference and state.
Definition efi_output.h:49
void initPin(const char *msg, brain_pin_e brainPin, pin_output_mode_e outputMode, bool forceInitWithFatalError=false)
Definition efi_gpio.cpp:711
bool getLogicValue() const
Definition efi_gpio.cpp:667
void setValue(const char *msg, int logicValue, bool isForce=false)
Definition efi_gpio.cpp:604
virtual int getPeriodMs()=0
virtual void PeriodicTask()=0
float getRpmAcceleration() const
uint32_t getRevolutionCounterSinceStart(void) const
virtual bool hasSensor() const
Definition sensor.h:141
virtual SensorResult get() const =0
virtual float getRaw() const
Definition sensor.h:148
static float getOrZero(SensorType type)
Definition sensor.h:83
InstantRpmCalculator instantRpm
PrimaryTriggerDecoder triggerState
angle_t getVVTPosition(uint8_t bankIndex, uint8_t camIndex)
int getHwEventCounter(int index) const
int64_t getTotalEventCounter() const
bool someSortOfTriggerError() const
uint32_t totalTriggerErrorCounter
float get() const override
Get the current motor duty cycle.
Definition dc_motor.cpp:48
bool hasWarningMessage()
Definition engine2.cpp:102
bool isWarningNow() const
Definition engine2.cpp:114
rusEfi console sniffer data buffer
void publishIfFull()
@ Unassigned
@ Invalid
bool is_usb_serial_ready()
DcHardware * getPrimaryDCHardwareForLogging()
Definition dc_motors.cpp:86
uint8_t getExtiOverflowCounter()
int getDynoviewHP()
Definition dynoview.cpp:164
int getDynoviewTorque()
Definition dynoview.cpp:168
EnginePins enginePins
Definition efi_gpio.cpp:24
const char * vvtNames[]
Definition efi_gpio.cpp:34
efitimesec_t getTimeNowS()
Current system time in seconds (32 bits)
Definition efitime.cpp:42
void blinkEtbErrorCodes(bool blinkPhase)
static EngineAccessor engine
Definition engine.h:413
static constexpr engine_configuration_s * engineConfiguration
rusEfi console wave sniffer
bool needErrorReportFile
const char * getCriticalErrorMessage()
bool hasConfigError()
bool hasErrorReportFile()
int getRusEfiVersion()
percent_t getInjectorDutyCycleStage2(float rpm)
percent_t getInjectorDutyCycle(float rpm)
Idle Valve Control thread.
int flexCallbackCounter
Definition init_flex.cpp:19
FrequencySensor inputShaftSpeedSensor(SensorType::InputShaftSpeed, MS2NT(500))
static CCM_OPTIONAL FunctionalSensor iat(SensorType::Iat, MS2NT(10))
static CCM_OPTIONAL FunctionalSensor clt(SensorType::Clt, MS2NT(10))
static RedundantPair pedal(pedalPrimary, pedalSecondary, SensorType::AcceleratorPedalUnfiltered)
static RedundantPair tps2(tps2p, tps2s, SensorType::Tps2)
FrequencySensor vehicleSpeedSensor(SensorType::VehicleSpeed, MS2NT(500))
void scheduleLogging(Logging *logging)
void printWave(Logging *logging)
void reportLogicAnalyzerToTS()
bool ltftNeedVeRefresh()
Main logic header.
bool hasErrorCodes(void)
This data structure holds current malfunction codes.
void updateSdCardLiveFlags()
const char * hwPortname(brain_pin_e brainPin)
bool isBrainPinValid(brain_pin_e brainPin)
I/O pin registry header.
uint32_t getEpochTime()
Real Time Clock helper.
expected< float > SensorResult
Definition sensor.h:46
Declaration for SensorReader, the class used to acquire readings from a sensor.
SensorType
Definition sensor_type.h:18
@ FuelEthanolPercent
@ ThrottleInletPressure
@ AmbientTemperature
@ CompressorDischargePressure
@ AcceleratorPedalPrimary
@ CompressorDischargeTemperature
@ AcceleratorPedalSecondary
@ AcceleratorPedalUnfiltered
@ BarometricPressure
auxTemp1("auxTemp1", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 18, 0.01, 0.0, 0.0, "deg C")
ambientTemp("ambientTemp", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 748, 0.01, 0.0, 0.0, "deg C")
fuelTemp("fuelTemp", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 746, 0.01, 0.0, 0.0, "deg C")
wallFuel("Fuel on the wall\nin ms of injector open time for each injector.", SensorCategory.SENSOR_INPUTS, FieldType.INT, 1744, 1.0, -1.0, -1.0, "")
oilTemp("oilTemp", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 744, 0.01, 0.0, 0.0, "deg C")
compressorDischargeTemp("compressorDischargeTemp", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 750, 0.01, 0.0, 0.0, "deg C")
lambdaValue("Lambda", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 36, 1.0E-4, 0.0, 0.0, "")
auxTemp2("auxTemp2", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 20, 0.01, 0.0, 0.0, "deg C")
void executorStatistics()
percent_t getCoilDutyCycle(float rpm)
@ SHAFT_SECONDARY_RISING
@ SHAFT_SECONDARY_FALLING
@ SHAFT_PRIMARY_FALLING
@ SHAFT_PRIMARY_RISING
static void updateTempSensors()
static void updateLambda()
void updateUnfilteredRawPedal()
Definition init_tps.cpp:194
static void initStatusLeds()
static void updateVehicleSpeed()
void printOverallStatus()
static void updateFlags()
void updateDevConsoleState()
Sends all pending data to rusEfi console.
static void updateFuelCorrections()
static SensorType luaGaugeTypes[]
static void updateVvtSensors()
static OutputPin * leds[]
static void printEngineSnifferPinMappings()
uint32_t maxLockedDuration
static void updateFuelInfo()
static void printVersionForConsole(const char *engineTypeName, const char *firmwareBuildId)
void updateTunerStudioState()
static void updateIgnition(float rpm)
static void updateFuelSensors()
static int packEngineMode()
static void updateFuelResults()
static void updateEgtSensors()
int maxTriggerReentrant
void startStatusThreads()
static bool isTriggerErrorNow()
void initWarningRunningPins()
static char logicAnalyzerBuffer[LOGIC_ANALYZER_BUFFER_SIZE]
static void updateMiscSensors()
static Logging logicAnalyzerLogger("logic analyzer", logicAnalyzerBuffer, sizeof(logicAnalyzerBuffer))
static void printOutPin(const char *pinName, brain_pin_e hwPin)
bool consoleByteArrived
static CommunicationBlinkingTask communicationsBlinkingTask
static void updatePressures()
static Timer printVersionTimer
static void updateThrottles()
static void updateRawSensors()
static void updateSensors()
WaveChart waveChart
bool getNeedToWriteConfiguration()
Definition storage.cpp:353
Accelerometer accelerometer
brain_input_pin_e triggerInputPins[TRIGGER_INPUT_PIN_COUNT]
float stftCorrection[FT_BANK_COUNT]
scaled_channel< uint16_t, 1000, 1 > stoichiometricRatio
scaled_channel< uint16_t, 1000, 1 > afrGasolineScale
scaled_channel< int16_t, 100, 1 > compressorDischargeTemp
scaled_channel< int16_t, 1000, 1 > rawBattery
float luaGauges[LUA_GAUGE_COUNT]
scaled_channel< uint16_t, 30, 1 > throttleInletPressure
scaled_channel< int16_t, 100, 1 > auxTemp2
scaled_channel< uint16_t, 100, 1 > speedToRpmRatio
scaled_channel< uint16_t, 100, 1 > coilDutyCycle
scaled_channel< int16_t, 1000, 1 > accelerationLat
scaled_channel< int16_t, 100, 1 > accPedalUnfiltered
scaled_channel< int16_t, 100, 1 > idlePositionSensor
scaled_channel< int16_t, 100, 1 > wastegatePositionSensor
scaled_channel< int16_t, 1000, 1 > accelerationVert
scaled_channel< uint16_t, 100, 1 > vehicleSpeedKph
scaled_channel< int16_t, 1000, 1 > rawAuxAnalog4
scaled_channel< int16_t, 10, 1 > highFuelPressure
scaled_channel< int16_t, 1000, 1 > rawTps2Secondary
scaled_channel< int16_t, 1000, 1 > rawTps1Secondary
scaled_channel< int16_t, 100, 1 > TPS2Value
scaled_channel< uint16_t, 10, 1 > mafEstimate
scaled_channel< int16_t, 1000, 1 > rawAuxAnalog1
scaled_channel< uint16_t, 10000, 1 > lambdaValue
scaled_channel< int16_t, 1000, 1 > rawHighFuelPressure
scaled_channel< uint16_t, 1000, 1 > rawMaf
scaled_channel< int16_t, 100, 1 > ambientTemp
scaled_channel< uint16_t, 30, 1 > oilPressure
scaled_channel< int16_t, 1000, 1 > rawTps1Primary
scaled_channel< int16_t, 1000, 1 > rawOilPressure
scaled_channel< uint16_t, 30, 1 > baroPressure
scaled_channel< uint16_t, 1000, 1 > afr2GasolineScale
scaled_channel< uint8_t, 2, 1 > injectorDutyCycle
scaled_channel< int16_t, 100, 1 > tps12Split
scaled_channel< int16_t, 1000, 1 > rawWastegatePosition
scaled_channel< int16_t, 1000, 1 > rawAuxTemp1
scaled_channel< uint16_t, 10, 1 > veValue
scaled_channel< uint16_t, 1000, 1 > VBatt
scaled_channel< int16_t, 100, 1 > fuelTankLevel
scaled_channel< int16_t, 4, 1 > egt[EGT_CHANNEL_COUNT]
scaled_channel< int16_t, 50, 1 > vvtPositionB1E
scaled_channel< int16_t, 1000, 1 > accelerationLon
scaled_channel< int16_t, 1000, 1 > rawIat
scaled_channel< int16_t, 1000, 1 > internalVref
scaled_channel< uint16_t, 1000, 1 > AFRValue2
scaled_channel< int16_t, 100, 1 > accPedalSplit
scaled_channel< int16_t, 100, 1 > fuelTemp
scaled_channel< int16_t, 100, 1 > wallFuelCorrectionValue
scaled_channel< uint16_t, 30, 1 > compressorDischargePressure
scaled_channel< int16_t, 1000, 1 > rawAuxTemp2
scaled_channel< int16_t, 1000, 1 > rawLowFuelPressure
scaled_channel< int16_t, 300, 1 > tpsAccelFuel
scaled_channel< uint16_t, 1000, 1 > rawMap
scaled_channel< uint16_t, 1000, 1 > AFRValue
scaled_channel< uint16_t, 100, 1 > Gego
scaled_channel< int16_t, 30, 1 > lowFuelPressure
scaled_channel< int16_t, 1000, 1 > rawClt
scaled_channel< uint16_t, 30, 1 > MAPValue
scaled_channel< uint16_t, 1000, 1 > SmoothedAFRValue2
scaled_channel< int16_t, 100, 1 > intake
scaled_channel< int16_t, 1000, 1 > gyroYaw
scaled_channel< int16_t, 1000, 1 > rawAuxAnalog3
scaled_channel< int16_t, 50, 1 > vvtPositionB2E
scaled_channel< int16_t, 1000, 1 > rawAmbientTemp
scaled_channel< uint16_t, 1000, 1 > SmoothedAFRValue
scaled_channel< int16_t, 100, 1 > tps1Split
scaled_channel< uint16_t, 100, 1 > wallFuelAmount
scaled_channel< int16_t, 1000, 1 > rawFuelLevel
scaled_channel< uint8_t, 2, 1 > flexPercent
scaled_channel< uint16_t, 1000, 1 > rawMaf2
scaled_channel< int16_t, 100, 1 > oilTemp
scaled_channel< uint16_t, 10, 1 > distanceTraveled
scaled_channel< int16_t, 100, 1 > throttlePedalPosition
scaled_channel< uint16_t, 10, 1 > mafMeasured2
scaled_channel< int16_t, 100, 1 > tps2Split
scaled_channel< uint16_t, 10, 1 > mafMeasured
scaled_channel< uint16_t, 200, 1 > fuelFlowRate
scaled_channel< uint8_t, 2, 1 > injectorDutyCycleStage2
scaled_channel< uint16_t, 1000, 1 > rawAfr
scaled_channel< uint16_t, 10000, 1 > lambdaValue2
scaled_channel< int16_t, 1000, 1 > rawIdlePositionSensor
scaled_channel< int16_t, 100, 1 > coolant
scaled_channel< int16_t, 50, 1 > vvtPositionB2I
scaled_channel< int16_t, 50, 1 > vvtPositionB1I
scaled_channel< int16_t, 100, 1 > TPSValue
scaled_channel< int16_t, 1000, 1 > rawTps2Primary
scaled_channel< int16_t, 1000, 1 > rawAcPressure
scaled_channel< int16_t, 100, 1 > auxTemp1
scaled_channel< int16_t, 1000, 1 > rawAnalogInput[LUA_ANALOG_INPUT_COUNT]
scaled_channel< int16_t, 1000, 1 > rawAuxAnalog2
float getThrottlePressureRatio(float map)
constexpr int convertVoltageTo10bitADC(float voltage)
Definition tps.h:21
bool needToTriggerTsRefresh()
maintainConstantValue implementation header