auto-sync
This commit is contained in:
parent
e6a6b26d86
commit
93072c913c
|
@ -86,84 +86,119 @@ static void setWarningEnabled(int value) {
|
||||||
static Logging fileLogger;
|
static Logging fileLogger;
|
||||||
#endif /* EFI_FILE_LOGGING */
|
#endif /* EFI_FILE_LOGGING */
|
||||||
|
|
||||||
static void reportSensorF(const char *caption, float value, int precision) {
|
static int logFileLineIndex = 0;
|
||||||
|
#define TAB "\t"
|
||||||
|
|
||||||
|
static void reportSensorF(Logging *log, bool fileFormat, const char *caption, const char *units, float value,
|
||||||
|
int precision) {
|
||||||
|
if (!fileFormat) {
|
||||||
#if (EFI_PROD_CODE || EFI_SIMULATOR) || defined(__DOXYGEN__)
|
#if (EFI_PROD_CODE || EFI_SIMULATOR) || defined(__DOXYGEN__)
|
||||||
debugFloat(&logger, caption, value, precision);
|
debugFloat(log, caption, value, precision);
|
||||||
#endif /* EFI_PROD_CODE || EFI_SIMULATOR */
|
#endif /* EFI_PROD_CODE || EFI_SIMULATOR */
|
||||||
|
} else {
|
||||||
|
|
||||||
#if EFI_FILE_LOGGING || defined(__DOXYGEN__)
|
#if EFI_FILE_LOGGING || defined(__DOXYGEN__)
|
||||||
debugFloat(&fileLogger, caption, value, precision);
|
if (logFileLineIndex == 0) {
|
||||||
|
append(log, caption);
|
||||||
|
append(log, TAB);
|
||||||
|
} else if (logFileLineIndex == 1) {
|
||||||
|
append(log, units);
|
||||||
|
append(log, TAB);
|
||||||
|
} else {
|
||||||
|
appendFloat(log, value, precision);
|
||||||
|
append(log, TAB);
|
||||||
|
}
|
||||||
#endif /* EFI_FILE_LOGGING */
|
#endif /* EFI_FILE_LOGGING */
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void reportSensorI(Logging *log, bool fileFormat, const char *caption, const char *units, int value) {
|
||||||
|
if (!fileFormat) {
|
||||||
|
|
||||||
static void reportSensorI(const char *caption, int value) {
|
|
||||||
#if (EFI_PROD_CODE || EFI_SIMULATOR) || defined(__DOXYGEN__)
|
#if (EFI_PROD_CODE || EFI_SIMULATOR) || defined(__DOXYGEN__)
|
||||||
debugInt(&logger, caption, value);
|
debugInt(log, caption, value);
|
||||||
#endif /* EFI_PROD_CODE || EFI_SIMULATOR */
|
#endif /* EFI_PROD_CODE || EFI_SIMULATOR */
|
||||||
|
} else {
|
||||||
#if EFI_FILE_LOGGING || defined(__DOXYGEN__)
|
#if EFI_FILE_LOGGING || defined(__DOXYGEN__)
|
||||||
debugInt(&fileLogger, caption, value);
|
if (logFileLineIndex == 0) {
|
||||||
|
append(log, caption);
|
||||||
|
append(log, TAB);
|
||||||
|
} else if (logFileLineIndex == 1) {
|
||||||
|
append(log, units);
|
||||||
|
append(log, TAB);
|
||||||
|
} else {
|
||||||
|
appendPrintf(log, "%d%s", value, TAB);
|
||||||
|
}
|
||||||
#endif /* EFI_FILE_LOGGING */
|
#endif /* EFI_FILE_LOGGING */
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static const char* boolean2string(int value) {
|
static const char* boolean2string(int value) {
|
||||||
return value ? "YES" : "NO";
|
return value ? "YES" : "NO";
|
||||||
}
|
}
|
||||||
|
|
||||||
void printSensors(Engine *engine) {
|
void printSensors(Logging *log, bool fileFormat, Engine *engine) {
|
||||||
#if EFI_FILE_LOGGING || defined(__DOXYGEN__)
|
|
||||||
resetLogging(&fileLogger);
|
|
||||||
#endif /* EFI_FILE_LOGGING */
|
|
||||||
|
|
||||||
// current time, in milliseconds
|
// current time, in milliseconds
|
||||||
int nowMs = currentTimeMillis();
|
int nowMs = currentTimeMillis();
|
||||||
float sec = ((float) nowMs) / 1000;
|
float sec = ((float) nowMs) / 1000;
|
||||||
reportSensorF("time", sec, 3);
|
reportSensorF(log, fileFormat, "time", "", sec, 3);
|
||||||
|
|
||||||
reportSensorI("rpm", getRpmE(engine));
|
reportSensorI(log, fileFormat, "rpm", "RPM", getRpmE(engine));
|
||||||
reportSensorF("maf", getMaf(), 2);
|
reportSensorF(log, fileFormat, "maf", "V", getMaf(), 2);
|
||||||
|
|
||||||
engine_configuration_s *engineConfiguration = engine->engineConfiguration;
|
engine_configuration_s *engineConfiguration = engine->engineConfiguration;
|
||||||
|
|
||||||
if (engineConfiguration->hasMapSensor) {
|
if (engineConfiguration->hasMapSensor) {
|
||||||
reportSensorF(getCaption(LP_MAP), getMap(), 2);
|
reportSensorF(log, fileFormat, "MAP", "kPa", getMap(), 2);
|
||||||
reportSensorF("map_r", getRawMap(), 2);
|
reportSensorF(log, fileFormat, "map_r", "V", getRawMap(), 2);
|
||||||
}
|
}
|
||||||
if (engineConfiguration->hasBaroSensor) {
|
if (engineConfiguration->hasBaroSensor) {
|
||||||
reportSensorF("baro", getBaroPressure(), 2);
|
reportSensorF(log, fileFormat, "baro", "kPa", getBaroPressure(), 2);
|
||||||
}
|
}
|
||||||
if (engineConfiguration->hasAfrSensor) {
|
if (engineConfiguration->hasAfrSensor) {
|
||||||
reportSensorF("afr", getAfr(), 2);
|
reportSensorF(log, fileFormat, "afr", "AFR", getAfr(), 2);
|
||||||
}
|
}
|
||||||
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
||||||
if (engineConfiguration->hasVehicleSpeedSensor) {
|
if (engineConfiguration->hasVehicleSpeedSensor) {
|
||||||
reportSensorF("vss", getVehicleSpeed(), 2);
|
reportSensorF(log, fileFormat, "vss", "kph", getVehicleSpeed(), 2);
|
||||||
}
|
}
|
||||||
#endif /* EFI_PROD_CODE */
|
#endif /* EFI_PROD_CODE */
|
||||||
reportSensorF("vref", getVRef(engineConfiguration), 2);
|
reportSensorF(log, fileFormat, "vref", "V", getVRef(engineConfiguration), 2);
|
||||||
reportSensorF("vbatt", getVBatt(engineConfiguration), 2);
|
reportSensorF(log, fileFormat, "vbatt", "V", getVBatt(engineConfiguration), 2);
|
||||||
|
|
||||||
reportSensorF("TRG_0_DUTY", getTriggerDutyCycle(0), 2);
|
reportSensorF(log, fileFormat, "TRG_0_DUTY", "%", getTriggerDutyCycle(0), 2);
|
||||||
reportSensorF("TRG_1_DUTY", getTriggerDutyCycle(1), 2);
|
reportSensorF(log, fileFormat, "TRG_1_DUTY", "%", getTriggerDutyCycle(1), 2);
|
||||||
|
|
||||||
reportSensorF(getCaption(LP_THROTTLE), getTPS(PASS_ENGINE_PARAMETER_F), 2);
|
reportSensorF(log, fileFormat, "TP", "%", getTPS(PASS_ENGINE_PARAMETER_F), 2);
|
||||||
|
|
||||||
if (engineConfiguration->hasCltSensor) {
|
if (engineConfiguration->hasCltSensor) {
|
||||||
reportSensorF(getCaption(LP_ECT), getCoolantTemperature(engine), 2);
|
reportSensorF(log, fileFormat, "CLT", "C", getCoolantTemperature(engine), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
reportSensorF(getCaption(LP_IAT), getIntakeAirTemperature(engine), 2);
|
reportSensorF(log, fileFormat, "MAT", "C", getIntakeAirTemperature(engine), 2);
|
||||||
|
|
||||||
// debugFloat(&logger, "tch", getTCharge1(tps), 2);
|
// debugFloat(&logger, "tch", getTCharge1(tps), 2);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
EXTERN_ENGINE;
|
||||||
|
|
||||||
|
void writeLogLine(void) {
|
||||||
#if EFI_FILE_LOGGING || defined(__DOXYGEN__)
|
#if EFI_FILE_LOGGING || defined(__DOXYGEN__)
|
||||||
|
resetLogging(&fileLogger);
|
||||||
|
printSensors(&fileLogger, true, engine);
|
||||||
|
|
||||||
|
if (isSdCardAlive()) {
|
||||||
appendPrintf(&fileLogger, "\r\n");
|
appendPrintf(&fileLogger, "\r\n");
|
||||||
appendToLog(fileLogger.buffer);
|
appendToLog(fileLogger.buffer);
|
||||||
|
logFileLineIndex++;
|
||||||
|
}
|
||||||
#endif /* EFI_FILE_LOGGING */
|
#endif /* EFI_FILE_LOGGING */
|
||||||
}
|
}
|
||||||
|
|
||||||
void printState(Engine *engine, int currentCkpEventCounter) {
|
void printState(Engine *engine, int currentCkpEventCounter) {
|
||||||
#if EFI_SHAFT_POSITION_INPUT || defined(__DOXYGEN__)
|
#if EFI_SHAFT_POSITION_INPUT || defined(__DOXYGEN__)
|
||||||
printSensors(engine);
|
printSensors(&logger, false, engine);
|
||||||
|
|
||||||
engine_configuration_s *engineConfiguration = engine->engineConfiguration;
|
engine_configuration_s *engineConfiguration = engine->engineConfiguration;
|
||||||
|
|
||||||
|
@ -358,10 +393,7 @@ OutputPin checkEnginePin;
|
||||||
OutputPin warningPin;
|
OutputPin warningPin;
|
||||||
OutputPin runningPin;
|
OutputPin runningPin;
|
||||||
|
|
||||||
static OutputPin *leds[] = { &warningPin, &runningPin,
|
static OutputPin *leds[] = { &warningPin, &runningPin, &errorLedPin, &communicationPin, &checkEnginePin };
|
||||||
&errorLedPin,
|
|
||||||
&communicationPin,
|
|
||||||
&checkEnginePin };
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method would blink all the LEDs just to test them
|
* This method would blink all the LEDs just to test them
|
||||||
|
@ -441,6 +473,7 @@ static void lcdThread(Engine *engine) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// stack for Tuner Studio thread
|
||||||
static THD_WORKING_AREA(tsThreadStack, UTILITY_THREAD_STACK_SIZE);
|
static THD_WORKING_AREA(tsThreadStack, UTILITY_THREAD_STACK_SIZE);
|
||||||
|
|
||||||
#if EFI_TUNER_STUDIO
|
#if EFI_TUNER_STUDIO
|
||||||
|
@ -541,7 +574,6 @@ void initStatusLoop(Engine *engine) {
|
||||||
#if EFI_FILE_LOGGING
|
#if EFI_FILE_LOGGING
|
||||||
initLogging(&fileLogger, "file logger");
|
initLogging(&fileLogger, "file logger");
|
||||||
#endif /* EFI_FILE_LOGGING */
|
#endif /* EFI_FILE_LOGGING */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void startStatusThreads(Engine *engine) {
|
void startStatusThreads(Engine *engine) {
|
||||||
|
|
|
@ -23,6 +23,7 @@ extern "C"
|
||||||
{
|
{
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
void writeLogLine(void);
|
||||||
bool getFullLog(void);
|
bool getFullLog(void);
|
||||||
void setFullLog(int value);
|
void setFullLog(int value);
|
||||||
void sayOsHello(void);
|
void sayOsHello(void);
|
||||||
|
|
|
@ -675,6 +675,8 @@ static void enableOrDisable(const char *param, bool isEnabled) {
|
||||||
boardConfiguration->isFastAdcEnabled = isEnabled;
|
boardConfiguration->isFastAdcEnabled = isEnabled;
|
||||||
} else if (strEqualCaseInsensitive(param, "joystick")) {
|
} else if (strEqualCaseInsensitive(param, "joystick")) {
|
||||||
engineConfiguration->isJoystickEnabled = isEnabled;
|
engineConfiguration->isJoystickEnabled = isEnabled;
|
||||||
|
} else if (strEqualCaseInsensitive(param, "sd")) {
|
||||||
|
boardConfiguration->isSdCardEnabled = isEnabled;
|
||||||
} else if (strEqualCaseInsensitive(param, "can")) {
|
} else if (strEqualCaseInsensitive(param, "can")) {
|
||||||
engineConfiguration->isCanEnabled = isEnabled;
|
engineConfiguration->isCanEnabled = isEnabled;
|
||||||
} else if (strEqualCaseInsensitive(param, "can_read")) {
|
} else if (strEqualCaseInsensitive(param, "can_read")) {
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "ff.h"
|
#include "ff.h"
|
||||||
#include "hardware.h"
|
#include "hardware.h"
|
||||||
#include "engine_configuration.h"
|
#include "engine_configuration.h"
|
||||||
|
#include "status_loop.h"
|
||||||
|
|
||||||
extern board_configuration_s *boardConfiguration;
|
extern board_configuration_s *boardConfiguration;
|
||||||
|
|
||||||
|
@ -44,7 +45,7 @@ static MMCConfig mmccfg = { &MMC_CARD_SPI, &ls_spicfg, &hs_spicfg };
|
||||||
|
|
||||||
static bool fs_ready = false;
|
static bool fs_ready = false;
|
||||||
|
|
||||||
#define PUSHPULLDELAY 500
|
#define FILE_LOG_DELAY 200
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fatfs MMC/SPI
|
* fatfs MMC/SPI
|
||||||
|
@ -72,6 +73,7 @@ static void printMmcPinout(void) {
|
||||||
|
|
||||||
static void sdStatistics(void) {
|
static void sdStatistics(void) {
|
||||||
printMmcPinout();
|
printMmcPinout();
|
||||||
|
scheduleMsg(&logger, "SD enabled: %s", boolToString(boardConfiguration->isSdCardEnabled));
|
||||||
scheduleMsg(&logger, "fs_ready=%d totalLoggedBytes=%d", fs_ready, totalLoggedBytes);
|
scheduleMsg(&logger, "fs_ready=%d totalLoggedBytes=%d", fs_ready, totalLoggedBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +89,7 @@ static void createLogFile(void) {
|
||||||
FRESULT err = f_open(&FDLogFile, "rusefi.log", FA_OPEN_ALWAYS | FA_WRITE); // Create new file
|
FRESULT err = f_open(&FDLogFile, "rusefi.log", FA_OPEN_ALWAYS | FA_WRITE); // Create new file
|
||||||
if (err != FR_OK && err != FR_EXIST) {
|
if (err != FR_OK && err != FR_EXIST) {
|
||||||
unlockSpi();
|
unlockSpi();
|
||||||
printError("Card mounted...\r\nCan't create Log file, check your SD.\r\nFS mount failed", err); // else - show error
|
printError("FS mount failed", err); // else - show error
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,10 +215,10 @@ static void MMCmount(void) {
|
||||||
}
|
}
|
||||||
unlockSpi();
|
unlockSpi();
|
||||||
// if Ok - mount FS now
|
// if Ok - mount FS now
|
||||||
memset(&MMC_FS, 0, sizeof(FATFS)); // reserve the memory
|
memset(&MMC_FS, 0, sizeof(FATFS));
|
||||||
if (f_mount(0, &MMC_FS) == FR_OK) {
|
if (f_mount(0, &MMC_FS) == FR_OK) {
|
||||||
createLogFile();
|
createLogFile();
|
||||||
scheduleMsg(&logger, "MMC/SD mounted!\r\nDon't forget umountsd before remove to prevent lost your data");
|
scheduleMsg(&logger, "MMC/SD mounted!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,8 +239,10 @@ static msg_t MMCmonThread(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// this thread is activated 10 times per second
|
if (isSdCardAlive())
|
||||||
chThdSleepMilliseconds(PUSHPULLDELAY);
|
writeLogLine();
|
||||||
|
|
||||||
|
chThdSleepMilliseconds(FILE_LOG_DELAY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,6 +252,7 @@ bool isSdCardAlive(void) {
|
||||||
|
|
||||||
void initMmcCard(void) {
|
void initMmcCard(void) {
|
||||||
initLogging(&logger, "mmcCard");
|
initLogging(&logger, "mmcCard");
|
||||||
|
addConsoleAction("sdstat", sdStatistics);
|
||||||
if (!boardConfiguration->isSdCardEnabled) {
|
if (!boardConfiguration->isSdCardEnabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -262,7 +267,6 @@ void initMmcCard(void) {
|
||||||
|
|
||||||
chThdCreateStatic(mmcThreadStack, sizeof(mmcThreadStack), LOWPRIO, (tfunc_t) MMCmonThread, NULL);
|
chThdCreateStatic(mmcThreadStack, sizeof(mmcThreadStack), LOWPRIO, (tfunc_t) MMCmonThread, NULL);
|
||||||
|
|
||||||
addConsoleAction("sdstat", sdStatistics);
|
|
||||||
addConsoleAction("mountsd", MMCmount);
|
addConsoleAction("mountsd", MMCmount);
|
||||||
addConsoleActionS("appendToLog", appendToLog);
|
addConsoleActionS("appendToLog", appendToLog);
|
||||||
addConsoleAction("umountsd", MMCumount);
|
addConsoleAction("umountsd", MMCumount);
|
||||||
|
|
|
@ -634,8 +634,8 @@ fileVersion = { 20141225 }
|
||||||
indicator = { needBurn }, "no Burn", "Need Burn", white, black, red, black
|
indicator = { needBurn }, "no Burn", "Need Burn", white, black, red, black
|
||||||
indicator = { hasSdCard}, "no SD", "with SD", white, black, green, black
|
indicator = { hasSdCard}, "no SD", "with SD", white, black, green, black
|
||||||
indicator = { ind_fuel_pump}, "no pump", "pump", white, black, green, black
|
indicator = { ind_fuel_pump}, "no pump", "pump", white, black, green, black
|
||||||
indicator = { clutchUpState }, "clutch", "c UP", white, black, red, black
|
indicator = { clutchUpState }, "clutch", "cltch Up", white, black, red, black
|
||||||
indicator = { clutchDownState }, "clutch", "c UP", white, black, red, black
|
indicator = { clutchDownState }, "clutch", "cltch Down", white, black, red, black
|
||||||
|
|
||||||
; error codes
|
; error codes
|
||||||
indicator = { ind_tps_error}, "tps", "tps error", white, black, red, black
|
indicator = { ind_tps_error}, "tps", "tps error", white, black, red, black
|
||||||
|
|
|
@ -171,55 +171,6 @@ void appendPrintf(Logging *logging, const char *fmt, ...) {
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: this method does not really belong to this file
|
|
||||||
char* getCaption(LoggingPoints loggingPoint) {
|
|
||||||
switch (loggingPoint) {
|
|
||||||
case LP_RPM:
|
|
||||||
return "RPM";
|
|
||||||
case LP_THROTTLE:
|
|
||||||
return "TP";
|
|
||||||
case LP_IAT:
|
|
||||||
return "MAT";
|
|
||||||
case LP_ECT:
|
|
||||||
return "CLT";
|
|
||||||
// case LP_SECONDS:
|
|
||||||
// return "SecL";
|
|
||||||
case LP_MAF:
|
|
||||||
return "MAF";
|
|
||||||
case LP_MAP:
|
|
||||||
return "MAP";
|
|
||||||
case LP_MAP_RAW:
|
|
||||||
return "MAP_R";
|
|
||||||
default:
|
|
||||||
firmwareError("No such loggingPoint");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
// todo: this method does not really belong to this file
|
|
||||||
static char* get2ndCaption(int loggingPoint) {
|
|
||||||
switch (loggingPoint) {
|
|
||||||
case LP_RPM:
|
|
||||||
return "RPM";
|
|
||||||
case LP_THROTTLE:
|
|
||||||
return "%";
|
|
||||||
case LP_IAT:
|
|
||||||
return "°F";
|
|
||||||
case LP_ECT:
|
|
||||||
return "°F";
|
|
||||||
case LP_SECONDS:
|
|
||||||
return "s";
|
|
||||||
case LP_MAP:
|
|
||||||
return "MAP";
|
|
||||||
case LP_MAF:
|
|
||||||
return "MAF";
|
|
||||||
}
|
|
||||||
firmwareError("No such loggingPoint");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
void initLoggingExt(Logging *logging, const char *name, char *buffer, int bufferSize) {
|
void initLoggingExt(Logging *logging, const char *name, char *buffer, int bufferSize) {
|
||||||
print("Init logging %s\r\n", name);
|
print("Init logging %s\r\n", name);
|
||||||
logging->name = name;
|
logging->name = name;
|
||||||
|
|
|
@ -91,7 +91,6 @@ void appendMsgPostfix(Logging *logging);
|
||||||
void scheduleMsg(Logging *logging, const char *fmt, ...);
|
void scheduleMsg(Logging *logging, const char *fmt, ...);
|
||||||
|
|
||||||
void printMsg(Logging *logging, const char *fmt, ...);
|
void printMsg(Logging *logging, const char *fmt, ...);
|
||||||
char* getCaption(LoggingPoints loggingPoint);
|
|
||||||
void appendPrintf(Logging *logging, const char *fmt, ...);
|
void appendPrintf(Logging *logging, const char *fmt, ...);
|
||||||
void vappendPrintf(Logging *logging, const char *fmt, va_list arg);
|
void vappendPrintf(Logging *logging, const char *fmt, va_list arg);
|
||||||
void append(Logging *logging, const char *text);
|
void append(Logging *logging, const char *text);
|
||||||
|
|
Loading…
Reference in New Issue