less dependence on that logger (#3884)
* less dependence on that logger * comma * refactor a bit, make it clear what this thing actually *does* * static * shrink the buffer a bit and make names useful * dead util that's just subtraction lol
This commit is contained in:
parent
ad9615bf41
commit
f1897ba7aa
|
@ -323,8 +323,6 @@
|
|||
/**
|
||||
* This is the size of the MemoryStream used by chvprintf
|
||||
*/
|
||||
#define STATUS_LOGGING_BUFFER_SIZE 1800
|
||||
#define SETTINGS_LOGGING_BUFFER_SIZE 1000
|
||||
#define DL_OUTPUT_BUFFER 6500
|
||||
|
||||
//#define UTILITY_THREAD_STACK_SIZE 270 /*400*/
|
||||
|
|
|
@ -292,8 +292,7 @@
|
|||
/**
|
||||
* This is the size of the MemoryStream used by chvprintf
|
||||
*/
|
||||
#define STATUS_LOGGING_BUFFER_SIZE 120 /*1800*/
|
||||
#define SETTINGS_LOGGING_BUFFER_SIZE 100 /*1000*/
|
||||
#define LOGIC_ANALYZER_BUFFER_SIZE 120 /*1800*/
|
||||
#define DL_OUTPUT_BUFFER 10 /*6500*/
|
||||
|
||||
#define UTILITY_THREAD_STACK_SIZE 270 /*400*/
|
||||
|
|
|
@ -11,7 +11,6 @@ export EXTRA_PARAMS="-DDUMMY -DSTM32F767xx \
|
|||
-DEFI_INJECTOR_PIN3=GPIO_UNASSIGNED \
|
||||
-DFIRMWARE_ID=\\\"nucleo767\\\" \
|
||||
-DEFI_COMMUNICATION_PIN=GPIOB_7 \
|
||||
-DSTATUS_LOGGING_BUFFER_SIZE=1400 \
|
||||
-DLED_CRITICAL_ERROR_BRAIN_PIN=GPIOB_14 \
|
||||
-DEFI_ENABLE_ASSERTS=FALSE \
|
||||
-DCH_DBG_ENABLE_CHECKS=FALSE -DCH_DBG_ENABLE_ASSERTS=FALSE -DCH_DBG_ENABLE_STACK_CHECK=FALSE -DCH_DBG_FILL_THREADS=FALSE -DCH_DBG_THREADS_PROFILING=FALSE"
|
||||
|
|
|
@ -11,7 +11,6 @@ export EXTRA_PARAMS="-DDUMMY \
|
|||
-DEFI_INJECTOR_PIN3=GPIO_UNASSIGNED \
|
||||
-DFIRMWARE_ID=\\\"nucleoH743\\\" \
|
||||
-DEFI_COMMUNICATION_PIN=GPIOB_7 \
|
||||
-DSTATUS_LOGGING_BUFFER_SIZE=1400 \
|
||||
-DLED_CRITICAL_ERROR_BRAIN_PIN=GPIOB_14"
|
||||
export DEBUG_LEVEL_OPT="-O2"
|
||||
|
||||
|
|
|
@ -600,7 +600,7 @@ static void handleGetVersion(TsChannelBase* tsChannel) {
|
|||
static void handleGetText(TsChannelBase* tsChannel) {
|
||||
tsState.textCommandCounter++;
|
||||
|
||||
printOverallStatus(getTimeNowSeconds());
|
||||
printOverallStatus();
|
||||
|
||||
size_t outputSize;
|
||||
const char* output = swapOutputBuffers(&outputSize);
|
||||
|
|
|
@ -108,14 +108,6 @@ int warningEnabled = true;
|
|||
extern int maxTriggerReentrant;
|
||||
extern uint32_t maxLockedDuration;
|
||||
|
||||
|
||||
#if !defined(STATUS_LOGGING_BUFFER_SIZE)
|
||||
#define STATUS_LOGGING_BUFFER_SIZE 1800
|
||||
#endif /* STATUS_LOGGING_BUFFER_SIZE */
|
||||
|
||||
static char LOGGING_BUFFER[STATUS_LOGGING_BUFFER_SIZE];
|
||||
static Logging logger("status loop", LOGGING_BUFFER, sizeof(LOGGING_BUFFER));
|
||||
|
||||
static void setWarningEnabled(int value) {
|
||||
warningEnabled = value;
|
||||
}
|
||||
|
@ -156,12 +148,22 @@ static int packEngineMode() {
|
|||
static int prevCkpEventCounter = -1;
|
||||
|
||||
/**
|
||||
* Time when the firmware version was reported last time, in seconds
|
||||
* Time when the firmware version was last reported
|
||||
* TODO: implement a request/response instead of just constantly sending this out
|
||||
*/
|
||||
static systime_t timeOfPreviousPrintVersion = 0;
|
||||
static Timer printVersionTimer;
|
||||
|
||||
#if EFI_PROD_CODE
|
||||
static void printRusefiVersion(const char *engineTypeName, const char *firmwareBuildId) {
|
||||
// VersionChecker in rusEFI console is parsing these version string, please follow the expected format
|
||||
efiPrintfProto(PROTOCOL_VERSION_TAG, "%d@%s %s %s %d",
|
||||
getRusEfiVersion(), VCS_VERSION,
|
||||
firmwareBuildId,
|
||||
engineTypeName,
|
||||
getTimeNowSeconds());
|
||||
}
|
||||
|
||||
// Inform the console about the mapping between a pin's logical name (for example, injector 3)
|
||||
// and the physical MCU pin backing that function (for example, PE3)
|
||||
static void printOutPin(const char *pinName, brain_pin_e hwPin) {
|
||||
if (hwPin == GPIO_UNASSIGNED || hwPin == GPIO_INVALID) {
|
||||
return;
|
||||
|
@ -172,29 +174,14 @@ static void printOutPin(const char *pinName, brain_pin_e hwPin) {
|
|||
} else {
|
||||
hwPinName = "smart";
|
||||
}
|
||||
logger.appendPrintf(PROTOCOL_OUTPIN LOG_DELIMITER "%s@%s" LOG_DELIMITER, pinName, hwPinName);
|
||||
|
||||
efiPrintfProto(PROTOCOL_OUTPIN, "%s@%s", pinName, hwPinName);
|
||||
}
|
||||
#endif /* EFI_PROD_CODE */
|
||||
|
||||
void printOverallStatus(efitimesec_t nowSeconds) {
|
||||
#if EFI_ENGINE_SNIFFER
|
||||
waveChart.publishIfFull();
|
||||
#endif /* EFI_ENGINE_SNIFFER */
|
||||
|
||||
#if EFI_SENSOR_CHART
|
||||
publishSensorChartIfFull();
|
||||
#endif // EFI_SENSOR_CHART
|
||||
|
||||
/**
|
||||
* we report the version every 4 seconds - this way the console does not need to
|
||||
* request it and we will display it pretty soon
|
||||
*/
|
||||
if (overflowDiff(nowSeconds, timeOfPreviousPrintVersion) < 4) {
|
||||
return;
|
||||
}
|
||||
timeOfPreviousPrintVersion = nowSeconds;
|
||||
int seconds = getTimeNowSeconds();
|
||||
printCurrentState(&logger, seconds, getEngine_type_e(engineConfiguration->engineType), FIRMWARE_ID);
|
||||
// Print out the current mapping between logical and physical pins that
|
||||
// the engine sniffer cares about, so we can display a physical pin
|
||||
// in each engine sniffer row
|
||||
static void printEngineSnifferPinMappings() {
|
||||
#if EFI_PROD_CODE
|
||||
printOutPin(PROTOCOL_CRANK1, engineConfiguration->triggerInputPins[0]);
|
||||
printOutPin(PROTOCOL_CRANK2, engineConfiguration->triggerInputPins[1]);
|
||||
|
@ -218,13 +205,46 @@ void printOverallStatus(efitimesec_t nowSeconds) {
|
|||
for (int i = 0; i < AUX_DIGITAL_VALVE_COUNT;i++) {
|
||||
printOutPin(enginePins.auxValve[i].getShortName(), engineConfiguration->auxValves[i]);
|
||||
}
|
||||
|
||||
#endif /* EFI_PROD_CODE */
|
||||
scheduleLogging(&logger);
|
||||
}
|
||||
|
||||
void printOverallStatus() {
|
||||
#if EFI_ENGINE_SNIFFER
|
||||
waveChart.publishIfFull();
|
||||
#endif /* EFI_ENGINE_SNIFFER */
|
||||
|
||||
#if EFI_SENSOR_CHART
|
||||
publishSensorChartIfFull();
|
||||
#endif // EFI_SENSOR_CHART
|
||||
|
||||
/**
|
||||
* we report the version every second - this way the console does not need to
|
||||
* request it and we will display it pretty soon
|
||||
*/
|
||||
if (printVersionTimer.hasElapsedSec(1)) {
|
||||
// we're sending, reset the timer
|
||||
printVersionTimer.reset();
|
||||
|
||||
// Output the firmware version, board type, git hash, uptime in seconds, etc
|
||||
printRusefiVersion(getEngine_type_e(engineConfiguration->engineType), FIRMWARE_ID);
|
||||
|
||||
// Output the current engine sniffer pin mappings
|
||||
printEngineSnifferPinMappings();
|
||||
}
|
||||
}
|
||||
|
||||
static systime_t timeOfPreviousReport = (systime_t) -1;
|
||||
|
||||
#if !defined(LOGIC_ANALYZER_BUFFER_SIZE)
|
||||
// TODO: how small can this be?
|
||||
#define LOGIC_ANALYZER_BUFFER_SIZE 1000
|
||||
#endif /* LOGIC_ANALYZER_BUFFER_SIZE */
|
||||
|
||||
#if EFI_LOGIC_ANALYZER
|
||||
static char logicAnalyzerBuffer[LOGIC_ANALYZER_BUFFER_SIZE];
|
||||
static Logging logicAnalyzerLogger("logic analyzer", logicAnalyzerBuffer, sizeof(logicAnalyzerBuffer));
|
||||
#endif // EFI_LOGIC_ANALYZER
|
||||
|
||||
/**
|
||||
* @brief Sends all pending data to rusEfi console
|
||||
*
|
||||
|
@ -266,10 +286,9 @@ void updateDevConsoleState(void) {
|
|||
#endif
|
||||
|
||||
#if EFI_LOGIC_ANALYZER
|
||||
printWave(&logger);
|
||||
printWave(&logicAnalyzerLogger);
|
||||
scheduleLogging(&logicAnalyzerLogger);
|
||||
#endif /* EFI_LOGIC_ANALYZER */
|
||||
|
||||
scheduleLogging(&logger);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -16,4 +16,4 @@ void initStatusLoop(void);
|
|||
|
||||
struct Writer;
|
||||
void writeLogLine(Writer& buffer);
|
||||
void printOverallStatus(efitimesec_t nowSeconds);
|
||||
void printOverallStatus();
|
||||
|
|
|
@ -196,15 +196,6 @@ void EngineState::updateTChargeK(int rpm, float tps) {
|
|||
#define VCS_VERSION "123"
|
||||
#endif
|
||||
|
||||
void printCurrentState(Logging *logging, int seconds, const char *engineTypeName, const char *firmwareBuildId) {
|
||||
// VersionChecker in rusEFI console is parsing these version string, please follow the expected format
|
||||
logging->appendPrintf(PROTOCOL_VERSION_TAG LOG_DELIMITER "%d@%s %s %s %d" LOG_DELIMITER,
|
||||
getRusEfiVersion(), VCS_VERSION,
|
||||
firmwareBuildId,
|
||||
engineTypeName,
|
||||
seconds);
|
||||
}
|
||||
|
||||
void TriggerConfiguration::update() {
|
||||
UseOnlyRisingEdgeForTrigger = isUseOnlyRisingEdgeForTrigger();
|
||||
VerboseTriggerSynchDetails = isVerboseTriggerSynchDetails();
|
||||
|
|
|
@ -18,5 +18,3 @@ void initStartStopButton();
|
|||
void initDataStructures();
|
||||
|
||||
void slowStartStopButtonCallback();
|
||||
|
||||
void printCurrentState(Logging *logging, int seconds, const char *engineTypeName, const char *firmwareBuildId);
|
||||
|
|
|
@ -38,10 +38,6 @@ extern int waveChartUsedSize;
|
|||
extern WaveChart waveChart;
|
||||
#endif /* EFI_ENGINE_SNIFFER */
|
||||
|
||||
#if !defined(SETTINGS_LOGGING_BUFFER_SIZE)
|
||||
#define SETTINGS_LOGGING_BUFFER_SIZE 1000
|
||||
#endif /* SETTINGS_LOGGING_BUFFER_SIZE */
|
||||
|
||||
void printSpiState(const engine_configuration_s *engineConfiguration) {
|
||||
efiPrintf("spi 1=%s/2=%s/3=%s/4=%s",
|
||||
boolToString(engineConfiguration->is_enabled_spi_1),
|
||||
|
|
|
@ -47,9 +47,6 @@
|
|||
*/
|
||||
#define DEEP_IN_THE_PAST_SECONDS -10
|
||||
|
||||
// todo: implement a function to work with times considering counter overflow
|
||||
#define overflowDiff(now, time) ((now) - (time))
|
||||
|
||||
#ifdef __cplusplus
|
||||
/**
|
||||
* Provide a 62-bit counter from a 32-bit counter source that wraps around.
|
||||
|
|
|
@ -23,7 +23,8 @@ namespace priv
|
|||
|
||||
// "normal" logging messages need a header and footer, so put them in
|
||||
// the format string at compile time
|
||||
#define efiPrintf(fmt, ...) priv::efiPrintfInternal(PROTOCOL_MSG LOG_DELIMITER fmt LOG_DELIMITER, ##__VA_ARGS__)
|
||||
#define efiPrintfProto(proto, fmt, ...) priv::efiPrintfInternal(proto LOG_DELIMITER fmt LOG_DELIMITER, ##__VA_ARGS__)
|
||||
#define efiPrintf(fmt, ...) efiPrintfProto(PROTOCOL_MSG, fmt, ##__VA_ARGS__)
|
||||
|
||||
/**
|
||||
* This is the legacy function to copy the contents of a local Logging object in to the output buffer
|
||||
|
|
|
@ -482,15 +482,6 @@ int getRusEfiVersion(void) {
|
|||
return 776655;
|
||||
}
|
||||
|
||||
TEST(util, datalogging) {
|
||||
char LOGGING_BUFFER[1000];
|
||||
Logging logger("settings control", LOGGING_BUFFER, sizeof(LOGGING_BUFFER));
|
||||
|
||||
printCurrentState(&logger, 239, "DEFAULT_FRANKENSO", "ID");
|
||||
// printf("Got [%s]\r\n", LOGGING_BUFFER);
|
||||
// ASSERT_STREQ("rusEfiVersion,776655@321ID DEFAULT_FRANKENSO 239,", LOGGING_BUFFER);
|
||||
}
|
||||
|
||||
TEST(util, PeakDetect) {
|
||||
constexpr int startTime = 50;
|
||||
constexpr int timeout = 100;
|
||||
|
|
Loading…
Reference in New Issue