diff --git a/firmware/config/stm32f7ems/efifeatures.h b/firmware/config/stm32f7ems/efifeatures.h index 2cba798ffb..556331a3f7 100644 --- a/firmware/config/stm32f7ems/efifeatures.h +++ b/firmware/config/stm32f7ems/efifeatures.h @@ -15,7 +15,7 @@ #ifndef EFI_EMBED_INI_MSD #define EFI_EMBED_INI_MSD FALSE #endif - + #include "../stm32f4ems/efifeatures.h" #pragma once diff --git a/firmware/console/console_io.h b/firmware/console/console_io.h index 486c6bdcf1..4c39f317d8 100644 --- a/firmware/console/console_io.h +++ b/firmware/console/console_io.h @@ -10,7 +10,7 @@ extern "C" { #endif /* __cplusplus */ - + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/firmware/controllers/algo/nmea.cpp b/firmware/controllers/algo/nmea.cpp index 26dd5870b8..4862cd12b3 100644 --- a/firmware/controllers/algo/nmea.cpp +++ b/firmware/controllers/algo/nmea.cpp @@ -29,7 +29,7 @@ static long hex2int(const char *a, int len) { for (i = 0; i < len; i++) if (a[i] <= 57) - val += (a[i] - 48) * (1 << (4 * (len - 1 - i))); // it's number + val += (a[i] - 48) * (1 << (4 * (len - 1 - i))); // it's decimal number else val += (a[i] - 87) * (1 << (4 * (len - 1 - i))); // it's a-f -> work only with low case hex return val; @@ -68,7 +68,7 @@ static void gps_convert_deg_to_dec(float *latitude, char ns, float *longitude, c } // in string collect all char till comma and convert to float -static int str_till_comma(char *a, char *dStr) { +static int str_till_comma(const char * const a, char * const dStr) { int i = 0, sLen = strlen(a); if (sLen > GPS_MAX_STRING) @@ -100,8 +100,8 @@ Unit M=Meters Age of DGPS Corr s Age of Differential Corrections DGPS Ref Station ID of DGPS Reference Station */ -void nmea_parse_gpgga(char *nmea, loc_t *loc) { - char *p = nmea; +void nmea_parse_gpgga(char const * const nmea, loc_t *loc) { + char const * p = (char *)nmea; char dStr[GPS_MAX_STRING]; p = strchr(p, ',') + 1; //skip time - we read date&time if Valid in GxRMC @@ -175,14 +175,14 @@ Magnetic Variation ° Magnetic Variation Magnetic Variation E=East,W=West Mode Indicator N A=Autonomous, D=Differential, E=Dead Reckoning, N=None Navigational Status S=Safe C=Caution U=Unsafe V=Not valid - */ -void nmea_parse_gprmc(char *nmea, loc_t *loc) { - char *p = nmea; + +void nmea_parse_gprmc(char const * const nmea, loc_t *loc) { + char const * p = (char *)nmea; char dStr[GPS_MAX_STRING]; struct tm timp; - p = strchr(p, ',') + 1; //read time + p = strchr(p, ',') + 1; // read time str_till_comma(p, dStr); if (strlen(dStr) > 5) { timp.tm_hour = str2int(dStr,2); @@ -190,7 +190,7 @@ void nmea_parse_gprmc(char *nmea, loc_t *loc) { timp.tm_sec = str2int(dStr+4,2); } - p = strchr(p, ',') + 1; //read field Valid status + p = strchr(p, ',') + 1; // read field Valid status str_till_comma(p, dStr); if (dStr[0] == 'V') { // if field is invalid @@ -217,7 +217,7 @@ void nmea_parse_gprmc(char *nmea, loc_t *loc) { break; } - p = strchr(p, ',') + 1; // longitude + p = strchr(p, ',') + 1; // longitude str_till_comma(p, dStr); // str to float till comma saved modified string loc->longitude = atoff(dStr); @@ -242,7 +242,7 @@ void nmea_parse_gprmc(char *nmea, loc_t *loc) { str_till_comma(p, dStr); // str to float till comma saved modified string loc->course = atoff(dStr); - p = strchr(p, ',') + 1; //read date + p = strchr(p, ',') + 1; // read date str_till_comma(p, dStr); if (strlen(dStr) > 5) { timp.tm_mday = str2int(dStr,2); @@ -280,7 +280,7 @@ nmea_message_type nmea_get_message_type(const char *message) { return NMEA_UNKNOWN; } -int nmea_valid_checksum(const char *message) { +int nmea_valid_checksum(char const * message) { char p; int sum = 0; const char* starPtr = strrchr(message, '*'); @@ -302,8 +302,7 @@ int nmea_valid_checksum(const char *message) { } // Compute the GPS location using decimal scale -void gps_location(loc_t *coord, char *buffer) { - +void gps_location(loc_t *coord, char const * const buffer) { coord->type = nmea_get_message_type(buffer); switch (coord->type) { @@ -318,5 +317,4 @@ void gps_location(loc_t *coord, char *buffer) { // unknown message type break; } - } diff --git a/firmware/controllers/algo/nmea.h b/firmware/controllers/algo/nmea.h index 1262b6a2dd..4d95cc4732 100644 --- a/firmware/controllers/algo/nmea.h +++ b/firmware/controllers/algo/nmea.h @@ -39,6 +39,6 @@ typedef struct GPSlocation loc_t; nmea_message_type nmea_get_message_type(const char *); int nmea_valid_checksum(const char *); -void nmea_parse_gpgga(char *, loc_t *); -void nmea_parse_gprmc(char *, loc_t *); -void gps_location(loc_t *, char *); +void nmea_parse_gpgga(char const * const, loc_t *); +void nmea_parse_gprmc(char const * const, loc_t *); +void gps_location(loc_t *, char const * const); diff --git a/firmware/controllers/algo/rusefi_types.h b/firmware/controllers/algo/rusefi_types.h index b263a3057c..b1de28cab1 100644 --- a/firmware/controllers/algo/rusefi_types.h +++ b/firmware/controllers/algo/rusefi_types.h @@ -34,8 +34,8 @@ using time_t = uint32_t; #define FOUR_STROKE_CYCLE_DURATION 720 // gasoline E0 -#define STOICH_RATIO 14.7f -#define CONST_PI 3.14159265358979323846 +#define STOICH_RATIO 14.7f +#define CONST_PI 3.14159265358979323846 // time in seconds diff --git a/firmware/controllers/can/can_dash.cpp b/firmware/controllers/can/can_dash.cpp index ade6fecf05..f70e2fbed2 100644 --- a/firmware/controllers/can/can_dash.cpp +++ b/firmware/controllers/can/can_dash.cpp @@ -17,6 +17,7 @@ #include "rtc_helper.h" #include "fuel_math.h" + // CAN Bus ID for broadcast #define CAN_FIAT_MOTOR_INFO 0x561 #define CAN_MAZDA_RX_RPM_SPEED 0x201 @@ -432,7 +433,7 @@ void canDashboardBMWE90(CanCycle cycle) msg[1] = 0x41; msg[2] = 0x61; msg[3] = 0x8F; - msg[4] = 0xFC; + msg[4] = 0xFC; } { //Ebrake light diff --git a/firmware/controllers/settings.cpp b/firmware/controllers/settings.cpp index c677940404..0a8c7b27da 100644 --- a/firmware/controllers/settings.cpp +++ b/firmware/controllers/settings.cpp @@ -8,7 +8,7 @@ #include "pch.h" -#if !EFI_UNIT_TEST +#if ! EFI_UNIT_TEST #include "eficonsole.h" #include "trigger_decoder.h" @@ -23,21 +23,21 @@ #include "can_hw.h" #include "rusefi.h" #include "hardware.h" -#endif /* EFI_PROD_CODE */ +#endif // EFI_PROD_CODE #if EFI_ELECTRONIC_THROTTLE_BODY #include "electronic_throttle.h" -#endif /* EFI_ELECTRONIC_THROTTLE_BODY */ +#endif // EFI_ELECTRONIC_THROTTLE_BODY #if EFI_INTERNAL_FLASH #include "flash_main.h" -#endif /* EFI_INTERNAL_FLASH */ +#endif // EFI_INTERNAL_FLASH #if EFI_ENGINE_SNIFFER #include "engine_sniffer.h" extern int waveChartUsedSize; extern WaveChart waveChart; -#endif /* EFI_ENGINE_SNIFFER */ +#endif // EFI_ENGINE_SNIFFER void printSpiState(const engine_configuration_s *engineConfiguration) { efiPrintf("spi 1=%s/2=%s/3=%s/4=%s", @@ -139,11 +139,10 @@ void printConfiguration(const engine_configuration_s *engineConfiguration) { efiPrintf("digitalPotentiometer CS%d %s", i, hwPortname(engineConfiguration->digitalPotentiometerChipSelect[i])); } + #if EFI_PROD_CODE - printSpiState(engineConfiguration); - -#endif /* EFI_PROD_CODE */ +#endif // EFI_PROD_CODE } static void doPrintConfiguration() { @@ -255,7 +254,6 @@ static void setRpmHardLimit(int value) { static void setCrankingIACExtra(float percent) { engineConfiguration->crankingIACposition = percent; efiPrintf("cranking_iac %.2f", percent); - } static void setCrankingFuel(float timeMs) { @@ -614,7 +612,7 @@ static void setAnalogInputPin(const char *sensorStr, const char *pinName) { } incrementGlobalConfigurationVersion(); } -#endif +#endif // HAL_USE_ADC static void setLogicInputPin(const char *indexStr, const char *pinName) { int index = atoi(indexStr); @@ -638,7 +636,7 @@ static void showPinFunction(const char *pinName) { efiPrintf("Pin %s: [%s]", pinName, getPinFunction(pin)); } -#endif /* EFI_PROD_CODE */ +#endif // EFI_PROD_CODE static void setSpiMode(int index, bool mode) { switch (index) { @@ -687,8 +685,8 @@ static void enableOrDisable(const char *param, bool isEnabled) { } else if (strEqualCaseInsensitive(param, "auto_idle")) { #if EFI_IDLE_CONTROL setIdleMode(isEnabled ? IM_MANUAL : IM_AUTO); -#endif /* EFI_IDLE_CONTROL */ -#endif /* EFI_PROD_CODE */ +#endif // EFI_IDLE_CONTROL +#endif // EFI_PROD_CODE } else if (strEqualCaseInsensitive(param, "stepperidle")) { engineConfiguration->useStepperIdle = isEnabled; } else if (strEqualCaseInsensitive(param, "two_wire_batch_injection")) { @@ -748,7 +746,7 @@ static void enableOrDisable(const char *param, bool isEnabled) { } else { disableTriggerStimulator(); } -#endif +#endif // EFI_EMULATE_POSITION_SENSORS } else if (strEqualCaseInsensitive(param, "engine_control")) { engineConfiguration->isEngineControlEnabled = isEnabled; } else if (strEqualCaseInsensitive(param, "map_avg")) { @@ -789,7 +787,6 @@ void scheduleStopEngine(void) { doScheduleStopEngine(); } -#if ! EFI_UNIT_TEST const plain_get_short_s getS_plain[] = { {"idle_pid_min", (uint16_t *)&engineConfiguration->idleRpmPid.minValue}, {"idle_pid_max", (uint16_t *)&engineConfiguration->idleRpmPid.maxValue}, @@ -824,8 +821,6 @@ static plain_get_integer_s getI_plain[] = { // {"idle_rpm", setTargetIdleRpm}, }; -#endif /* EFI_UNIT_TEST */ - static plain_get_integer_s *findInt(const char *name) { plain_get_integer_s *currentI = &getI_plain[0]; while (currentI < getI_plain + efi::size(getI_plain)) { @@ -838,7 +833,6 @@ static plain_get_integer_s *findInt(const char *name) { } static void getValue(const char *paramStr) { -#if ! EFI_UNIT_TEST { plain_get_integer_s *known = findInt(paramStr); if (known != nullptr) { @@ -856,16 +850,12 @@ static void getValue(const char *paramStr) { } } - -#endif /* EFI_UNIT_TEST */ - - if (strEqualCaseInsensitive(paramStr, "isCJ125Enabled")) { efiPrintf("isCJ125Enabled=%d", engineConfiguration->isCJ125Enabled); #if EFI_PROD_CODE } else if (strEqualCaseInsensitive(paramStr, "bor")) { showBor(); -#endif /* EFI_PROD_CODE */ +#endif // EFI_PROD_CODE } else if (strEqualCaseInsensitive(paramStr, "tps_min")) { efiPrintf("tps_min=%d", engineConfiguration->tpsMin); } else if (strEqualCaseInsensitive(paramStr, "tps_max")) { @@ -933,15 +923,15 @@ const command_f_s commandsF[] = { {"idle_p", setIdlePFactor}, {"idle_i", setIdleIFactor}, {"idle_d", setIdleDFactor}, -#endif /* EFI_IDLE_CONTROL */ -#endif /* EFI_PROD_CODE */ +#endif // EFI_IDLE_CONTROL +#endif // EFI_PROD_CODE -#if EFI_ELECTRONIC_THROTTLE_BODY && (!EFI_UNIT_TEST) +#if EFI_ELECTRONIC_THROTTLE_BODY {"etb_p", setEtbPFactor}, {"etb_i", setEtbIFactor}, {"etb_d", setEtbDFactor}, {"etb", setThrottleDutyCycle}, -#endif /* EFI_ELECTRONIC_THROTTLE_BODY */ +#endif // EFI_ELECTRONIC_THROTTLE_BODY // {"", }, // {"", }, @@ -988,16 +978,16 @@ const command_i_s commandsI[] = {{"ignition_mode", setIgnitionMode}, #if EFI_CAN_SUPPORT {"can_mode", setCanType}, {"can_vss", setCanVss}, -#endif /* EFI_CAN_SUPPORT */ +#endif // EFI_CAN_SUPPORT #if EFI_IDLE_CONTROL {"idle_position", setManualIdleValvePosition}, {"idle_rpm", setTargetIdleRpm}, -#endif /* EFI_IDLE_CONTROL */ -#endif /* EFI_PROD_CODE */ +#endif // EFI_IDLE_CONTROL +#endif // EFI_PROD_CODE #if EFI_ELECTRONIC_THROTTLE_BODY {"etb_o", setEtbOffset}, -#endif /* EFI_ELECTRONIC_THROTTLE_BODY */ +#endif // EFI_ELECTRONIC_THROTTLE_BODY // {"", }, // {"", }, @@ -1039,7 +1029,7 @@ static void setValue(const char *paramStr, const char *valueStr) { } else if (strEqualCaseInsensitive(paramStr, "alt_p")) { setAltPFactor(valueF); } else -#endif /* EFI_ALTERNATOR_CONTROL */ +#endif // EFI_ALTERNATOR_CONTROL if (strEqualCaseInsensitive(paramStr, "warning_period")) { engineConfiguration->warningPeriod = valueI; } else if (strEqualCaseInsensitive(paramStr, "dwell")) { @@ -1058,7 +1048,7 @@ static void setValue(const char *paramStr, const char *valueStr) { #if EFI_EMULATE_POSITION_SENSORS } else if (strEqualCaseInsensitive(paramStr, CMD_RPM)) { setTriggerEmulatorRPM(valueI); -#endif /* EFI_EMULATE_POSITION_SENSORS */ +#endif // EFI_EMULATE_POSITION_SENSORS } else if (strEqualCaseInsensitive(paramStr, "vvt_offset")) { engineConfiguration->vvtOffsets[0] = valueF; } else if (strEqualCaseInsensitive(paramStr, "vvt_mode")) { @@ -1091,7 +1081,7 @@ static void setValue(const char *paramStr, const char *valueStr) { void initSettings(void) { #if EFI_SIMULATOR printf("initSettings\n"); -#endif +#endif // EFI_SIMULATOR // todo: start saving values into flash right away? @@ -1159,30 +1149,30 @@ void initSettings(void) { #if HAL_USE_ADC addConsoleActionSS("set_analog_input_pin", setAnalogInputPin); -#endif +#endif // HAL_USE_ADC addConsoleActionSS(CMD_LOGIC_PIN, setLogicInputPin); addConsoleActionI("set_pot_spi", setPotSpi); -#endif /* EFI_PROD_CODE */ +#endif // EFI_PROD_CODE } -#endif /* !EFI_UNIT_TEST */ +#endif // ! EFI_UNIT_TEST void setEngineType(int value) { { #if EFI_PROD_CODE chibios_rt::CriticalSectionLocker csl; -#endif /* EFI_PROD_CODE */ +#endif // EFI_PROD_CODE engineConfiguration->engineType = (engine_type_e)value; resetConfigurationExt((engine_type_e)value); engine->resetEngineSnifferIfInTestMode(); - #if EFI_INTERNAL_FLASH +#if EFI_INTERNAL_FLASH writeToFlashNow(); - #endif /* EFI_INTERNAL_FLASH */ +#endif // EFI_INTERNAL_FLASH } incrementGlobalConfigurationVersion(); #if ! EFI_UNIT_TEST doPrintConfiguration(); -#endif /* EFI_UNIT_TEST */ +#endif // ! EFI_UNIT_TEST } diff --git a/firmware/hw_layer/sensors/gps_uart.cpp b/firmware/hw_layer/sensors/gps_uart.cpp index a1f6216577..5c3e6883b1 100644 --- a/firmware/hw_layer/sensors/gps_uart.cpp +++ b/firmware/hw_layer/sensors/gps_uart.cpp @@ -49,8 +49,8 @@ static void printGpsInfo() { float sec = getTimeNowMs() / 1000.0; efiPrintf("communication speed: %.2f", gpsMesagesCount / sec); - print("GPS latitude = %.2f\r\n", GPSdata.latitude); - print("GPS longitude = %.2f\r\n", GPSdata.longitude); + efiPrintf("GPS latitude = %.2f\r\n", GPSdata.latitude); + efiPrintf("GPS longitude = %.2f\r\n", GPSdata.longitude); } static struct tm curTm; @@ -83,7 +83,7 @@ static THD_FUNCTION(GpsThreadEntryPoint, arg) { if (count >= 1) gps_str[--count] = '\0'; // delete 0xD -// scheduleMsg(&logger, "got GPS [%s]", gps_str); + // scheduleMsg(&logger, "got GPS [%s]", gps_str); // 'gps_str' string completed onGpsMessage(gps_str); diff --git a/firmware/run_hw_test.bat b/firmware/run_hw_test.bat index 7beca67165..ef703b4d1f 100644 --- a/firmware/run_hw_test.bat +++ b/firmware/run_hw_test.bat @@ -1,7 +1,7 @@ rem rem this takes about 12 minutes to run unfortunatelly, current implementation is pretty inefficient :( See comments around 'nextChart()' method rem pa -rem +rem set port=%1 echo "Port (optional): %port%" diff --git a/firmware/util/efitime.h b/firmware/util/efitime.h index ce06a689d3..45d4f7a4fe 100644 --- a/firmware/util/efitime.h +++ b/firmware/util/efitime.h @@ -116,4 +116,3 @@ efitimems_t getTimeNowMs(); efitimesec_t getTimeNowS(); #endif /* __cplusplus */ - diff --git a/unit_tests/tests/test_util.cpp b/unit_tests/tests/test_util.cpp index dfe13268d8..b0fbcaeecf 100644 --- a/unit_tests/tests/test_util.cpp +++ b/unit_tests/tests/test_util.cpp @@ -286,7 +286,7 @@ TEST(misc, testGpsParser) { ASSERT_EQ( 0, GPSdata.course) << "3 course"; ASSERT_EQ( 2006, GPSdata.GPStm.tm_year + 1900) << "3 GPS yy"; ASSERT_EQ( 12, GPSdata.GPStm.tm_mon) << "3 GPS mm"; - ASSERT_EQ( 26, GPSdata.GPStm.tm_mday) << "3 GPS yy"; + ASSERT_EQ( 26, GPSdata.GPStm.tm_mday) << "3 GPS dd"; ASSERT_EQ( 11, GPSdata.GPStm.tm_hour) << "3 GPS hh"; ASSERT_EQ( 16, GPSdata.GPStm.tm_min) << "3 GPS mm"; ASSERT_EQ( 9, GPSdata.GPStm.tm_sec) << "3 GPS ss";