console composite logger

This commit is contained in:
rusefi 2020-05-26 22:30:53 -04:00
parent 3705c9522f
commit 347413e44b
3 changed files with 36 additions and 0 deletions

View File

@ -51,6 +51,10 @@ static bool coil = false;
// same about injectors
static bool injector = false;
int getCompositeRecordCount() {
return NextIdx;
}
static void SetNextCompositeEntry(efitick_t timestamp, bool trigger1, bool trigger2,
bool isTDC DECLARE_ENGINE_PARAMETER_SUFFIX) {
uint32_t nowUs = NT2US(timestamp);
@ -159,6 +163,12 @@ void EnableToothLogger() {
tsOutputChannels.toothLogReady = true;
}
void EnableToothLoggerIfNotEnabled() {
if (!ToothLoggerEnabled) {
EnableToothLogger();
}
}
void DisableToothLogger() {
ToothLoggerEnabled = false;
tsOutputChannels.toothLogReady = false;

View File

@ -13,6 +13,10 @@
#include "rusefi_enums.h"
#include "engine.h"
int getCompositeRecordCount();
void EnableToothLoggerIfNotEnabled();
// Enable the tooth logger - this clears the buffer starts logging
void EnableToothLogger();

View File

@ -749,6 +749,8 @@ bool handlePlainCommand(ts_channel_s *tsChannel, uint8_t command) {
}
}
static int transmitted = 0;
int tunerStudioHandleCrcCommand(ts_channel_s *tsChannel, char *data, int incomingPacketSize) {
ScopePerf perf(PE::TunerStudioHandleCrcCommand);
@ -842,6 +844,26 @@ int tunerStudioHandleCrcCommand(ts_channel_s *tsChannel, char *data, int incomin
sendOkResponse(tsChannel, TS_CRC);
break;
case TS_GET_COMPOSITE_BUFFER_DONE_DIFFERENTLY:
{
const uint8_t* const buffer = GetToothLoggerBuffer().Buffer;
const uint8_t* const start = buffer + COMPOSITE_PACKET_SIZE * transmitted;
int currentEnd = getCompositeRecordCount();
if (currentEnd > transmitted) {
// more normal case - tail after head
sr5SendResponse(tsChannel, TS_CRC, start, COMPOSITE_PACKET_SIZE * (currentEnd - transmitted));
transmitted = currentEnd;
} else {
// we are here if tail of buffer has reached the end of buffer and re-started from the start of buffer
// sending end of the buffer, next transmission would take care of the rest
sr5SendResponse(tsChannel, TS_CRC, start, COMPOSITE_PACKET_SIZE * (COMPOSITE_PACKET_COUNT - transmitted));
transmitted = 0;
}
}
break;
case TS_GET_LOGGER_GET_BUFFER:
{
auto toothBuffer = GetToothLoggerBuffer();