rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Data Structures | Functions | Variables
tooth_logger.h File Reference

Data Structures

struct  CompositeBuffer
 

Functions

const std::vector< CompositeEvent > & getCompositeEvents ()
 
void jsonTraceEntry (const char *name, int pid, bool isEnter, efitick_t timestamp)
 
void EnableToothLoggerIfNotEnabled ()
 
void EnableToothLogger ()
 
void DisableToothLogger ()
 
bool IsToothLoggerEnabled ()
 
void LogTriggerTooth (trigger_event_e tooth, efitick_t timestamp)
 
void LogTriggerCamTooth (bool isRising, efitick_t timestamp, int index)
 
void LogTriggerTopDeadCenter (efitick_t timestamp)
 
void LogTriggerSync (bool isSync, efitick_t timestamp)
 
void LogTriggerCoilState (efitick_t timestamp, size_t index, bool state)
 
void LogTriggerInjectorState (efitick_t timestamp, size_t index, bool state)
 
struct __attribute__ ((packed))
 
CompositeBufferGetToothLoggerBufferNonblocking ()
 
CompositeBufferGetToothLoggerBufferBlocking ()
 
void ReturnToothLoggerBuffer (CompositeBuffer *)
 

Variables

 composite_logger_s
 
static constexpr size_t toothLoggerEntriesPerBuffer = 250
 

Function Documentation

◆ __attribute__()

struct __attribute__ ( (packed)  )

Definition at line 38 of file tooth_logger.h.

40 {
41 // the whole order of all packet bytes is reversed, not just the 'endian-swap' integers
42 uint32_t timestamp;
43 // unfortunately all these fields are required by TS...
44 bool priLevel : 1;
45 bool secLevel : 1;
46 bool trigger : 1;
47 bool sync : 1;
48 bool coil : 1;
49 bool injector : 1;
static bool sync(void *instance)
composite_logger_s

◆ DisableToothLogger()

void DisableToothLogger ( )

Definition at line 77 of file tooth_logger.cpp.

77 {
78 ToothLoggerEnabled = false;
79}
static volatile bool ToothLoggerEnabled

Referenced by TunerStudio::handleCrcCommand(), perfTraceEnable(), and sdLoggerStop().

Here is the caller graph for this function:

◆ EnableToothLogger()

void EnableToothLogger ( )

Definition at line 72 of file tooth_logger.cpp.

72 {
73 ToothLoggerEnabled = true;
74 events.clear();
75}
static std::vector< CompositeEvent > events

Referenced by EnableToothLoggerIfNotEnabled(), TunerStudio::handleCrcCommand(), and sdLoggerStart().

Here is the caller graph for this function:

◆ EnableToothLoggerIfNotEnabled()

void EnableToothLoggerIfNotEnabled ( )

Definition at line 370 of file tooth_logger.cpp.

370 {
371 if (!ToothLoggerEnabled) {
373 }
374}
void EnableToothLogger()

Referenced by TunerStudio::handleCrcCommand().

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

◆ getCompositeEvents()

const std::vector< CompositeEvent > & getCompositeEvents ( )

Definition at line 54 of file tooth_logger.cpp.

54 {
55 return events;
56}

◆ GetToothLoggerBufferBlocking()

CompositeBuffer * GetToothLoggerBufferBlocking ( )

Definition at line 176 of file tooth_logger.cpp.

176 {
177 return GetToothLoggerBufferImpl(TIME_INFINITE);
178}
static CompositeBuffer * GetToothLoggerBufferImpl(sysinterval_t timeout)

Referenced by sdTriggerLogger().

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

◆ GetToothLoggerBufferNonblocking()

CompositeBuffer * GetToothLoggerBufferNonblocking ( )

Definition at line 172 of file tooth_logger.cpp.

172 {
173 return GetToothLoggerBufferImpl(TIME_IMMEDIATE);
174}

Referenced by TunerStudio::handleCrcCommand().

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

◆ IsToothLoggerEnabled()

bool IsToothLoggerEnabled ( )

Definition at line 376 of file tooth_logger.cpp.

376 {
377 return ToothLoggerEnabled;
378}

Referenced by perfTraceEnable().

Here is the caller graph for this function:

◆ jsonTraceEntry()

void jsonTraceEntry ( const char name,
int  pid,
bool  isEnter,
efitick_t  timestamp 
)

Definition at line 38 of file tooth_logger.cpp.

38 {
39extern FILE *jsonTrace;
40 if (jsonTrace != nullptr) {
41 fprintf(jsonTrace, ",\n");
42 fprintf(jsonTrace, "{\"name\":\"%s\",\"ph\":\"%s\",\"tid\":0,\"pid\":%d,\"ts\":%f}",
43 name,
44 isEnter ? "B" : "E",
45 pid,
46 timestamp / 1000.0);
47 }
48}

Referenced by LogTriggerCamTooth(), LogTriggerCoilState(), LogTriggerInjectorState(), LogTriggerSync(), and LogTriggerTooth().

Here is the caller graph for this function:

◆ LogTriggerCamTooth()

void LogTriggerCamTooth ( bool  isRising,
efitick_t  timestamp,
int  index 
)

Definition at line 269 of file tooth_logger.cpp.

269 {
270#if EFI_UNIT_TEST
271 jsonTraceEntry("cam", JSON_CAM_PID + index, /*isEnter*/isRising, timestamp);
272#else
273 UNUSED(isRising); UNUSED(timestamp); UNUSED(index);
274#endif
275}
UNUSED(samplingTimeSeconds)
void jsonTraceEntry(const char *name, int pid, bool isEnter, efitick_t timestamp)

Referenced by logVvtFront().

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

◆ LogTriggerCoilState()

void LogTriggerCoilState ( efitick_t  timestamp,
size_t  index,
bool  state 
)

Definition at line 346 of file tooth_logger.cpp.

346 {
347#if EFI_UNIT_TEST
348 jsonTraceEntry("coil", 20 + index, state, timestamp);
349#endif // EFI_UNIT_TEST
350 if (!ToothLoggerEnabled) {
351 return;
352 }
354 UNUSED(timestamp); UNUSED(index);
355 //SetNextCompositeEntry(timestamp, trigger1, trigger2, trigger);
356}
state("state", SensorCategory.SENSOR_INPUTS, FieldType.INT8, 1871, 1.0, -1.0, -1.0, "")
static bool currentCoilState

Referenced by fireSparkAndPrepareNextSchedule(), and turnSparkPinHighStartCharging().

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

◆ LogTriggerInjectorState()

void LogTriggerInjectorState ( efitick_t  timestamp,
size_t  index,
bool  state 
)

Definition at line 358 of file tooth_logger.cpp.

358 {
359#if EFI_UNIT_TEST
360 jsonTraceEntry("inj", 30 + index, state, timestamp);
361#endif // EFI_UNIT_TEST
362 if (!ToothLoggerEnabled) {
363 return;
364 }
366 UNUSED(timestamp); UNUSED(index);
367 //SetNextCompositeEntry(timestamp, trigger1, trigger2, trigger);
368}
static bool currentInjectorState

Referenced by InjectorOutputPin::close(), and InjectorOutputPin::open().

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

◆ LogTriggerSync()

void LogTriggerSync ( bool  isSync,
efitick_t  timestamp 
)

Definition at line 261 of file tooth_logger.cpp.

261 {
262#if EFI_UNIT_TEST
263 jsonTraceEntry("sync", 3, /*isEnter*/isSync, timestamp);
264#else
265 UNUSED(isSync); UNUSED(timestamp);
266#endif
267}

Referenced by TriggerDecoderBase::setShaftSynchronized().

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

◆ LogTriggerTooth()

void LogTriggerTooth ( trigger_event_e  tooth,
efitick_t  timestamp 
)

Definition at line 277 of file tooth_logger.cpp.

277 {
278#if EFI_UNIT_TEST
279 if (tooth == SHAFT_PRIMARY_RISING) {
280 jsonTraceEntry("trg0", JSON_TRG_PID, /*isEnter*/true, timestamp);
281 } else if (tooth == SHAFT_PRIMARY_FALLING) {
282 jsonTraceEntry("trg0", JSON_TRG_PID, /*isEnter*/false, timestamp);
283 }
284#endif // EFI_UNIT_TEST
285
286 efiAssertVoid(ObdCode::CUSTOM_ERR_6650, hasLotsOfRemainingStack(), "l-t-t");
287 // bail if we aren't enabled
288 if (!ToothLoggerEnabled) {
289 return;
290 }
291
292 // Don't log at significant engine speed
293 if (!getTriggerCentral()->isEngineSnifferEnabled) {
294 return;
295 }
296
298
299/*
300 // We currently only support the primary trigger falling edge
301 // (this is the edge that VR sensors are accurate on)
302 // Since VR sensors are the most useful case here, this is okay for now.
303 if (tooth != SHAFT_PRIMARY_FALLING) {
304 return;
305 }
306
307 uint32_t nowUs = NT2US(timestamp);
308 // 10us per LSB - this gives plenty of accuracy, yet fits 655.35 ms in to a uint16
309 uint16_t delta = static_cast<uint16_t>((nowUs - lastEdgeTimestamp) / 10);
310 lastEdgeTimestamp = nowUs;
311
312 SetNextEntry(delta);
313*/
314
315 switch (tooth) {
317 currentTrigger1 = false;
318 break;
320 currentTrigger1 = true;
321 break;
323 currentTrigger2 = false;
324 break;
326 currentTrigger2 = true;
327 break;
328 default:
329 break;
330 }
331
332 SetNextCompositeEntry(timestamp);
333}
TriggerCentral * getTriggerCentral()
Definition engine.cpp:590
@ CUSTOM_ERR_6650
@ LogTriggerTooth
@ SHAFT_SECONDARY_RISING
@ SHAFT_SECONDARY_FALLING
@ SHAFT_PRIMARY_FALLING
@ SHAFT_PRIMARY_RISING
static bool currentTrigger1
static bool currentTrigger2
void SetNextCompositeEntry(efitick_t timestamp)
Here is the call graph for this function:

◆ LogTriggerTopDeadCenter()

void LogTriggerTopDeadCenter ( efitick_t  timestamp)

Definition at line 335 of file tooth_logger.cpp.

335 {
336 // bail if we aren't enabled
337 if (!ToothLoggerEnabled) {
338 return;
339 }
340 currentTdc = true;
341 SetNextCompositeEntry(timestamp);
342 currentTdc = false;
343 SetNextCompositeEntry(timestamp + 10);
344}
static bool currentTdc

Referenced by onTdcCallback().

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

◆ ReturnToothLoggerBuffer()

void ReturnToothLoggerBuffer ( CompositeBuffer buffer)

Definition at line 180 of file tooth_logger.cpp.

180 {
181 chibios_rt::CriticalSectionLocker csl;
182
183 msg_t msg = freeBuffers.postI(buffer);
184 criticalAssertVoid(msg == MSG_OK, "Composite logger post to free buffer fail");
185}
static chibios_rt::Mailbox< CanFrameData *, LUA_canFrameCount > freeBuffers
static BigBufferHandle buffer

Referenced by TunerStudio::handleCrcCommand(), and sdTriggerLogger().

Here is the caller graph for this function:

Variable Documentation

◆ composite_logger_s

composite_logger_s

Definition at line 50 of file tooth_logger.h.

Referenced by TunerStudio::handleCrcCommand(), and sdTriggerLogger().

◆ toothLoggerEntriesPerBuffer

constexpr size_t toothLoggerEntriesPerBuffer = 250
staticconstexpr

Definition at line 52 of file tooth_logger.h.

Go to the source code of this file.