rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Public Member Functions | Data Fields | Private Attributes
WaveChart Class Reference

rusEfi console sniffer data buffer More...

#include <engine_sniffer.h>

Collaboration diagram for WaveChart:
Collaboration graph
[legend]

Public Member Functions

 WaveChart ()
 
void init ()
 
void addEvent3 (const char *name, const char *msg)
 Register an event for digital sniffer.
 
void reset ()
 
void startDataCollection ()
 
void publishIfFull ()
 
void publish ()
 
bool isFull () const
 
bool isStartedTooLongAgo () const
 
int getSize ()
 

Data Fields

efitick_t pauseEngineSnifferUntilNt = 0
 

Private Attributes

Logging logging
 
char timeBuffer [_MAX_FILLER+2]
 
uint32_t counter = 0
 
bool collectingData = false
 
efitick_t startTimeNt = 0
 
volatile int isInitialized = false
 

Detailed Description

rusEfi console sniffer data buffer

Definition at line 35 of file engine_sniffer.h.

Constructor & Destructor Documentation

◆ WaveChart()

WaveChart::WaveChart ( )

Definition at line 75 of file engine_sniffer.cpp.

75 : logging("wave chart", WAVE_LOGGING_BUFFER, sizeof(WAVE_LOGGING_BUFFER)) {
76}
Logging logging

Member Function Documentation

◆ addEvent3()

void WaveChart::addEvent3 ( const char name,
const char msg 
)

Register an event for digital sniffer.

We want smaller times within a chart in order to reduce packet size.

todo: migrate to binary fractions in order to eliminate this division? I do not like division

at least that's 32 bit division now

printf is a heavy method, append is used here as a performance optimization

Definition at line 150 of file engine_sniffer.cpp.

150 {
151#if EFI_TEXT_LOGGING
153 efitick_t nowNt = getTimeNowNt();
154
155 if (nowNt < pauseEngineSnifferUntilNt) {
156 return;
157 }
158 if (!getTriggerCentral()->isEngineSnifferEnabled) {
159 return;
160 }
161 if (skipUntilEngineCycle != 0 && getRevolutionCounter() < skipUntilEngineCycle)
162 return;
163#if EFI_SIMULATOR
164 if (!collectingData) {
165 return;
166 }
167#endif
168 efiAssertVoid(ObdCode::CUSTOM_ERR_6651, name!=NULL, "WC: NULL name");
169
170#if EFI_PROD_CODE
171 efiAssertVoid(ObdCode::CUSTOM_ERR_6652, getCurrentRemainingStack() > 32, "lowstck#2c");
172#endif /* EFI_PROD_CODE */
173
174 efiAssertVoid(ObdCode::CUSTOM_ERR_6653, isInitialized, "chart not initialized");
175
176 if (isFull()) {
177 return;
178 }
179
180 // we have multiple threads writing to the same output buffer
181 chibios_rt::CriticalSectionLocker csl;
182
183 if (counter == 0) {
184 startTimeNt = nowNt;
185 }
186 counter++;
187
188 /**
189 * We want smaller times within a chart in order to reduce packet size.
190 */
191 /**
192 * todo: migrate to binary fractions in order to eliminate
193 * this division? I do not like division
194 *
195 * at least that's 32 bit division now
196 */
197 uint32_t diffNt = nowNt - startTimeNt;
198 uint32_t time100 = NT2US(diffNt / ENGINE_SNIFFER_UNIT_US);
199
200 if (logging.remainingSize() > 35) {
201 /**
202 * printf is a heavy method, append is used here as a performance optimization
203 */
204 logging.appendFast(name);
205 logging.appendChar(CHART_DELIMETER);
206 logging.appendFast(msg);
207 logging.appendChar(CHART_DELIMETER);
208// time100 -= startTime100;
209
210 itoa10(timeBuffer, time100);
212 logging.appendChar(CHART_DELIMETER);
214 }
215#endif /* EFI_TEXT_LOGGING */
216}
void appendFast(const char *text)
void appendChar(char c)
Definition datalogging.h:40
size_t remainingSize() const
Definition datalogging.h:49
void terminate()
Definition datalogging.h:33
volatile int isInitialized
efitick_t startTimeNt
bool isFull() const
char timeBuffer[_MAX_FILLER+2]
efitick_t pauseEngineSnifferUntilNt
uint32_t counter
bool collectingData
char * itoa10(char *p, int num)
Definition efilib.cpp:107
efitick_t getTimeNowNt()
Definition efitime.cpp:19
TriggerCentral * getTriggerCentral()
Definition engine.cpp:590
static uint32_t skipUntilEngineCycle
@ CUSTOM_ERR_6651
@ CUSTOM_ERR_6653
@ CUSTOM_ERR_6652
@ EngineSniffer
Here is the call graph for this function:

◆ getSize()

int WaveChart::getSize ( )

Definition at line 110 of file engine_sniffer.cpp.

110 {
111 return counter;
112}

Referenced by triggerInfo().

Here is the caller graph for this function:

◆ init()

void WaveChart::init ( )

Definition at line 78 of file engine_sniffer.cpp.

78 {
79 isInitialized = true;
80 reset();
81}

Referenced by initWaveChart().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isFull()

bool WaveChart::isFull ( ) const

Definition at line 106 of file engine_sniffer.cpp.

106 {
108}
static constexpr engine_configuration_s * engineConfiguration

Referenced by addEvent3(), and publishIfFull().

Here is the caller graph for this function:

◆ isStartedTooLongAgo()

bool WaveChart::isStartedTooLongAgo ( ) const

Say at 300rpm we should get at least four events per revolution. That's 300/60*4=20 events per second engineChartSize/20 is the longest meaningful chart.

Definition at line 95 of file engine_sniffer.cpp.

95 {
96 /**
97 * Say at 300rpm we should get at least four events per revolution.
98 * That's 300/60*4=20 events per second
99 * engineChartSize/20 is the longest meaningful chart.
100 *
101 */
102 efidur_t chartDurationNt = getTimeNowNt() - startTimeNt;
103 return startTimeNt != 0 && NT2US(chartDurationNt) > engineConfiguration->engineChartSize * 1000000 / 20;
104}
efitick_t efidur_t

Referenced by publishIfFull().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ publish()

void WaveChart::publish ( )

Definition at line 136 of file engine_sniffer.cpp.

136 {
137#if EFI_ENGINE_SNIFFER
138 logging.appendPrintf( LOG_DELIMITER);
140
141 if (getTriggerCentral()->isEngineSnifferEnabled) {
143 }
144#endif /* EFI_ENGINE_SNIFFER */
145}
size_t loggingSize() const
Definition datalogging.h:45
void appendPrintf(const char *fmt,...) __attribute__((format(printf
int waveChartUsedSize
void scheduleLogging(Logging *logging)

Referenced by publishIfFull().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ publishIfFull()

void WaveChart::publishIfFull ( )

Definition at line 129 of file engine_sniffer.cpp.

129 {
130 if (isFull() || isStartedTooLongAgo()) {
131 publish();
132 reset();
133 }
134}
bool isStartedTooLongAgo() const

Referenced by printOverallStatus().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset()

void WaveChart::reset ( )

Definition at line 83 of file engine_sniffer.cpp.

83 {
84 logging.reset();
85 counter = 0;
86 startTimeNt = 0;
87 collectingData = false;
88 logging.appendPrintf( "%s%s", PROTOCOL_ENGINE_SNIFFER, LOG_DELIMITER);
89}
void reset()

Referenced by init(), publishIfFull(), Engine::resetEngineSnifferIfInTestMode(), and resetNow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ startDataCollection()

void WaveChart::startDataCollection ( )

Definition at line 91 of file engine_sniffer.cpp.

91 {
92 collectingData = true;
93}

Referenced by addEngineSnifferTdcEvent().

Here is the caller graph for this function:

Field Documentation

◆ collectingData

bool WaveChart::collectingData = false
private

We want to avoid visual jitter thus we want the left edge to be aligned https://github.com/rusefi/rusefi/issues/780

Definition at line 59 of file engine_sniffer.h.

Referenced by addEvent3(), reset(), and startDataCollection().

◆ counter

uint32_t WaveChart::counter = 0
private

Definition at line 54 of file engine_sniffer.h.

Referenced by addEvent3(), getSize(), isFull(), and reset().

◆ isInitialized

volatile int WaveChart::isInitialized = false
private

Definition at line 61 of file engine_sniffer.h.

Referenced by addEvent3(), and init().

◆ logging

Logging WaveChart::logging
private

Definition at line 51 of file engine_sniffer.h.

Referenced by addEvent3(), publish(), and reset().

◆ pauseEngineSnifferUntilNt

efitick_t WaveChart::pauseEngineSnifferUntilNt = 0

Definition at line 47 of file engine_sniffer.h.

Referenced by addEvent3(), and Engine::resetEngineSnifferIfInTestMode().

◆ startTimeNt

efitick_t WaveChart::startTimeNt = 0
private

Definition at line 60 of file engine_sniffer.h.

Referenced by addEvent3(), isStartedTooLongAgo(), and reset().

◆ timeBuffer

char WaveChart::timeBuffer[_MAX_FILLER+2]
private

Definition at line 52 of file engine_sniffer.h.

Referenced by addEvent3().


The documentation for this class was generated from the following files: