2017-03-24 10:41:36 -07:00
|
|
|
/**
|
|
|
|
* @file engine_sniffer.h
|
2019-05-02 14:52:48 -07:00
|
|
|
* @brief rusEfi console wave sniffer
|
2017-03-24 10:41:36 -07:00
|
|
|
*
|
|
|
|
* @date Jun 23, 2013
|
2020-01-13 18:57:43 -08:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2020
|
2017-03-24 10:41:36 -07:00
|
|
|
*/
|
|
|
|
|
2020-04-01 16:00:56 -07:00
|
|
|
#pragma once
|
2017-03-24 10:41:36 -07:00
|
|
|
|
2022-09-10 20:33:37 -07:00
|
|
|
#include "rusefi_enums.h"
|
2017-03-24 10:41:36 -07:00
|
|
|
|
|
|
|
#include "datalogging.h"
|
|
|
|
|
2022-09-10 20:33:37 -07:00
|
|
|
enum class FrontDirection : uint8_t {
|
|
|
|
UP,
|
|
|
|
DOWN
|
|
|
|
};
|
|
|
|
|
2022-09-10 17:25:13 -07:00
|
|
|
void addEngineSnifferTdcEvent(int rpm);
|
2022-09-10 20:33:37 -07:00
|
|
|
void addEngineSnifferLogicAnalyzerEvent(int laIndex, FrontDirection frontDirection);
|
|
|
|
/**
|
|
|
|
* @param wheelIndex 0 or 1
|
|
|
|
* @triggerEventIndex index from sync point, from 0 to number of teeth in engine cycle
|
|
|
|
*/
|
|
|
|
void addEngineSnifferCrankEvent(int wheelIndex, int triggerEventIndex, FrontDirection frontDirection);
|
|
|
|
void addEngineSnifferVvtEvent(int vvtIndex, FrontDirection frontDirection);
|
2022-10-29 18:27:49 -07:00
|
|
|
void addEngineSnifferOutputPinEvent(NamedOutputPin *pin, FrontDirection frontDirection);
|
2022-09-10 17:25:13 -07:00
|
|
|
|
2022-09-10 21:18:08 -07:00
|
|
|
#if EFI_ENGINE_SNIFFER
|
|
|
|
|
2017-03-24 10:41:36 -07:00
|
|
|
/**
|
2019-05-02 14:52:48 -07:00
|
|
|
* @brief rusEfi console sniffer data buffer
|
2017-03-24 10:41:36 -07:00
|
|
|
*/
|
2021-11-16 13:52:11 -08:00
|
|
|
class WaveChart {
|
2017-03-24 10:41:36 -07:00
|
|
|
public:
|
|
|
|
WaveChart();
|
|
|
|
void init();
|
|
|
|
void addEvent3(const char *name, const char *msg);
|
|
|
|
void reset();
|
2019-05-02 15:42:59 -07:00
|
|
|
void startDataCollection();
|
2017-03-24 10:41:36 -07:00
|
|
|
void publishIfFull();
|
|
|
|
void publish();
|
2019-06-08 06:51:36 -07:00
|
|
|
bool isFull() const;
|
|
|
|
bool isStartedTooLongAgo() const;
|
2020-05-25 20:38:15 -07:00
|
|
|
// looks like this is only used by functional tests on real hardware
|
2019-12-21 20:27:54 -08:00
|
|
|
efitick_t pauseEngineSnifferUntilNt = 0;
|
2021-04-04 19:48:48 -07:00
|
|
|
int getSize();
|
2019-12-21 20:27:54 -08:00
|
|
|
|
2017-03-24 10:41:36 -07:00
|
|
|
private:
|
|
|
|
Logging logging;
|
2019-09-22 22:55:23 -07:00
|
|
|
char timeBuffer[_MAX_FILLER + 2];
|
2022-06-17 19:10:34 -07:00
|
|
|
// current number of events in buffer, see getSize()
|
2019-05-02 15:42:59 -07:00
|
|
|
uint32_t counter = 0;
|
|
|
|
/**
|
|
|
|
* We want to avoid visual jitter thus we want the left edge to be aligned
|
|
|
|
* https://github.com/rusefi/rusefi/issues/780
|
|
|
|
*/
|
|
|
|
bool collectingData = false;
|
2019-12-21 18:11:09 -08:00
|
|
|
efitick_t startTimeNt = 0;
|
2019-05-02 15:42:59 -07:00
|
|
|
volatile int isInitialized = false;
|
2017-03-24 10:41:36 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
void initWaveChart(WaveChart *chart);
|
|
|
|
void setChartSize(int newSize);
|
|
|
|
|
|
|
|
#endif /* EFI_ENGINE_SNIFFER */
|
|
|
|
|