rusEFI
The most advanced open source ECU
Functions | Variables
tooth_logger.cpp File Reference

Functions

 fail ("EFI_SHAFT_POSITION_INPUT required to have EFI_EMULATE_POSITION_SENSORS") static_assert(sizeof(composite_logger_s)
 
const std::vector< CompositeEvent > & getCompositeEvents ()
 
void SetNextCompositeEntry (efitick_t timestamp)
 
void EnableToothLogger ()
 
void DisableToothLogger ()
 
static void setToothLogReady (bool value)
 
static CompositeBufferGetToothLoggerBufferImpl (sysinterval_t timeout)
 
CompositeBufferGetToothLoggerBufferNonblocking ()
 
CompositeBufferGetToothLoggerBufferBlocking ()
 
void ReturnToothLoggerBuffer (CompositeBuffer *buffer)
 
static CompositeBufferfindBuffer (efitick_t timestamp)
 
void LogTriggerTooth (trigger_event_e tooth, efitick_t timestamp)
 
void LogTriggerTopDeadCenter (efitick_t timestamp)
 
void LogTriggerCoilState (efitick_t timestamp, bool state)
 
void LogTriggerInjectorState (efitick_t timestamp, bool state)
 
void EnableToothLoggerIfNotEnabled ()
 
bool IsToothLoggerEnabled ()
 

Variables

composite packet size
 
static volatile bool ToothLoggerEnabled = false
 
static bool currentTrigger1 = false
 
static bool currentTrigger2 = false
 
static bool currentTdc = false
 
static bool currentCoilState = false
 
static bool currentInjectorState = false
 
static std::vector< CompositeEvent > events
 
static constexpr size_t BUFFER_COUNT = BIG_BUFFER_SIZE / sizeof(CompositeBuffer)
 
static CompositeBufferbuffers = nullptr
 
static chibios_rt::Mailbox< CompositeBuffer *, BUFFER_COUNT > freeBuffers CCM_OPTIONAL
 
static CompositeBuffercurrentBuffer = nullptr
 
static BigBufferHandle bufferHandle
 

Function Documentation

◆ DisableToothLogger()

void DisableToothLogger ( )

Definition at line 64 of file tooth_logger.cpp.

64  {
65  ToothLoggerEnabled = false;
66 }
static volatile bool ToothLoggerEnabled

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

Here is the caller graph for this function:

◆ EnableToothLogger()

void EnableToothLogger ( )

Definition at line 59 of file tooth_logger.cpp.

59  {
60  ToothLoggerEnabled = true;
61  events.clear();
62 }
static std::vector< CompositeEvent > events

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

Here is the caller graph for this function:

◆ EnableToothLoggerIfNotEnabled()

void EnableToothLoggerIfNotEnabled ( )

Definition at line 324 of file tooth_logger.cpp.

324  {
325  if (!ToothLoggerEnabled) {
327  }
328 }
void EnableToothLogger()

Referenced by TunerStudio::handleCrcCommand().

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

◆ fail()

fail ( "EFI_SHAFT_POSITION_INPUT required to have EFI_EMULATE_POSITION_SENSORS"  )

Engine idles around 20Hz and revs up to 140Hz, at 60/2 and 8 cylinders we have about 20Khz events If we can read buffer at 50Hz we want buffer to be about 400 elements.

Referenced by Engine::periodicSlowCallback().

Here is the caller graph for this function:

◆ findBuffer()

static CompositeBuffer* findBuffer ( efitick_t  timestamp)
static

Definition at line 174 of file tooth_logger.cpp.

174  {
176 
177  if (!currentBuffer) {
178  // try and find a buffer, if none available, we can't log
179  if (MSG_OK != freeBuffers.fetchI(&buffer)) {
180  return nullptr;
181  }
182 
183  // Record the time of the last buffer swap so we can force a swap after a minimum period of time
184  // This ensures the user sees *something* even if they don't have enough trigger events
185  // to fill the buffer.
186  buffer->startTime.reset(timestamp);
187  buffer->nextIdx = 0;
188 
190  }
191 
192  return currentBuffer;
193 }
static chibios_rt::Mailbox< CanFrameData *, canFrameCount > freeBuffers
Definition: lua_can_rx.cpp:25
static CompositeBuffer * currentBuffer
static BigBufferHandle buffer

◆ getCompositeEvents()

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

Definition at line 41 of file tooth_logger.cpp.

41  {
42  return events;
43 }

◆ GetToothLoggerBufferBlocking()

CompositeBuffer* GetToothLoggerBufferBlocking ( )

Definition at line 163 of file tooth_logger.cpp.

163  {
164  return GetToothLoggerBufferImpl(TIME_INFINITE);
165 }
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:

◆ GetToothLoggerBufferImpl()

static CompositeBuffer* GetToothLoggerBufferImpl ( sysinterval_t  timeout)
static

Definition at line 135 of file tooth_logger.cpp.

135  {
137  msg_t msg = filledBuffers.fetch(&buffer, timeout);
138 
139  if (msg == MSG_TIMEOUT) {
140  setToothLogReady(false);
141  return nullptr;
142  }
143 
144  if (msg != MSG_OK) {
145  // What even happened if we didn't get timeout, but also didn't get OK?
146  return nullptr;
147  }
148 
149  chibios_rt::CriticalSectionLocker csl;
150 
151  // If the used list is empty, clear the ready flag
152  if (filledBuffers.getUsedCountI() == 0) {
153  setToothLogReady(false);
154  }
155 
156  return buffer;
157 }
static chibios_rt::Mailbox< CanFrameData *, canFrameCount > filledBuffers
Definition: lua_can_rx.cpp:27
static void setToothLogReady(bool value)

Referenced by GetToothLoggerBufferBlocking(), and GetToothLoggerBufferNonblocking().

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

◆ GetToothLoggerBufferNonblocking()

CompositeBuffer* GetToothLoggerBufferNonblocking ( )

Definition at line 159 of file tooth_logger.cpp.

159  {
160  return GetToothLoggerBufferImpl(TIME_IMMEDIATE);
161 }

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 330 of file tooth_logger.cpp.

330  {
331  return ToothLoggerEnabled;
332 }

Referenced by perfTraceEnable().

Here is the caller graph for this function:

◆ LogTriggerCoilState()

void LogTriggerCoilState ( efitick_t  timestamp,
bool  state 
)

Definition at line 306 of file tooth_logger.cpp.

306  {
307  if (!ToothLoggerEnabled) {
308  return;
309  }
311  UNUSED(timestamp);
312  //SetNextCompositeEntry(timestamp, trigger1, trigger2, trigger);
313 }
UNUSED(samplingTimeSeconds)
static ScState state
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,
bool  state 
)

Definition at line 315 of file tooth_logger.cpp.

315  {
316  if (!ToothLoggerEnabled) {
317  return;
318  }
320  UNUSED(timestamp);
321  //SetNextCompositeEntry(timestamp, trigger1, trigger2, trigger);
322 }
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:

◆ LogTriggerTooth()

void LogTriggerTooth ( trigger_event_e  tooth,
efitick_t  timestamp 
)

Definition at line 245 of file tooth_logger.cpp.

245  {
246  efiAssertVoid(ObdCode::CUSTOM_ERR_6650, hasLotsOfRemainingStack(), "l-t-t");
247  // bail if we aren't enabled
248  if (!ToothLoggerEnabled) {
249  return;
250  }
251 
252  // Don't log at significant engine speed
253  if (!getTriggerCentral()->isEngineSnifferEnabled) {
254  return;
255  }
256 
258 
259 /*
260  // We currently only support the primary trigger falling edge
261  // (this is the edge that VR sensors are accurate on)
262  // Since VR sensors are the most useful case here, this is okay for now.
263  if (tooth != SHAFT_PRIMARY_FALLING) {
264  return;
265  }
266 
267  uint32_t nowUs = NT2US(timestamp);
268  // 10us per LSB - this gives plenty of accuracy, yet fits 655.35 ms in to a uint16
269  uint16_t delta = static_cast<uint16_t>((nowUs - lastEdgeTimestamp) / 10);
270  lastEdgeTimestamp = nowUs;
271 
272  SetNextEntry(delta);
273 */
274 
275  switch (tooth) {
277  currentTrigger1 = false;
278  break;
280  currentTrigger1 = true;
281  break;
283  currentTrigger2 = false;
284  break;
286  currentTrigger2 = true;
287  break;
288  default:
289  break;
290  }
291 
292  SetNextCompositeEntry(timestamp);
293 }
TriggerCentral * getTriggerCentral()
Definition: engine.cpp:609
@ 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)

Referenced by handleShaftSignal(), and logVvtFront().

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

◆ LogTriggerTopDeadCenter()

void LogTriggerTopDeadCenter ( efitick_t  timestamp)

Definition at line 295 of file tooth_logger.cpp.

295  {
296  // bail if we aren't enabled
297  if (!ToothLoggerEnabled) {
298  return;
299  }
300  currentTdc = true;
301  SetNextCompositeEntry(timestamp);
302  currentTdc = false;
303  SetNextCompositeEntry(timestamp + 10);
304 }
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 167 of file tooth_logger.cpp.

167  {
168  chibios_rt::CriticalSectionLocker csl;
169 
170  msg_t msg = freeBuffers.postI(buffer);
171  criticalAssertVoid(msg == MSG_OK, "Composite logger post to free buffer fail");
172 }

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

Here is the caller graph for this function:

◆ SetNextCompositeEntry()

static void SetNextCompositeEntry ( efitick_t  timestamp)

Definition at line 45 of file tooth_logger.cpp.

45  {
46  CompositeEvent event;
47 
48  event.timestamp = timestamp;
49  event.primaryTrigger = currentTrigger1;
50  event.secondaryTrigger = currentTrigger2;
51  event.isTDC = currentTdc;
53  event.coil = currentCoilState;
54  event.injector = currentInjectorState;
55 
56  events.push_back(event);
57 }
TriggerCentral triggerCentral
Definition: engine.h:286
PrimaryTriggerDecoder triggerState
Engine * engine

Referenced by LogTriggerTooth(), and LogTriggerTopDeadCenter().

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

◆ setToothLogReady()

static void setToothLogReady ( bool  value)
static

Definition at line 79 of file tooth_logger.cpp.

79  {
80 #if EFI_TUNER_STUDIO && (EFI_PROD_CODE || EFI_SIMULATOR)
82 #endif // EFI_TUNER_STUDIO
83 }
TunerStudioOutputChannels outputChannels
Definition: engine.h:99

Referenced by GetToothLoggerBufferImpl().

Here is the caller graph for this function:

Variable Documentation

◆ BUFFER_COUNT

constexpr size_t BUFFER_COUNT = BIG_BUFFER_SIZE / sizeof(CompositeBuffer)
staticconstexpr

Definition at line 70 of file tooth_logger.cpp.

◆ bufferHandle

BigBufferHandle bufferHandle
static

Definition at line 85 of file tooth_logger.cpp.

◆ buffers

CompositeBuffer* buffers = nullptr
static

Definition at line 73 of file tooth_logger.cpp.

◆ CCM_OPTIONAL

static chibios_rt::Mailbox< CompositeBuffer *, BUFFER_COUNT > filledBuffers CCM_OPTIONAL
static

Definition at line 74 of file tooth_logger.cpp.

◆ currentBuffer

CompositeBuffer* currentBuffer = nullptr
static

Definition at line 77 of file tooth_logger.cpp.

Referenced by findBuffer().

◆ currentCoilState

bool currentCoilState = false
static

Definition at line 32 of file tooth_logger.cpp.

Referenced by LogTriggerCoilState(), and SetNextCompositeEntry().

◆ currentInjectorState

bool currentInjectorState = false
static

Definition at line 34 of file tooth_logger.cpp.

Referenced by LogTriggerInjectorState(), and SetNextCompositeEntry().

◆ currentTdc

bool currentTdc = false
static

Definition at line 30 of file tooth_logger.cpp.

Referenced by LogTriggerTopDeadCenter(), and SetNextCompositeEntry().

◆ currentTrigger1

bool currentTrigger1 = false
static

Definition at line 28 of file tooth_logger.cpp.

Referenced by LogTriggerTooth(), and SetNextCompositeEntry().

◆ currentTrigger2

bool currentTrigger2 = false
static

Definition at line 29 of file tooth_logger.cpp.

Referenced by LogTriggerTooth(), and SetNextCompositeEntry().

◆ events

std::vector<CompositeEvent> events
static

◆ size

composite packet size

Definition at line 23 of file tooth_logger.cpp.

Referenced by __early_sdram_test(), ArrayList< Type, Dimention >::add(), TsChannelBase::assertPacketSize(), at32GetMcuType(), base64(), bluetoothStart(), TriggerWaveform::calculateExpectedEventCounts(), chDbgPanic3(), commonGenesisCoupe(), computeFieldsRecordLength(), TsChannelBase::copyAndWriteSmallCrcPacket(), InjectorModelBase::correctInjectionPolynomial(), TsChannelBase::crcAndWriteBuffer(), debugBrainPin(), deInitAuxDigital(), deinitAuxSensors(), do_connection(), EnginePins::EnginePins(), EventQueue::EventQueue(), fft::fft(), fft::fft_adc_sample(), fft::fft_amp(), fft::fft_db(), fft::fft_freq(), fft::ffti(), findBaudIndex(), HellenBoardIdFinderBase::findClosestResistor(), findEntry(), findIndexMsg(), findSensorTypeByName(), firmwareError(), get_info(), fft::get_main_freq(), getAdcChannel(), getAdcChannelBrainPin(), getAdcInternalChannel(), getArray(), getBoardMetaOutputsCount(), getBrainPinPort(), Sensor::getEntryForType(), getHwPort(), getLiveData(), getLiveDataFragments(), getNextPwmDevice(), BoostController::getOpenLoop(), getPortIndex(), getPreviousIndex(), getRunningAdvance(), BoostController::getSetpoint(), AirmassVeModelBase::getVe(), gpiochip_getNextPwmDevice(), gpiochip_register(), gzSize(), TunerStudio::handleScatteredReadCommand(), GenericGearController::init(), SimpleTransmissionController::init(), initAuxDigital(), initAuxSensors(), initBoostCtrl(), initDataStructures(), initGpPwm(), initRangeSensors(), initVrThresholdPwm(), initWave(), TsChannelBase::isBigPacket(), knockSpectorgramAddLine(), loadLibraries(), LPUART_TransferGetRxRingBufferLength(), lua_vincpy(), luaDeInitPins(), mreSecondaryCan(), onConfigurationChangeTriggerCallback(), SensorChecker::onSlowCallback(), onStartKnockSampling(), Engine::OnTriggerSynchronizationLost(), EngineState::periodicFastCallback(), pinDiag2string(), pokeAuxDigital(), portname(), AdcSubscription::PrintInfo(), printScatterList(), proteusBoardTest(), proteusDcWastegateTest(), proteusLuaDemo(), TsChannelBase::read(), SerialTsChannel::readTimeout(), UartTsChannel::readTimeout(), UartDmaTsChannel::readTimeout(), ArrayList< Type, Dimention >::removeAt(), ArrayList< Type, Dimention >::reset(), resetAccel(), Sensor::resetAllMocks(), AdcSubscription::ResetFilters(), FuelSchedule::resetOverlapping(), Sensor::resetRegistry(), sendQcBenchRawAnalogValues(), TsChannelBase::sendResponse(), setCurveValue(), setDefaultCranking(), setDefaultGppwmParameters(), setDefaultIgnition(), setDefaultLambdaTable(), setDefaultStftSettings(), setDefaultVETable(), setGmLs4(), setHarley(), setHondaCivicBcm(), setHyundaiPb(), InstantRpmCalculator::setLastEventTimeForInstantRpm(), setMafDecodingBins(), setProteusVwPassatB6(), setRpmBin(), Sensor::showAllSensorInfo(), startTriggerEmulatorPins(), stopTriggerEmulatorPins(), tinymt32_init_by_array(), EventQueue::tryReturnScheduling(), turnInjectionPinHigh(), turnInjectionPinLow(), turnInjectionPinLowStage2(), GenericGearController::update(), SimpleTransmissionController::update(), updateGppwm(), AdcSubscription::UpdateSubscribers(), updateVrThresholdPwm(), updateWarningCodes(), USBD_LL_PrepareReceive(), USBD_LL_Transmit(), validateConfigOnStartUpOrBurn(), w25q_find_id(), warning(), wipeString(), SerialTsChannel::write(), UartTsChannel::write(), TsChannelBase::writeCrcPacket(), TsChannelBase::writeCrcPacketLarge(), LogField::writeData(), writeFileHeader(), TsChannelBase::writePacketHeader(), and writeSdBlock().

◆ ToothLoggerEnabled

volatile bool ToothLoggerEnabled = false
static

Go to the source code of this file.