fome-fw/firmware/console/binary/tooth_logger.h

66 lines
1.6 KiB
C
Raw Normal View History

2019-07-07 12:22:46 -07:00
/*
* @file tooth_logger.h
*
* @date Jul 7, 2019
* @author Matthew Kennedy
*/
#pragma once
#include "rusefi_enums.h"
2022-09-07 16:35:52 -07:00
#include "expected.h"
#include "trigger_structure.h"
2020-07-19 21:36:10 -07:00
#if EFI_UNIT_TEST
#include "logicdata.h"
const std::vector<CompositeEvent>& getCompositeEvents();
2020-07-19 21:36:10 -07:00
#endif // EFI_UNIT_TEST
2020-05-26 19:30:53 -07:00
void EnableToothLoggerIfNotEnabled();
// Enable the tooth logger - this clears the buffer starts logging
void EnableToothLogger();
// Stop logging - leave buffer intact
void DisableToothLogger();
// A new tooth has arrived! Log to the buffer if enabled.
void LogTriggerTooth(trigger_event_e tooth, efitick_t timestamp);
void LogTriggerTopDeadCenter(efitick_t timestamp);
void LogTriggerCoilState(efitick_t timestamp, bool state);
2020-05-25 21:07:18 -07:00
void LogTriggerInjectorState(efitick_t timestamp, bool state);
2020-05-25 21:07:18 -07:00
typedef struct __attribute__ ((packed)) {
// the whole order of all packet bytes is reversed, not just the 'endian-swap' integers
uint32_t timestamp;
// unfortunately all these fields are required by TS...
bool priLevel : 1;
bool secLevel : 1;
bool trigger : 1;
bool sync : 1;
bool coil : 1;
bool injector : 1;
} composite_logger_s;
static constexpr size_t toothLoggerEntriesPerBuffer = 250;
struct CompositeBuffer {
composite_logger_s buffer[toothLoggerEntriesPerBuffer];
size_t nextIdx;
Timer startTime;
};
// Get a reference to the buffer
// Returns nullptr if no buffer is available
CompositeBuffer* GetToothLoggerBufferNonblocking();
// Blocks until a buffer is available
CompositeBuffer* GetToothLoggerBufferBlocking();
// Return a buffer to the pool once its contents have been read
void ReturnToothLoggerBuffer(CompositeBuffer*);
#include "big_buffer.h"