outputRequestPeriod into logs

This commit is contained in:
rusefillc 2022-09-12 20:56:57 -04:00
parent 5da9012d70
commit 228437f574
2 changed files with 15 additions and 1 deletions

View File

@ -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);

View File

@ -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