better error code enum names & minor binary protocol test command fix

This commit is contained in:
rusefi 2017-03-05 14:13:47 -05:00
parent 187e73f4ca
commit a0d0f8ac79
10 changed files with 33 additions and 29 deletions

View File

@ -597,18 +597,22 @@ void handleOutputChannelsCommand(ts_channel_s *tsChannel, ts_response_format_e m
tsSendResponse(tsChannel, mode, (const uint8_t *) &tsOutputChannels, sizeof(TunerStudioOutputChannels)); tsSendResponse(tsChannel, mode, (const uint8_t *) &tsOutputChannels, sizeof(TunerStudioOutputChannels));
} }
#define TEST_RESPONSE_TAG " ts_p_alive\r\n"
void handleTestCommand(ts_channel_s *tsChannel) { void handleTestCommand(ts_channel_s *tsChannel) {
// static char warningCodeBuff[7];
/** /**
* this is NOT a standard TunerStudio command, this is my own * this is NOT a standard TunerStudio command, this is my own
* extension of the protocol to simplify troubleshooting * extension of the protocol to simplify troubleshooting
*/ */
tunerStudioDebug("got T (Test)"); tunerStudioDebug("got T (Test)");
tunerStudioWriteData(tsChannel, (const uint8_t *) VCS_VERSION, sizeof(VCS_VERSION)); tunerStudioWriteData(tsChannel, (const uint8_t *) VCS_VERSION, sizeof(VCS_VERSION));
// itoa10(warningCodeBuff, engine->engineState.lastErrorCode);
/** /**
* Please note that this response is a magic constant used by dev console for protocol detection * Please note that this response is a magic constant used by dev console for protocol detection
* @see EngineState#TS_PROTOCOL_TAG * @see EngineState#TS_PROTOCOL_TAG
*/ */
tunerStudioWriteData(tsChannel, (const uint8_t *) " ts_p_alive\r\n", 8); tunerStudioWriteData(tsChannel, (const uint8_t *) TEST_RESPONSE_TAG, sizeof(TEST_RESPONSE_TAG));
} }
extern CommandHandler console_line_callback; extern CommandHandler console_line_callback;
@ -795,10 +799,10 @@ int tunerStudioHandleCrcCommand(ts_channel_s *tsChannel, char *data, int incomin
void startTunerStudioConnectivity(void) { void startTunerStudioConnectivity(void) {
if (sizeof(persistent_config_s) != getTunerStudioPageSize(0)) if (sizeof(persistent_config_s) != getTunerStudioPageSize(0))
firmwareError(CUSTOM_OBD_52, "TS page size mismatch: %d/%d", sizeof(persistent_config_s), getTunerStudioPageSize(0)); firmwareError(CUSTOM_OBD_TS_PAGE_MISMATCH, "TS page size mismatch: %d/%d", sizeof(persistent_config_s), getTunerStudioPageSize(0));
if (sizeof(TunerStudioOutputChannels) != TS_OUTPUT_SIZE) if (sizeof(TunerStudioOutputChannels) != TS_OUTPUT_SIZE)
firmwareError(CUSTOM_OBD_53, "TS outputs size mismatch: %d/%d", sizeof(TunerStudioOutputChannels), TS_OUTPUT_SIZE); firmwareError(CUSTOM_OBD_TS_OUTPUT_MISMATCH, "TS outputs size mismatch: %d/%d", sizeof(TunerStudioOutputChannels), TS_OUTPUT_SIZE);
memset(&tsState, 0, sizeof(tsState)); memset(&tsState, 0, sizeof(tsState));
syncTunerStudioCopy(); syncTunerStudioCopy();

View File

@ -36,7 +36,7 @@ static void myfatal(void) {
} }
static void myerror(void) { static void myerror(void) {
firmwareError(CUSTOM_ERR_6107, "firmwareError: %d", getRusEfiVersion()); firmwareError(CUSTOM_ERR_TEST_ERROR, "firmwareError: %d", getRusEfiVersion());
} }
static void sayNothing(void) { static void sayNothing(void) {

View File

@ -63,8 +63,8 @@ int getRusEfiVersion(void);
* is stopped. Please use firmwareWarning() instead * is stopped. Please use firmwareWarning() instead
*/ */
#if EFI_ENABLE_ASSERTS #if EFI_ENABLE_ASSERTS
#define efiAssert(condition, message, result) { if (!(condition)) { firmwareError(CUSTOM_ERR_6500, message); return result; } } #define efiAssert(condition, message, result) { if (!(condition)) { firmwareError(CUSTOM_ERR_ASSERT, message); return result; } }
#define efiAssertVoid(condition, message) { if (!(condition)) { firmwareError(CUSTOM_ERR_6501, message); return; } } #define efiAssertVoid(condition, message) { if (!(condition)) { firmwareError(CUSTOM_ERR_ASSERT_VOID, message); return; } }
#else /* EFI_ENABLE_ASSERTS */ #else /* EFI_ENABLE_ASSERTS */
#define efiAssert(condition, message, result) { } #define efiAssert(condition, message, result) { }
#define efiAssertVoid(condition, message) { } #define efiAssertVoid(condition, message) { }

View File

@ -1745,8 +1745,8 @@ typedef enum {
*/ */
CUSTOM_TOO_LONG_FUEL_INJECTION = 6050, CUSTOM_TOO_LONG_FUEL_INJECTION = 6050,
CUSTOM_OBD_ZERO_CYLINDER_COUNT = 6051, CUSTOM_OBD_ZERO_CYLINDER_COUNT = 6051,
CUSTOM_OBD_52 = 6052, CUSTOM_OBD_TS_PAGE_MISMATCH = 6052,
CUSTOM_OBD_53 = 6053, CUSTOM_OBD_TS_OUTPUT_MISMATCH = 6053,
CUSTOM_OBD_54 = 6054, CUSTOM_OBD_54 = 6054,
CUSTOM_OBD_55 = 6055, CUSTOM_OBD_55 = 6055,
CUSTOM_OBD_56 = 6056, CUSTOM_OBD_56 = 6056,
@ -1805,7 +1805,7 @@ typedef enum {
CUSTOM_ERR_INVALID_INJECTION_MODE = 6104, CUSTOM_ERR_INVALID_INJECTION_MODE = 6104,
CUSTOM_ERR_WAVE_1 = 6105, CUSTOM_ERR_WAVE_1 = 6105,
CUSTOM_ERR_WAVE_2 = 6106, CUSTOM_ERR_WAVE_2 = 6106,
CUSTOM_ERR_6107 = 6107, CUSTOM_ERR_TEST_ERROR = 6107,
CUSTOM_ERR_6108 = 6108, CUSTOM_ERR_6108 = 6108,
CUSTOM_ERR_6109 = 6109, CUSTOM_ERR_6109 = 6109,
@ -1821,7 +1821,7 @@ typedef enum {
CUSTOM_ERR_NO_SHAPE = 6119, CUSTOM_ERR_NO_SHAPE = 6119,
CUSTOM_ERR_TRIGGER_SYNC = 6120, CUSTOM_ERR_TRIGGER_SYNC = 6120,
CUSTOM_ERR_6121 = 6121, CUSTOM_ERR_SGTP_ARGUMENT = 6121,
CUSTOM_ERR_6122 = 6122, CUSTOM_ERR_6122 = 6122,
CUSTOM_ERR_6123 = 6123, CUSTOM_ERR_6123 = 6123,
CUSTOM_ERR_6124 = 6124, CUSTOM_ERR_6124 = 6124,
@ -1846,32 +1846,32 @@ typedef enum {
CUSTOM_ERR_FLASH_CRC_FAILED = 6141, CUSTOM_ERR_FLASH_CRC_FAILED = 6141,
CUSTOM_ERR_NOT_INPUT_PIN = 6142, CUSTOM_ERR_NOT_INPUT_PIN = 6142,
CUSTOM_ERR_SKIPPED_TOOTH_SHAPE = 6143, CUSTOM_ERR_SKIPPED_TOOTH_SHAPE = 6143,
CUSTOM_ERR_6144 = 6144, CUSTOM_ERR_UNEXPECTED_SHAFT_EVENT = 6144,
CUSTOM_ERR_6145 = 6145, CUSTOM_ERR_SD_MOUNT_FAILED = 6145,
CUSTOM_ERR_6146 = 6146, CUSTOM_ERR_SD_SEEK_FAILED = 6146,
CUSTOM_ERR_6147 = 6147, CUSTOM_ERR_6147 = 6147,
CUSTOM_ERR_6148 = 6148, CUSTOM_ERR_6148 = 6148,
CUSTOM_OUT_OF_ORDER_COIL = 6149, CUSTOM_OUT_OF_ORDER_COIL = 6149,
CUSTOM_ERR_6500 = 6500, CUSTOM_ERR_ASSERT = 6500,
CUSTOM_ERR_6501 = 6501, CUSTOM_ERR_ASSERT_VOID = 6501,
CUSTOM_ERR_6502 = 6502, CUSTOM_ERR_6502 = 6502,
CUSTOM_ERR_6503 = 6503, CUSTOM_ERR_FSIO_POOL = 6503,
CUSTOM_ERR_6504 = 6504, CUSTOM_ERR_6504 = 6504,
CUSTOM_ERR_6505 = 6505, CUSTOM_ERR_6505 = 6505,
CUSTOM_ERR_6506 = 6506, CUSTOM_ERR_6506 = 6506,
CUSTOM_ERR_6507 = 6507, CUSTOM_ERR_6507 = 6507,
CUSTOM_ERR_6508 = 6508, CUSTOM_ERR_6508 = 6508,
CUSTOM_ERR_6509 = 6509, CUSTOM_ERR_6509 = 6509,
CUSTOM_ERR_6510 = 6510, CUSTOM_ERR_TRG_ANGLE_ORDER = 6510,
CUSTOM_ERR_6511 = 6511, CUSTOM_ERR_STATE_NULL = 6511,
CUSTOM_ERR_6512 = 6512, CUSTOM_ERR_6512 = 6512,
CUSTOM_ERR_6513 = 6513, CUSTOM_ERR_6513 = 6513,
CUSTOM_ERR_6514 = 6514, CUSTOM_ERR_6514 = 6514,
CUSTOM_ERR_6515 = 6515, CUSTOM_ERR_6515 = 6515,
CUSTOM_ERR_6516 = 6516, CUSTOM_ERR_6516 = 6516,
CUSTOM_ERR_6517 = 6517, CUSTOM_ERR_ADC_USED = 6517,
CUSTOM_ERR_6518 = 6518, CUSTOM_ERR_ADC_DEPTH = 6518,
CUSTOM_ERR_6519 = 6519, CUSTOM_ERR_6519 = 6519,
CUSTOM_ERR_6520 = 6520, CUSTOM_ERR_6520 = 6520,
CUSTOM_ERR_6521 = 6521, CUSTOM_ERR_6521 = 6521,

View File

@ -357,7 +357,7 @@ int LEElementPool::getSize() {
LEElement *LEElementPool::next() { LEElement *LEElementPool::next() {
if (index >= size) { if (index >= size) {
// todo: this should not be a fatal error, just an error // todo: this should not be a fatal error, just an error
firmwareError(CUSTOM_ERR_6503, "LE_ELEMENT_POOL_SIZE overflow"); firmwareError(CUSTOM_ERR_FSIO_POOL, "LE_ELEMENT_POOL_SIZE overflow");
return NULL; return NULL;
} }
LEElement *result = &pool[index++]; LEElement *result = &pool[index++];

View File

@ -467,7 +467,7 @@ static void setCrankingFuel(float timeMs) {
static void setGlobalTriggerAngleOffset(float value) { static void setGlobalTriggerAngleOffset(float value) {
if (cisnan(value)) { if (cisnan(value)) {
warning(CUSTOM_ERR_6121, "Invalid argument"); warning(CUSTOM_ERR_SGTP_ARGUMENT, "Invalid argument");
return; return;
} }
engineConfiguration->globalTriggerAngleOffset = value; engineConfiguration->globalTriggerAngleOffset = value;

View File

@ -224,7 +224,7 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal DECLARE_ENGINE_PAR
if (triggerShape.shapeDefinitionError) { if (triggerShape.shapeDefinitionError) {
// trigger is broken, we cannot do anything here // trigger is broken, we cannot do anything here
warning(CUSTOM_ERR_6144, "Shaft event while trigger is mis-configured"); warning(CUSTOM_ERR_UNEXPECTED_SHAFT_EVENT, "Shaft event while trigger is mis-configured");
return; return;
} }

View File

@ -316,7 +316,7 @@ void TriggerShape::addEvent2(angle_t angle, trigger_wheel_e const waveIndex, tri
efiAssertVoid(angle > 0, "angle should be positive"); efiAssertVoid(angle > 0, "angle should be positive");
if (size > 0) { if (size > 0) {
if (angle <= previousAngle) { if (angle <= previousAngle) {
firmwareError(CUSTOM_ERR_6510, "invalid angle order: %f and %f, size=%d", angle, previousAngle, size); firmwareError(CUSTOM_ERR_TRG_ANGLE_ORDER, "invalid angle order: %f and %f, size=%d", angle, previousAngle, size);
return; return;
} }
} }
@ -327,7 +327,7 @@ void TriggerShape::addEvent2(angle_t angle, trigger_wheel_e const waveIndex, tri
single_wave_s *wave = &this->wave.waves[i]; single_wave_s *wave = &this->wave.waves[i];
if (wave->pinStates == NULL) { if (wave->pinStates == NULL) {
firmwareError(CUSTOM_ERR_6511, "wave pinStates is NULL"); firmwareError(CUSTOM_ERR_STATE_NULL, "wave pinStates is NULL");
return; return;
} }
wave->pinStates[0] = initialState[i]; wave->pinStates[0] = initialState[i];

View File

@ -512,7 +512,7 @@ static void addChannel(const char *name, adc_channel_e setting, adc_channel_mode
} }
if (adcHwChannelEnabled[setting] != ADC_OFF) { if (adcHwChannelEnabled[setting] != ADC_OFF) {
getPinNameByAdcChannel(name, setting, errorMsgBuff); getPinNameByAdcChannel(name, setting, errorMsgBuff);
firmwareError(CUSTOM_ERR_6517, "ADC mapping error: input %s for %s already used by %s?", errorMsgBuff, name, adcHwChannelUsage[setting]); firmwareError(CUSTOM_ERR_ADC_USED, "ADC mapping error: input %s for %s already used by %s?", errorMsgBuff, name, adcHwChannelUsage[setting]);
} }
adcHwChannelUsage[setting] = name; adcHwChannelUsage[setting] = name;
@ -549,7 +549,7 @@ void initAdcInputs(bool boardTestMode) {
if (ADC_BUF_DEPTH_FAST > MAX_ADC_GRP_BUF_DEPTH) if (ADC_BUF_DEPTH_FAST > MAX_ADC_GRP_BUF_DEPTH)
firmwareError(CUSTOM_ERR_6519, "ADC_BUF_DEPTH_FAST too high"); firmwareError(CUSTOM_ERR_6519, "ADC_BUF_DEPTH_FAST too high");
if (ADC_BUF_DEPTH_SLOW > MAX_ADC_GRP_BUF_DEPTH) if (ADC_BUF_DEPTH_SLOW > MAX_ADC_GRP_BUF_DEPTH)
firmwareError(CUSTOM_ERR_6518, "ADC_BUF_DEPTH_SLOW too high"); firmwareError(CUSTOM_ERR_ADC_DEPTH, "ADC_BUF_DEPTH_SLOW too high");
configureInputs(); configureInputs();

View File

@ -178,7 +178,7 @@ static void createLogFile(void) {
if (err != FR_OK && err != FR_EXIST) { if (err != FR_OK && err != FR_EXIST) {
unlockSpi(); unlockSpi();
sdStatus = SD_STATE_OPEN_FAILED; sdStatus = SD_STATE_OPEN_FAILED;
warning(CUSTOM_ERR_6145, "SD: mount failed"); warning(CUSTOM_ERR_SD_MOUNT_FAILED, "SD: mount failed");
printError("FS mount failed", err); // else - show error printError("FS mount failed", err); // else - show error
return; return;
} }
@ -187,7 +187,7 @@ static void createLogFile(void) {
if (err) { if (err) {
unlockSpi(); unlockSpi();
sdStatus = SD_STATE_SEEK_FAILED; sdStatus = SD_STATE_SEEK_FAILED;
warning(CUSTOM_ERR_6146, "SD: seek failed"); warning(CUSTOM_ERR_SD_SEEK_FAILED, "SD: seek failed");
printError("Seek error", err); printError("Seek error", err);
return; return;
} }