moving SD logic to better source
This commit is contained in:
parent
ab51fc0b2a
commit
9c83cfd696
|
@ -8,6 +8,7 @@
|
|||
#include "binary_logging.h"
|
||||
#include "log_field.h"
|
||||
#include "buffered_writer.h"
|
||||
#include "tunerstudio.h"
|
||||
|
||||
#define TIME_PRECISION 1000
|
||||
|
||||
|
@ -28,9 +29,35 @@ static constexpr uint16_t computeFieldsRecordLength() {
|
|||
return recLength;
|
||||
}
|
||||
|
||||
#if EFI_FILE_LOGGING
|
||||
// this one needs to be in main ram so that SD card SPI DMA works fine
|
||||
static NO_CACHE char sdLogBuffer[250];
|
||||
static uint64_t binaryLogCount = 0;
|
||||
|
||||
extern bool main_loop_started;
|
||||
|
||||
void writeSdLogLine(Writer& buffer) {
|
||||
if (!main_loop_started)
|
||||
return;
|
||||
|
||||
if (binaryLogCount == 0) {
|
||||
writeFileHeader(buffer);
|
||||
} else {
|
||||
updateTunerStudioState();
|
||||
size_t length = writeBlock(sdLogBuffer);
|
||||
efiAssertVoid(OBD_PCM_Processor_Fault, length <= efi::size(sdLogBuffer), "SD log buffer overflow");
|
||||
buffer.write(sdLogBuffer, length);
|
||||
}
|
||||
|
||||
binaryLogCount++;
|
||||
}
|
||||
|
||||
#endif /* EFI_FILE_LOGGING */
|
||||
|
||||
|
||||
static constexpr uint16_t recordLength = computeFieldsRecordLength();
|
||||
|
||||
void writeHeader(Writer& outBuffer) {
|
||||
void writeFileHeader(Writer& outBuffer) {
|
||||
char buffer[MLQ_HEADER_SIZE];
|
||||
// File format: MLVLG\0
|
||||
strncpy(buffer, "MLVLG", 6);
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
/**
|
||||
* @file binary_logging.h
|
||||
*/
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
struct Writer;
|
||||
void writeHeader(Writer& buffer);
|
||||
void writeFileHeader(Writer& buffer);
|
||||
void writeSdLogLine(Writer& buffer);
|
||||
size_t writeBlock(char* buffer);
|
||||
|
|
|
@ -111,29 +111,6 @@ static void setWarningEnabled(int value) {
|
|||
warningEnabled = value;
|
||||
}
|
||||
|
||||
#if EFI_FILE_LOGGING
|
||||
// this one needs to be in main ram so that SD card SPI DMA works fine
|
||||
static NO_CACHE char sdLogBuffer[250];
|
||||
static uint64_t binaryLogCount = 0;
|
||||
|
||||
void writeLogLine(Writer& buffer) {
|
||||
if (!main_loop_started)
|
||||
return;
|
||||
|
||||
if (binaryLogCount == 0) {
|
||||
writeHeader(buffer);
|
||||
} else {
|
||||
updateTunerStudioState();
|
||||
size_t length = writeBlock(sdLogBuffer);
|
||||
efiAssertVoid(OBD_PCM_Processor_Fault, length <= efi::size(sdLogBuffer), "SD log buffer overflow");
|
||||
buffer.write(sdLogBuffer, length);
|
||||
}
|
||||
|
||||
binaryLogCount++;
|
||||
}
|
||||
|
||||
#endif /* EFI_FILE_LOGGING */
|
||||
|
||||
/**
|
||||
* This is useful if we are changing engine mode dynamically
|
||||
* For example http://rusefi.com/forum/viewtopic.php?f=5&t=1085
|
||||
|
|
|
@ -14,5 +14,5 @@ void startStatusThreads(void);
|
|||
void initStatusLoop(void);
|
||||
|
||||
struct Writer;
|
||||
void writeLogLine(Writer& buffer);
|
||||
|
||||
void printOverallStatus();
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include "buffered_writer.h"
|
||||
#include "status_loop.h"
|
||||
#include "binary_logging.h"
|
||||
|
||||
static bool fs_ready = false;
|
||||
|
||||
|
@ -532,7 +533,7 @@ static THD_FUNCTION(MMCmonThread, arg) {
|
|||
engine->outputChannels.debugIntField4 = fileCreatedCounter;
|
||||
}
|
||||
|
||||
writeLogLine(logBuffer);
|
||||
writeSdLogLine(logBuffer);
|
||||
|
||||
// Something went wrong (already handled), so cancel further writes
|
||||
if (logBuffer.failed) {
|
||||
|
|
Loading…
Reference in New Issue