From 228437f57490814bd118f579f4e8b6075d944a8b Mon Sep 17 00:00:00 2001 From: rusefillc Date: Mon, 12 Sep 2022 20:56:57 -0400 Subject: [PATCH] outputRequestPeriod into logs --- firmware/console/binary/tunerstudio_commands.cpp | 8 ++++++++ firmware/console/binary_log/binary_logging.cpp | 8 +++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/firmware/console/binary/tunerstudio_commands.cpp b/firmware/console/binary/tunerstudio_commands.cpp index 7250e2c0d8..37d3ef4bc8 100644 --- a/firmware/console/binary/tunerstudio_commands.cpp +++ b/firmware/console/binary/tunerstudio_commands.cpp @@ -35,6 +35,8 @@ bool validateOffsetCount(size_t offset, size_t count, TsChannelBase* tsChannel) // the ECU. Forcing a reboot will force TS to re-read the tune CRC, bool rebootForPresetPending = false; +static efitimeus_t prevRequestTime = 0; + /** * @brief 'Output' command sends out a snapshot of current values * Gauges refresh @@ -47,6 +49,12 @@ void TunerStudio::cmdOutputChannels(TsChannelBase* tsChannel, uint16_t offset, u return; } + if (offset < BLOCKING_FACTOR) { + efitimeus_t now = getTimeNowUs(); + engine->outputChannels.outputRequestPeriod = now - prevRequestTime; + prevRequestTime = now; + } + tsState.outputChannelsCommandCounter++; updateTunerStudioState(); tsChannel->assertPacketSize(count, false); diff --git a/firmware/console/binary_log/binary_logging.cpp b/firmware/console/binary_log/binary_logging.cpp index 37115736c8..0c558b6252 100644 --- a/firmware/console/binary_log/binary_logging.cpp +++ b/firmware/console/binary_log/binary_logging.cpp @@ -102,6 +102,8 @@ void writeFileHeader(Writer& outBuffer) { static uint8_t blockRollCounter = 0; +//static efitimeus_t prevSdCardLineTime = 0; + size_t writeBlock(char* buffer) { // Offset 0 = Block type, standard data block in this case buffer[0] = 0; @@ -110,10 +112,14 @@ size_t writeBlock(char* buffer) { buffer[1] = blockRollCounter++; // Offset 2, size 2 = Timestamp at 10us resolution - uint16_t timestamp = getTimeNowUs() / 10; + efitimeus_t nowUs = getTimeNowUs(); + uint16_t timestamp = nowUs / 10; buffer[2] = timestamp >> 8; buffer[3] = timestamp & 0xFF; + // todo: add a log field for SD card period +// prevSdCardLineTime = nowUs; + packedTime = getTimeNowMs() * 1.0 / TIME_PRECISION; // Offset 4 = field data