From a338d6b7bcb911d4a57b7be7c9ebda8eb6008d2a Mon Sep 17 00:00:00 2001 From: rusefi Date: Tue, 28 Mar 2017 18:30:53 -0400 Subject: [PATCH 01/17] todo --- firmware/controllers/error_handling.cpp | 2 ++ firmware/util/datalogging.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/firmware/controllers/error_handling.cpp b/firmware/controllers/error_handling.cpp index 3fad6fcd4a..0917a31a50 100644 --- a/firmware/controllers/error_handling.cpp +++ b/firmware/controllers/error_handling.cpp @@ -95,6 +95,7 @@ void addWarningCode(obd_code_e code) { engine->engineState.lastErrorCode = code; } +// todo: look into chsnprintf // todo: move to some util file & reuse for 'firmwareError' method void printToStream(MemoryStream *stream, const char *fmt, va_list ap) { stream->eos = 0; // reset @@ -199,6 +200,7 @@ void firmwareError(obd_code_e code, const char *fmt, ...) { strncpy((char*) errorMessageBuffer, fmt, sizeof(errorMessageBuffer) - 1); errorMessageBuffer[sizeof(errorMessageBuffer) - 1] = 0; // just to be sure } else { + // todo: look into chsnprintf once on Chibios 3 firmwareErrorMessageStream.eos = 0; // reset va_list ap; va_start(ap, fmt); diff --git a/firmware/util/datalogging.cpp b/firmware/util/datalogging.cpp index 822d2b62fc..08e856daa7 100644 --- a/firmware/util/datalogging.cpp +++ b/firmware/util/datalogging.cpp @@ -102,6 +102,7 @@ void appendFast(Logging *logging, const char *text) { logging->linePointer += extraLen; } +// todo: look into chsnprintf once on Chibios 3 static void vappendPrintfI(Logging *logging, const char *fmt, va_list arg) { intermediateLoggingBuffer.eos = 0; // reset efiAssertVoid(getRemainingStack(chThdSelf()) > 128, "lowstck#1b"); From 676bedefac0d18d9f64cdf55a7c90aede8f7d1da Mon Sep 17 00:00:00 2001 From: rusefi Date: Tue, 28 Mar 2017 18:59:42 -0400 Subject: [PATCH 02/17] reducing variable name conflict --- firmware/controllers/error_handling.cpp | 8 +++++--- unit_tests/engine_test_helper.cpp | 4 ++-- unit_tests/test_trigger_decoder.cpp | 6 +++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/firmware/controllers/error_handling.cpp b/firmware/controllers/error_handling.cpp index 0917a31a50..2c20ef1190 100644 --- a/firmware/controllers/error_handling.cpp +++ b/firmware/controllers/error_handling.cpp @@ -102,9 +102,11 @@ void printToStream(MemoryStream *stream, const char *fmt, va_list ap) { chvprintf((BaseSequentialStream *) stream, fmt, ap); stream->buffer[stream->eos] = 0; } -#endif +#else +int unitTestWarningCounter = 0; + +#endif /* EFI_SIMULATOR || EFI_PROD_CODE */ -int warningCounter = 0; /** * OBD_PCM_Processor_Fault is the general error code for now @@ -142,7 +144,7 @@ bool warning(obd_code_e code, const char *fmt, ...) { append(&logger, DELIMETER); scheduleLogging(&logger); #else - warningCounter++; + unitTestWarningCounter++; printf("unit_test_warning: "); va_list ap; va_start(ap, fmt); diff --git a/unit_tests/engine_test_helper.cpp b/unit_tests/engine_test_helper.cpp index 8388d37f15..9c437361e4 100644 --- a/unit_tests/engine_test_helper.cpp +++ b/unit_tests/engine_test_helper.cpp @@ -18,11 +18,11 @@ extern int timeNow; extern EnginePins enginePins; extern EventQueue schedulingQueue; -extern int warningCounter; +extern int unitTestWarningCounter; EngineTestHelper::EngineTestHelper(engine_type_e engineType) : engine (&persistentConfig) { ec = &persistentConfig.engineConfiguration; - warningCounter = 0; + unitTestWarningCounter = 0; schedulingQueue.clear(); enginePins.reset(); diff --git a/unit_tests/test_trigger_decoder.cpp b/unit_tests/test_trigger_decoder.cpp index 1598aa35d2..215a229465 100644 --- a/unit_tests/test_trigger_decoder.cpp +++ b/unit_tests/test_trigger_decoder.cpp @@ -35,7 +35,7 @@ extern int timeNow; extern float unitTestValue; extern float testMafValue; -extern int warningCounter; +extern int unitTestWarningCounter; extern bool printTriggerDebug; extern float actualSynchGap; @@ -1240,7 +1240,7 @@ void testMissedSpark299(void) { engineConfiguration->isIgnitionEnabled = true; engineConfiguration->isInjectionEnabled = false; - assertEqualsM("warningCounter#0", 4, warningCounter); + assertEqualsM("warningCounter#0", 4, unitTestWarningCounter); timeNow += MS2US(20); eth.firePrimaryTriggerRise(); @@ -1311,5 +1311,5 @@ void testMissedSpark299(void) { eth.firePrimaryTriggerFall(); schedulingQueue.executeAll(timeNow); - assertEqualsM("warningCounter#1", 5, warningCounter); + assertEqualsM("warningCounter#1", 5, unitTestWarningCounter); } From 376effb394a9e903470266e69c84fae56ec3344a Mon Sep 17 00:00:00 2001 From: rusefi Date: Tue, 28 Mar 2017 19:26:44 -0400 Subject: [PATCH 03/17] removing dead code --- firmware/controllers/error_handling.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/firmware/controllers/error_handling.cpp b/firmware/controllers/error_handling.cpp index 2c20ef1190..e2f32ff744 100644 --- a/firmware/controllers/error_handling.cpp +++ b/firmware/controllers/error_handling.cpp @@ -17,18 +17,12 @@ #include static MemoryStream warningStream; static MemoryStream firmwareErrorMessageStream; -extern OutputPin communicationPin; - -#endif - +#endif /* EFI_SIMULATOR || EFI_PROD_CODE */ #define WARNING_BUFFER_SIZE 80 static char warningBuffer[WARNING_BUFFER_SIZE]; static bool isWarningStreamInitialized = false; - - - #if EFI_HD44780_LCD || defined(__DOXYGEN__) #include "lcd_HD44780.h" #endif /* EFI_HD44780_LCD */ From e539ae75fb4b3075930114c70d70ab7f8203b255 Mon Sep 17 00:00:00 2001 From: rusefi Date: Tue, 28 Mar 2017 19:36:56 -0400 Subject: [PATCH 04/17] chprintf test into simulator --- .../simulator/rusEfiFunctionalTest.cpp | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/win32_functional_tests/simulator/rusEfiFunctionalTest.cpp b/win32_functional_tests/simulator/rusEfiFunctionalTest.cpp index 3c8eb6f76c..6dcda9f595 100644 --- a/win32_functional_tests/simulator/rusEfiFunctionalTest.cpp +++ b/win32_functional_tests/simulator/rusEfiFunctionalTest.cpp @@ -29,6 +29,8 @@ #include "trigger_emulator.h" #include "engine_controller.h" #include "map_averaging.h" +#include "memstreams.h" +#include #define DEFAULT_SIM_RPM 1200 #define DEFAULT_SNIFFER_THR 2500 @@ -53,6 +55,23 @@ float getMap(void) { return getRawMap(); } +static void runChprintfTess() { + static MemoryStream testStream; + static char testBuffer[200]; + msObjectInit(&testStream, (uint8_t *) testBuffer, sizeof(testBuffer), 0); + + +// it's a very, very long and mostly forgotten story how this became our %f precision format + testStream.eos = 0; // reset + chprintf((BaseSequentialStream*)&testStream, "%f/%..10000f/%..10000f", 0.239f, 239.932, 0.1234); + testStream.buffer[testStream.eos] = 0; + +#define FLOAT_STRING_EXPECTED "0.23/239.9320/0.1234" + if (strcmp(FLOAT_STRING_EXPECTED, testBuffer) != 0) { + firmwareError(0, "got %s while %s", testBuffer, FLOAT_STRING_EXPECTED); + } +} + void rusEfiFunctionalTest(void) { printToWin32Console("Running version:"); printToWin32Console("TODO"); @@ -94,6 +113,8 @@ void rusEfiFunctionalTest(void) { startStatusThreads(engine); + runChprintfTess(); + initPeriodicEvents(PASS_ENGINE_PARAMETER_F); setTriggerEmulatorRPM(DEFAULT_SIM_RPM, engine); From 797eddd824cff39d93080cc6e7e40b401e018c22 Mon Sep 17 00:00:00 2001 From: rusefi Date: Tue, 28 Mar 2017 19:39:48 -0400 Subject: [PATCH 05/17] chprintf test into simulator --- win32_functional_tests/simulator/rusEfiFunctionalTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win32_functional_tests/simulator/rusEfiFunctionalTest.cpp b/win32_functional_tests/simulator/rusEfiFunctionalTest.cpp index 6dcda9f595..d040417346 100644 --- a/win32_functional_tests/simulator/rusEfiFunctionalTest.cpp +++ b/win32_functional_tests/simulator/rusEfiFunctionalTest.cpp @@ -68,7 +68,7 @@ static void runChprintfTess() { #define FLOAT_STRING_EXPECTED "0.23/239.9320/0.1234" if (strcmp(FLOAT_STRING_EXPECTED, testBuffer) != 0) { - firmwareError(0, "got %s while %s", testBuffer, FLOAT_STRING_EXPECTED); + firmwareError(0, "chprintf test: got %s while %s", testBuffer, FLOAT_STRING_EXPECTED); } } From 33b2f1a50c5779487f3fa8c471413b1778df7c3f Mon Sep 17 00:00:00 2001 From: rusefi Date: Tue, 28 Mar 2017 23:08:40 -0400 Subject: [PATCH 06/17] fixing compilation on the chprintf test --- win32_functional_tests/simulator/rusEfiFunctionalTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win32_functional_tests/simulator/rusEfiFunctionalTest.cpp b/win32_functional_tests/simulator/rusEfiFunctionalTest.cpp index d040417346..7e6b5b7e6c 100644 --- a/win32_functional_tests/simulator/rusEfiFunctionalTest.cpp +++ b/win32_functional_tests/simulator/rusEfiFunctionalTest.cpp @@ -68,7 +68,7 @@ static void runChprintfTess() { #define FLOAT_STRING_EXPECTED "0.23/239.9320/0.1234" if (strcmp(FLOAT_STRING_EXPECTED, testBuffer) != 0) { - firmwareError(0, "chprintf test: got %s while %s", testBuffer, FLOAT_STRING_EXPECTED); + firmwareError(OBD_PCM_Processor_Fault, "chprintf test: got %s while %s", testBuffer, FLOAT_STRING_EXPECTED); } } From 5fd3769bc80866ec6f9657289accba1e67994a45 Mon Sep 17 00:00:00 2001 From: rusefi Date: Wed, 29 Mar 2017 00:00:48 -0400 Subject: [PATCH 07/17] lovely how we were surviving this build script issue all this time --- firmware/util/util.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/firmware/util/util.mk b/firmware/util/util.mk index 8e96c74d07..ca68898468 100644 --- a/firmware/util/util.mk +++ b/firmware/util/util.mk @@ -5,8 +5,8 @@ UTILSRC = $(PROJECT_DIR)/util/crc.c \ $(PROJECT_DIR)/util/histogram.c UTILSRC_CPP = $(PROJECT_DIR)/util/cyclic_buffer.cpp \ - $(PROJECT_DIR)/console_util/datalogging.cpp \ - $(PROJECT_DIR)/console_util/loggingcentral.cpp \ + $(PROJECT_DIR)/console/datalogging.cpp \ + $(PROJECT_DIR)/console/loggingcentral.cpp \ $(PROJECT_DIR)/util/listener_array.cpp \ $(PROJECT_DIR)/util/cli_registry.cpp \ $(PROJECT_DIR)/util/efilib.cpp \ From 4630767d499bf2313ad04e5174528296fcaee215 Mon Sep 17 00:00:00 2001 From: rusefi Date: Wed, 29 Mar 2017 08:59:24 -0400 Subject: [PATCH 08/17] touching frozen master as part of merge resolution --- firmware/util/util.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/firmware/util/util.mk b/firmware/util/util.mk index ca68898468..c30bef1785 100644 --- a/firmware/util/util.mk +++ b/firmware/util/util.mk @@ -5,8 +5,8 @@ UTILSRC = $(PROJECT_DIR)/util/crc.c \ $(PROJECT_DIR)/util/histogram.c UTILSRC_CPP = $(PROJECT_DIR)/util/cyclic_buffer.cpp \ - $(PROJECT_DIR)/console/datalogging.cpp \ - $(PROJECT_DIR)/console/loggingcentral.cpp \ + $(PROJECT_DIR)/util/datalogging.cpp \ + $(PROJECT_DIR)/util/loggingcentral.cpp \ $(PROJECT_DIR)/util/listener_array.cpp \ $(PROJECT_DIR)/util/cli_registry.cpp \ $(PROJECT_DIR)/util/efilib.cpp \ From 1cd93d16f9969593db23d7e67e80c8109b4ec281 Mon Sep 17 00:00:00 2001 From: rusefi Date: Thu, 30 Mar 2017 08:12:35 -0400 Subject: [PATCH 09/17] strict defines --- firmware/config/engines/audi_aan.h | 1 + 1 file changed, 1 insertion(+) diff --git a/firmware/config/engines/audi_aan.h b/firmware/config/engines/audi_aan.h index 5e1edb7c94..28ba423dc9 100644 --- a/firmware/config/engines/audi_aan.h +++ b/firmware/config/engines/audi_aan.h @@ -9,6 +9,7 @@ #ifndef AUDI_AAN_H_ #define AUDI_AAN_H_ +#include "global.h" #if EFI_ENGINE_AUDI_AAN #endif /* EFI_ENGINE_AUDI_AAN */ From 48c25bc6c7e99664ddc508bd4989155262ddf533 Mon Sep 17 00:00:00 2001 From: rusefi Date: Thu, 30 Mar 2017 08:14:58 -0400 Subject: [PATCH 10/17] strict defines --- firmware/config/engines/snow_blower.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/firmware/config/engines/snow_blower.h b/firmware/config/engines/snow_blower.h index f33e2e468e..16242dfbcb 100644 --- a/firmware/config/engines/snow_blower.h +++ b/firmware/config/engines/snow_blower.h @@ -9,6 +9,8 @@ #ifndef SNOW_BLOWER_H_ #define SNOW_BLOWER_H_ +#include "global.h" + #if EFI_ENGINE_SNOW_BLOWER #endif /* EFI_ENGINE_SNOW_BLOWER */ From 9790a0939d0b3ed39a7f6e7eeb930f4ae4eee44c Mon Sep 17 00:00:00 2001 From: rusefi Date: Thu, 30 Mar 2017 08:57:49 -0400 Subject: [PATCH 11/17] safe pre-merge, reducing chibios3 PR --- firmware/controllers/trigger/rpm_calculator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/controllers/trigger/rpm_calculator.cpp b/firmware/controllers/trigger/rpm_calculator.cpp index 90f5af3bb9..c32033d94e 100644 --- a/firmware/controllers/trigger/rpm_calculator.cpp +++ b/firmware/controllers/trigger/rpm_calculator.cpp @@ -181,7 +181,7 @@ void rpmShaftPositionCallback(trigger_event_e ckpSignalType, efitick_t nowNt = getTimeNowNt(); engine->m.beforeRpmCb = GET_TIMESTAMP(); #if EFI_PROD_CODE - efiAssertVoid(getRemainingStack(chThdSelf()) > 256, "lowstck#2z"); + efiAssertVoid(getRemainingStack(chThdGetSelfX()) > 256, "lowstck#2z"); #endif #if EFI_SENSOR_CHART || defined(__DOXYGEN__) From 4fe5b75664d720430c69285a757ed68d66c846d7 Mon Sep 17 00:00:00 2001 From: rusefi Date: Thu, 30 Mar 2017 08:58:48 -0400 Subject: [PATCH 12/17] safe pre-merge, reducing chibios3 PR --- firmware/controllers/trigger/trigger_central.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 486d5cfc97..534a9229cb 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -170,7 +170,7 @@ void hwHandleShaftSignal(trigger_event_e signal) { if (triggerReentraint > maxTriggerReentraint) maxTriggerReentraint = triggerReentraint; triggerReentraint++; - efiAssertVoid(getRemainingStack(chThdSelf()) > 128, "lowstck#8"); + efiAssertVoid(getRemainingStack(chThdGetSelfX()) > 128, "lowstck#8"); engine->triggerCentral.handleShaftSignal(signal PASS_ENGINE_PARAMETER); triggerReentraint--; triggerDuration = GET_TIMESTAMP() - triggerHanlderEntryTime; From 60b7a67beb1d6d7391f4c412f8cd2319e76ed910 Mon Sep 17 00:00:00 2001 From: rusefi Date: Thu, 30 Mar 2017 08:59:12 -0400 Subject: [PATCH 13/17] safe pre-merge, reducing chibios3 PR --- firmware/controllers/trigger/trigger_decoder.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index 95497836c3..2ffe65fe14 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -483,7 +483,7 @@ static TriggerState initState CCM_OPTIONAL; void TriggerShape::initializeTriggerShape(Logging *logger DECLARE_ENGINE_PARAMETER_S) { const trigger_config_s *triggerConfig = &engineConfiguration->trigger; #if EFI_PROD_CODE || defined(__DOXYGEN__) - efiAssertVoid(getRemainingStack(chThdSelf()) > 256, "init t"); + efiAssertVoid(getRemainingStack(chThdGetSelfX()) > 256, "init t"); scheduleMsg(logger, "initializeTriggerShape(%s/%d)", getTrigger_type_e(triggerConfig->type), (int) triggerConfig->type); #endif @@ -676,7 +676,7 @@ static void onFindIndex(TriggerState *state) { uint32_t findTriggerZeroEventIndex(TriggerState *state, TriggerShape * shape, trigger_config_s const*triggerConfig DECLARE_ENGINE_PARAMETER_S) { #if EFI_PROD_CODE || defined(__DOXYGEN__) - efiAssert(getRemainingStack(chThdSelf()) > 128, "findPos", -1); + efiAssert(getRemainingStack(chThdGetSelfX()) > 128, "findPos", -1); #endif isInitializingTrigger = true; errorDetection.clear(); From 3baea1986783aa34045c8f5ac03246de63f479fe Mon Sep 17 00:00:00 2001 From: rusefi Date: Thu, 30 Mar 2017 08:59:38 -0400 Subject: [PATCH 14/17] safe pre-merge, reducing chibios3 PR --- firmware/controllers/trigger/trigger_structure.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/controllers/trigger/trigger_structure.cpp b/firmware/controllers/trigger/trigger_structure.cpp index 28045d2667..fa8a4aacf2 100644 --- a/firmware/controllers/trigger/trigger_structure.cpp +++ b/firmware/controllers/trigger/trigger_structure.cpp @@ -44,7 +44,7 @@ TriggerShape::TriggerShape() : void TriggerShape::calculateTriggerSynchPoint(TriggerState *state DECLARE_ENGINE_PARAMETER_S) { #if EFI_PROD_CODE || defined(__DOXYGEN__) - efiAssertVoid(getRemainingStack(chThdSelf()) > 256, "calc s"); + efiAssertVoid(getRemainingStack(chThdGetSelfX()) > 256, "calc s"); #endif trigger_config_s const*triggerConfig = &engineConfiguration->trigger; From d00e7d66de52196519a68b1801631438bead36ac Mon Sep 17 00:00:00 2001 From: rusefi Date: Thu, 30 Mar 2017 09:00:55 -0400 Subject: [PATCH 15/17] safe pre-merge, reducing chibios3 PR --- firmware/hw_layer/accelerometer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/hw_layer/accelerometer.cpp b/firmware/hw_layer/accelerometer.cpp index 9b9c36a453..828a2b00d4 100644 --- a/firmware/hw_layer/accelerometer.cpp +++ b/firmware/hw_layer/accelerometer.cpp @@ -6,7 +6,7 @@ */ #include "main.h" -#include "lis302dl.h" +//#include "lis302dl.h" void initAccelerometer(DECLARE_ENGINE_PARAMETER_F) { From 24c771a24dfcbfa725a0172362540759ee9b501b Mon Sep 17 00:00:00 2001 From: rusefi Date: Thu, 30 Mar 2017 09:01:28 -0400 Subject: [PATCH 16/17] safe pre-merge, reducing chibios3 PR --- firmware/hw_layer/adc_inputs.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/firmware/hw_layer/adc_inputs.cpp b/firmware/hw_layer/adc_inputs.cpp index 117dada0e5..a05d626bec 100644 --- a/firmware/hw_layer/adc_inputs.cpp +++ b/firmware/hw_layer/adc_inputs.cpp @@ -148,7 +148,7 @@ AdcDevice fastAdc(&adcgrpcfg_fast); void doSlowAdc(void) { - efiAssertVoid(getRemainingStack(chThdSelf())> 32, "lwStAdcSlow"); + efiAssertVoid(getRemainingStack(chThdGetSelfX())> 32, "lwStAdcSlow"); #if EFI_INTERNAL_ADC @@ -156,19 +156,19 @@ void doSlowAdc(void) { will be executed in parallel to the current PWM cycle and will terminate before the next PWM cycle.*/ slowAdc.conversionCount++; - chSysLockFromIsr() + chSysLockFromISR() ; if (ADC_SLOW_DEVICE.state != ADC_READY && ADC_SLOW_DEVICE.state != ADC_COMPLETE && ADC_SLOW_DEVICE.state != ADC_ERROR) { // todo: why and when does this happen? firmwareError(OBD_PCM_Processor_Fault, "ADC slow not ready?"); slowAdc.errorsCount++; - chSysUnlockFromIsr() + chSysUnlockFromISR() ; return; } adcStartConversionI(&ADC_SLOW_DEVICE, &adcgrpcfgSlow, slowAdc.samples, ADC_BUF_DEPTH_SLOW); - chSysUnlockFromIsr() + chSysUnlockFromISR() ; #endif } @@ -179,7 +179,7 @@ static void pwmpcb_slow(PWMDriver *pwmp) { } static void pwmpcb_fast(PWMDriver *pwmp) { - efiAssertVoid(getRemainingStack(chThdSelf())> 32, "lwStAdcFast"); + efiAssertVoid(getRemainingStack(chThdGetSelfX())> 32, "lwStAdcFast"); #if EFI_INTERNAL_ADC (void) pwmp; @@ -188,19 +188,19 @@ static void pwmpcb_fast(PWMDriver *pwmp) { * will be executed in parallel to the current PWM cycle and will * terminate before the next PWM cycle. */ - chSysLockFromIsr() + chSysLockFromISR() ; if (ADC_FAST_DEVICE.state != ADC_READY && ADC_FAST_DEVICE.state != ADC_COMPLETE && ADC_FAST_DEVICE.state != ADC_ERROR) { fastAdc.errorsCount++; // todo: when? why? firmwareError(OBD_PCM_Processor_Fault, "ADC fast not ready?"); - chSysUnlockFromIsr() + chSysUnlockFromISR() ; return; } adcStartConversionI(&ADC_FAST_DEVICE, &adcgrpcfg_fast, fastAdc.samples, ADC_BUF_DEPTH_FAST); - chSysUnlockFromIsr() + chSysUnlockFromISR() ; fastAdc.conversionCount++; #endif @@ -483,7 +483,7 @@ static void setAdcDebugReporting(int value) { static void adc_callback_slow(ADCDriver *adcp, adcsample_t *buffer, size_t n) { (void) buffer; (void) n; - efiAssertVoid(getRemainingStack(chThdSelf()) > 128, "lowstck#9c"); + efiAssertVoid(getRemainingStack(chThdGetSelfX()) > 128, "lowstck#9c"); /* Note, only in the ADC_COMPLETE state because the ADC driver fires * an intermediate callback when the buffer is half full. */ if (adcp->state == ADC_COMPLETE) { From 0f56565db85e6ee785bf0ebd76874bc32e21fbf7 Mon Sep 17 00:00:00 2001 From: rusefi Date: Thu, 30 Mar 2017 09:03:42 -0400 Subject: [PATCH 17/17] safe pre-merge, reducing chibios3 PR --- firmware/util/datalogging.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/firmware/util/datalogging.cpp b/firmware/util/datalogging.cpp index 08e856daa7..ecc2a84ced 100644 --- a/firmware/util/datalogging.cpp +++ b/firmware/util/datalogging.cpp @@ -105,7 +105,7 @@ void appendFast(Logging *logging, const char *text) { // todo: look into chsnprintf once on Chibios 3 static void vappendPrintfI(Logging *logging, const char *fmt, va_list arg) { intermediateLoggingBuffer.eos = 0; // reset - efiAssertVoid(getRemainingStack(chThdSelf()) > 128, "lowstck#1b"); + efiAssertVoid(getRemainingStack(chThdGetSelfX()) > 128, "lowstck#1b"); chvprintf((BaseSequentialStream *) &intermediateLoggingBuffer, fmt, arg); intermediateLoggingBuffer.buffer[intermediateLoggingBuffer.eos] = 0; // need to terminate explicitly append(logging, (char *) intermediateLoggingBufferData); @@ -115,7 +115,7 @@ static void vappendPrintfI(Logging *logging, const char *fmt, va_list arg) { * this method acquires system lock to guard the shared intermediateLoggingBuffer memory stream */ void vappendPrintf(Logging *logging, const char *fmt, va_list arg) { - efiAssertVoid(getRemainingStack(chThdSelf()) > 128, "lowstck#5b"); + efiAssertVoid(getRemainingStack(chThdGetSelfX()) > 128, "lowstck#5b"); if (!intermediateLoggingBufferInited) { firmwareError(CUSTOM_ERR_6532, "intermediateLoggingBufferInited not inited!"); return; @@ -128,7 +128,7 @@ void vappendPrintf(Logging *logging, const char *fmt, va_list arg) { } void appendPrintf(Logging *logging, const char *fmt, ...) { - efiAssertVoid(getRemainingStack(chThdSelf()) > 128, "lowstck#4"); + efiAssertVoid(getRemainingStack(chThdGetSelfX()) > 128, "lowstck#4"); va_list ap; va_start(ap, fmt); vappendPrintf(logging, fmt, ap); @@ -253,7 +253,7 @@ void resetLogging(Logging *logging) { * This method should only be invoked on main thread because only the main thread can write to the console */ void printMsg(Logging *logger, const char *fmt, ...) { - efiAssertVoid(getRemainingStack(chThdSelf()) > 128, "lowstck#5o"); + efiAssertVoid(getRemainingStack(chThdGetSelfX()) > 128, "lowstck#5o"); // resetLogging(logging); // I guess 'reset' is not needed here? appendMsgPrefix(logger);