diff --git a/firmware/config/stm32f4ems/efifeatures.h b/firmware/config/stm32f4ems/efifeatures.h index f96f31e2dc..63dcdeb00e 100644 --- a/firmware/config/stm32f4ems/efifeatures.h +++ b/firmware/config/stm32f4ems/efifeatures.h @@ -278,10 +278,10 @@ #define TS_SERIAL_AF 7 #define LED_WARNING_PORT GPIOD -#define LED_WARNING_PIN GPIOD_LED3 +#define LED_WARNING_PIN 13 #define LED_ERROR_PORT GPIOD -#define LED_ERROR_PIN GPIOD_LED5 +#define LED_ERROR_PIN 14 #define EFI_WARNING_LED TRUE diff --git a/firmware/console/binary/tunerstudio_configuration.h b/firmware/console/binary/tunerstudio_configuration.h index 0d57707e60..7e487b92f5 100644 --- a/firmware/console/binary/tunerstudio_configuration.h +++ b/firmware/console/binary/tunerstudio_configuration.h @@ -85,7 +85,7 @@ typedef struct { egt_values_s egtValues; float rpmAcceleration; float massAirFlowValue; - float veValue; + float veValue; // current volumetric efficiency float deltaTps; int triggerErrorsCounter; float currentMapAccelDelta; @@ -101,7 +101,9 @@ typedef struct { float totalFuelCorrection; floatms_t wallFuelCorrection; float idlePosition; - int unused3[5]; + float currentTargetAfr; + float chargeAirMass; + int unused3[3]; } TunerStudioOutputChannels; #endif /* TUNERSTUDIO_CONFIGURATION_H_ */ diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index a95e2abacf..354ce5d69d 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -398,7 +398,9 @@ static void showFuelInfo2(float rpm, float engineLoad) { float baseFuelMs = getBaseTableFuel(engineConfiguration, (int) rpm, engineLoad); - scheduleMsg(&logger, "SD magic fuel %f", sdMath(engineConfiguration, 100, 100, 14.7, convertCelsiusToKelvin(20))); + float magicAir = getAirMass(engineConfiguration, 1, 100, convertCelsiusToKelvin(20)); + + scheduleMsg(&logger, "SD magic fuel %f", sdMath(engineConfiguration, magicAir, 14.7)); scheduleMsg(&logger, "inj flow %fcc/min displacement %fL", engineConfiguration->injector.flow, engineConfiguration->specs.displacement); @@ -552,6 +554,7 @@ static void lcdThread(void *arg) { extern WallFuel wallFuel; extern fuel_Map3D_t veMap; +extern fuel_Map3D_t afrMap; void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ENGINE_PARAMETER_S) { #if EFI_SHAFT_POSITION_INPUT || defined(__DOXYGEN__) @@ -579,6 +582,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ tsOutputChannels->massAirFlowValue = hasMafSensor() ? getRealMaf() : 0; tsOutputChannels->veValue = veMap.getValue(getMap(), rpm); + tsOutputChannels->currentTargetAfr = afrMap.getValue(getMap(), rpm); tsOutputChannels->airFuelRatio = getAfr(); if (hasVBatt(PASS_ENGINE_PARAMETER_F)) { tsOutputChannels->vBatt = getVBatt(PASS_ENGINE_PARAMETER_F); @@ -650,6 +654,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ tsOutputChannels->baseFuel = baseFuelMs; tsOutputChannels->pulseWidthMs = ENGINE(actualLastInjection); tsOutputChannels->crankingFuelMs = getCrankingFuel(PASS_ENGINE_PARAMETER_F); + tsOutputChannels->chargeAirMass = engine->engineState.airMass; } extern TunerStudioOutputChannels tsOutputChannels; diff --git a/firmware/controllers/algo/engine.h b/firmware/controllers/algo/engine.h index 0565685c25..1c05c6f60c 100644 --- a/firmware/controllers/algo/engine.h +++ b/firmware/controllers/algo/engine.h @@ -90,6 +90,8 @@ public: float iat; float clt; + float airMass; + /** * that's fuel in tank - just a gauge */ @@ -127,7 +129,14 @@ public: float currentVE; float targerAFR; + /** + * pre-calculated value from simple fuel lookup + */ float baseTableFuel; + /** + * fuel regardless of fuel logic mode + */ + float baseFuel; angle_t injectionOffset; }; diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index 955c6e4dc0..528d4747a0 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -230,7 +230,11 @@ void prepareVoidConfiguration(engine_configuration_s *activeConfiguration) { boardConfiguration->ignitionPins[i] = GPIO_UNASSIGNED; } boardConfiguration->ignitionPinMode = OM_DEFAULT; +} +void setDefaultBasePins(DECLARE_ENGINE_PARAMETER_F) { + engineConfiguration->fatalErrorPin = GPIOD_14; + engineConfiguration->warninigPin = GPIOD_13; } /** @@ -564,6 +568,7 @@ void setDefaultConfiguration(DECLARE_ENGINE_PARAMETER_F) { engineConfiguration->communicationPin = GPIOD_15; engineConfiguration->runningPin = GPIOD_12; + setDefaultBasePins(PASS_ENGINE_PARAMETER_F); engineConfiguration->binarySerialTxPin = GPIOC_10; engineConfiguration->binarySerialRxPin = GPIOC_11; engineConfiguration->consoleSerialTxPin = GPIOC_10; diff --git a/firmware/controllers/algo/engine_configuration_generated_structures.h b/firmware/controllers/algo/engine_configuration_generated_structures.h index 8211000739..dae4ae0f63 100644 --- a/firmware/controllers/algo/engine_configuration_generated_structures.h +++ b/firmware/controllers/algo/engine_configuration_generated_structures.h @@ -1,4 +1,4 @@ -// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Wed Nov 18 19:07:01 EST 2015 +// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Tue Dec 01 20:29:19 EST 2015 // begin #include "rusefi_types.h" typedef struct { @@ -1428,7 +1428,23 @@ typedef struct { * offset 2212 */ float mapAccelEnrichmentMultiplier; - /** total size 2216*/ + /** + * offset 2216 + */ + brain_pin_e fatalErrorPin; + /** + * offset 2220 + */ + brain_pin_e warninigPin; + /** + * offset 2224 + */ + brain_pin_e configResetPin; + /** + * offset 2228 + */ + int unused[197]; + /** total size 3016*/ } engine_configuration_s; typedef struct { @@ -1437,143 +1453,143 @@ typedef struct { */ engine_configuration_s engineConfiguration; /** - * offset 2216 + * offset 3016 */ le_formula_t le_formulas[LE_COMMAND_COUNT]; /** - * offset 5416 + * offset 6216 */ le_formula_t timingMultiplier; /** - * offset 5616 + * offset 6416 */ le_formula_t timingAdditive; /** - * offset 5816 + * offset 6616 */ float cltFuelCorrBins[CLT_CURVE_SIZE]; /** - * offset 5880 + * offset 6680 */ float cltFuelCorr[CLT_CURVE_SIZE]; /** - * offset 5944 + * offset 6744 */ float iatFuelCorrBins[IAT_CURVE_SIZE]; /** - * offset 6008 + * offset 6808 */ float iatFuelCorr[IAT_CURVE_SIZE]; /** - * offset 6072 + * offset 6872 */ float crankingFuelCoef[CRANKING_CURVE_SIZE]; /** - * offset 6104 + * offset 6904 */ float crankingFuelBins[CRANKING_CURVE_SIZE]; /** - * offset 6136 + * offset 6936 */ float crankingCycleCoef[CRANKING_CURVE_SIZE]; /** - * offset 6168 + * offset 6968 */ float crankingCycleBins[CRANKING_CURVE_SIZE]; /** * CLT-based adjustment for simple manual idle controller - * offset 6200 + * offset 7000 */ float cltIdleCorrBins[CLT_CURVE_SIZE]; /** - * offset 6264 + * offset 7064 */ float cltIdleCorr[CLT_CURVE_SIZE]; /** * kg/hour value. * By the way 2.081989116 kg/h = 1 ft³/m - * offset 6328 + * offset 7128 */ float mafDecoding[MAF_DECODING_COUNT]; /** - * offset 7352 + * offset 8152 */ float mafDecodingBins[MAF_DECODING_COUNT]; /** - * offset 8376 + * offset 9176 */ ignition_table_t ignitionIatCorrTable; /** - * offset 9400 + * offset 10200 */ float ignitionIatCorrLoadBins[IGN_LOAD_COUNT]; /** - * offset 9464 + * offset 10264 */ float ignitionIatCorrRpmBins[IGN_RPM_COUNT]; /** - * offset 9528 + * offset 10328 */ ignition_table_t injectionPhase; /** - * offset 10552 + * offset 11352 */ float injPhaseLoadBins[FUEL_LOAD_COUNT]; /** - * offset 10616 + * offset 11416 */ float injPhaseRpmBins[FUEL_RPM_COUNT]; /** - * offset 10680 + * offset 11480 */ fuel_table_t fuelTable; /** - * offset 11704 + * offset 12504 */ float fuelLoadBins[FUEL_LOAD_COUNT]; /** * RPM is float and not integer in order to use unified methods for interpolation - * offset 11768 + * offset 12568 */ float fuelRpmBins[FUEL_RPM_COUNT]; /** - * offset 11832 + * offset 12632 */ ignition_table_t ignitionTable; /** - * offset 12856 + * offset 13656 */ float ignitionLoadBins[IGN_LOAD_COUNT]; /** - * offset 12920 + * offset 13720 */ float ignitionRpmBins[IGN_RPM_COUNT]; /** - * offset 12984 + * offset 13784 */ ve_table_t veTable; /** - * offset 14008 + * offset 14808 */ float veLoadBins[FUEL_LOAD_COUNT]; /** - * offset 14072 + * offset 14872 */ float veRpmBins[FUEL_RPM_COUNT]; /** - * offset 14136 + * offset 14936 */ afr_table_t afrTable; /** - * offset 15160 + * offset 15960 */ float afrLoadBins[FUEL_LOAD_COUNT]; /** - * offset 15224 + * offset 16024 */ float afrRpmBins[FUEL_RPM_COUNT]; - /** total size 15288*/ + /** total size 16088*/ } persistent_config_s; // end -// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Wed Nov 18 19:07:01 EST 2015 +// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Tue Dec 01 20:29:19 EST 2015 diff --git a/firmware/controllers/algo/fuel_math.cpp b/firmware/controllers/algo/fuel_math.cpp index fa4f52c117..16932917bb 100644 --- a/firmware/controllers/algo/fuel_math.cpp +++ b/firmware/controllers/algo/fuel_math.cpp @@ -74,13 +74,15 @@ floatms_t getBaseFuel(int rpm DECLARE_ENGINE_PARAMETER_S) { floatms_t tpsAccelEnrich = ENGINE(tpsAccelEnrichment.getTpsEnrichment(PASS_ENGINE_PARAMETER_F)); if (CONFIG(algorithm) == LM_SPEED_DENSITY) { - return tpsAccelEnrich + getSpeedDensityFuel(rpm PASS_ENGINE_PARAMETER); + engine->engineState.baseFuel = getSpeedDensityFuel(rpm PASS_ENGINE_PARAMETER); } else if (engineConfiguration->algorithm == LM_REAL_MAF) { float maf = getRealMaf(PASS_ENGINE_PARAMETER_F) + engine->mapAccelEnrichment.getMapEnrichment(PASS_ENGINE_PARAMETER_F); - return tpsAccelEnrich + getRealMafFuel(maf, rpm PASS_ENGINE_PARAMETER); + engine->engineState.baseFuel = getRealMafFuel(maf, rpm PASS_ENGINE_PARAMETER); } else { - return tpsAccelEnrich + engine->engineState.baseTableFuel; + engine->engineState.baseFuel = engine->engineState.baseTableFuel; } + + return tpsAccelEnrich + engine->engineState.baseFuel; } float getinjectionOffset(int rpm DECLARE_ENGINE_PARAMETER_S) { diff --git a/firmware/controllers/algo/rusefi_generated.h b/firmware/controllers/algo/rusefi_generated.h index 397231c0ea..7684b23b00 100644 --- a/firmware/controllers/algo/rusefi_generated.h +++ b/firmware/controllers/algo/rusefi_generated.h @@ -722,70 +722,71 @@ #define decelEnleanmentMultiplier_offset 2204 #define mapAccelEnrichmentThreshold_offset 2208 #define mapAccelEnrichmentMultiplier_offset 2212 -#define le_formulas1_offset 2216 -#define le_formulas2_offset 2416 -#define le_formulas2_offset_hex 970 -#define le_formulas3_offset 2616 -#define le_formulas4_offset 2816 -#define le_formulas5_offset 3016 -#define le_formulas6_offset 3216 -#define le_formulas7_offset 3416 -#define le_formulas8_offset 3616 -#define le_formulas9_offset 3816 -#define le_formulas10_offset 4016 -#define le_formulas11_offset 4216 -#define le_formulas11_offset_hex 1078 -#define le_formulas12_offset 4416 -#define le_formulas12_offset_hex 1140 -#define le_formulas13_offset 4616 -#define le_formulas13_offset_hex 1208 -#define le_formulas14_offset 4816 -#define le_formulas15_offset 5016 -#define le_formulas15_offset_hex 1398 -#define le_formulas16_offset 5216 -#define le_formulas16_offset_hex 1460 -#define timingMultiplier_offset 5416 -#define timingMultiplier_offset_hex 1528 -#define timingAdditive_offset 5616 -#define cltFuelCorrBins_offset 5816 -#define cltFuelCorr_offset 5880 -#define iatFuelCorrBins_offset 5944 -#define iatFuelCorrBins_offset_hex 1738 -#define iatFuelCorr_offset 6008 -#define iatFuelCorr_offset_hex 1778 -#define crankingFuelCoef_offset 6072 -#define crankingFuelBins_offset 6104 -#define crankingCycleCoef_offset 6136 -#define crankingCycleBins_offset 6168 -#define crankingCycleBins_offset_hex 1818 -#define cltIdleCorrBins_offset 6200 -#define cltIdleCorrBins_offset_hex 1838 -#define cltIdleCorr_offset 6264 -#define cltIdleCorr_offset_hex 1878 -#define mafDecoding_offset 6328 -#define mafDecodingBins_offset 7352 -#define ignitionIatCorrTable_offset 8376 -#define ignitionIatCorrLoadBins_offset 9400 -#define ignitionIatCorrRpmBins_offset 9464 -#define injectionPhase_offset 9528 -#define injectionPhase_offset_hex 2538 -#define injPhaseLoadBins_offset 10552 -#define injPhaseLoadBins_offset_hex 2938 -#define injPhaseRpmBins_offset 10616 -#define injPhaseRpmBins_offset_hex 2978 -#define fuelTable_offset 10680 -#define fuelLoadBins_offset 11704 -#define fuelRpmBins_offset 11768 -#define ignitionTable_offset 11832 -#define ignitionLoadBins_offset 12856 -#define ignitionLoadBins_offset_hex 3238 -#define ignitionRpmBins_offset 12920 -#define ignitionRpmBins_offset_hex 3278 -#define veTable_offset 12984 -#define veLoadBins_offset 14008 -#define veRpmBins_offset 14072 -#define afrTable_offset 14136 -#define afrTable_offset_hex 3738 -#define afrLoadBins_offset 15160 -#define afrRpmBins_offset 15224 -#define TOTAL_CONFIG_SIZE 15288 +#define fatalErrorPin_offset 2216 +#define warninigPin_offset 2220 +#define configResetPin_offset 2224 +#define unused_offset 2228 +#define le_formulas1_offset 3016 +#define le_formulas2_offset 3216 +#define le_formulas3_offset 3416 +#define le_formulas4_offset 3616 +#define le_formulas5_offset 3816 +#define le_formulas6_offset 4016 +#define le_formulas7_offset 4216 +#define le_formulas7_offset_hex 1078 +#define le_formulas8_offset 4416 +#define le_formulas8_offset_hex 1140 +#define le_formulas9_offset 4616 +#define le_formulas9_offset_hex 1208 +#define le_formulas10_offset 4816 +#define le_formulas11_offset 5016 +#define le_formulas11_offset_hex 1398 +#define le_formulas12_offset 5216 +#define le_formulas12_offset_hex 1460 +#define le_formulas13_offset 5416 +#define le_formulas13_offset_hex 1528 +#define le_formulas14_offset 5616 +#define le_formulas15_offset 5816 +#define le_formulas16_offset 6016 +#define le_formulas16_offset_hex 1780 +#define timingMultiplier_offset 6216 +#define timingMultiplier_offset_hex 1848 +#define timingAdditive_offset 6416 +#define timingAdditive_offset_hex 1910 +#define cltFuelCorrBins_offset 6616 +#define cltFuelCorr_offset 6680 +#define iatFuelCorrBins_offset 6744 +#define iatFuelCorr_offset 6808 +#define crankingFuelCoef_offset 6872 +#define crankingFuelBins_offset 6904 +#define crankingCycleCoef_offset 6936 +#define crankingCycleBins_offset 6968 +#define cltIdleCorrBins_offset 7000 +#define cltIdleCorr_offset 7064 +#define mafDecoding_offset 7128 +#define mafDecodingBins_offset 8152 +#define ignitionIatCorrTable_offset 9176 +#define ignitionIatCorrLoadBins_offset 10200 +#define ignitionIatCorrRpmBins_offset 10264 +#define ignitionIatCorrRpmBins_offset_hex 2818 +#define injectionPhase_offset 10328 +#define injectionPhase_offset_hex 2858 +#define injPhaseLoadBins_offset 11352 +#define injPhaseRpmBins_offset 11416 +#define fuelTable_offset 11480 +#define fuelLoadBins_offset 12504 +#define fuelRpmBins_offset 12568 +#define fuelRpmBins_offset_hex 3118 +#define ignitionTable_offset 12632 +#define ignitionTable_offset_hex 3158 +#define ignitionLoadBins_offset 13656 +#define ignitionLoadBins_offset_hex 3558 +#define ignitionRpmBins_offset 13720 +#define ignitionRpmBins_offset_hex 3598 +#define veTable_offset 13784 +#define veLoadBins_offset 14808 +#define veRpmBins_offset 14872 +#define afrTable_offset 14936 +#define afrLoadBins_offset 15960 +#define afrRpmBins_offset 16024 +#define TOTAL_CONFIG_SIZE 16088 diff --git a/firmware/controllers/flash_main.h b/firmware/controllers/flash_main.h index 7c67760d12..a3e1569c68 100644 --- a/firmware/controllers/flash_main.h +++ b/firmware/controllers/flash_main.h @@ -11,7 +11,7 @@ #include "engine.h" -#define FLASH_DATA_VERSION 8900 +#define FLASH_DATA_VERSION 9000 void readFromFlash(void); void initFlash(Logging *sharedLogger); diff --git a/firmware/controllers/math/speed_density.cpp b/firmware/controllers/math/speed_density.cpp index dc3fef7d50..e15209be81 100644 --- a/firmware/controllers/math/speed_density.cpp +++ b/firmware/controllers/math/speed_density.cpp @@ -48,19 +48,22 @@ float getTCharge(int rpm, float tps, float coolantTemp, float airTemp) { */ #define GAS_R 0.28705 +float getAirMass(engine_configuration_s *engineConfiguration, float VE, float MAP, float tempK) { + // todo: pre-calculate cylinder displacement to save one division + float cylinderDisplacement = engineConfiguration->specs.displacement / engineConfiguration->specs.cylindersCount; + return (cylinderDisplacement * VE * MAP) / (GAS_R * tempK); +} + /** * @return per cylinder injection time, in seconds */ -float sdMath(engine_configuration_s *engineConfiguration, float VE, float MAP, float AFR, float tempK) { +float sdMath(engine_configuration_s *engineConfiguration, float airMass, float AFR) { /** * todo: pre-calculate gramm/second injector flow to save one multiplication * open question if that's needed since that's just a multiplication */ float injectorFlowRate = cc_minute_to_gramm_second(engineConfiguration->injector.flow); - // todo: pre-calculate cylinder displacement to save one division - float cylinderDisplacement = engineConfiguration->specs.displacement / engineConfiguration->specs.cylindersCount; - float airMass = (cylinderDisplacement * VE * MAP) / (GAS_R * tempK); /** * injection_pulse_duration = fuel_mass / injector_flow * fuel_mass = air_mass / target_afr @@ -86,7 +89,9 @@ float getSpeedDensityFuel(int rpm DECLARE_ENGINE_PARAMETER_S) { float adjMap = map + engine->mapAccelEnrichment.getMapEnrichment(PASS_ENGINE_PARAMETER_F); - return sdMath(engineConfiguration, ENGINE(engineState.currentVE), adjMap, ENGINE(engineState.targerAFR), tChargeK) * 1000; + engine->engineState.airMass = getAirMass(engineConfiguration, ENGINE(engineState.currentVE), adjMap, tChargeK); + + return sdMath(engineConfiguration, engine->engineState.airMass, ENGINE(engineState.targerAFR)) * 1000; } static const baro_corr_table_t default_baro_corr = { diff --git a/firmware/controllers/math/speed_density.h b/firmware/controllers/math/speed_density.h index aa89bdcf3d..67f6af1c8b 100644 --- a/firmware/controllers/math/speed_density.h +++ b/firmware/controllers/math/speed_density.h @@ -11,7 +11,8 @@ float getTCharge(int rpm, float tps, float coolantTemp, float airTemp); void setDetaultVETable(persistent_config_s *config); -float sdMath(engine_configuration_s *engineConfiguration, float VE, float MAP, float AFR, float tempK); +float getAirMass(engine_configuration_s *engineConfiguration, float VE, float MAP, float tempK); +float sdMath(engine_configuration_s *engineConfiguration, float airMass, float AFR); #define gramm_second_to_cc_minute(gs) ((gs) / 0.0119997981) diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 7655bc080f..5ec53bbe28 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -230,7 +230,7 @@ adc_channel_e fuelLevelSensor; float vehicleSpeedCoef;This coefficient translates vehicle speed input frequency (in Hz) into vehicle speed, km/h;"coef", 1, 0, 0.01, 2000.0, 2 -custom can_nbc_e 4 bits, U32, @OFFSET@, [0:1], "BMW", "FIAT", "VAG" , "INVALID" +custom can_nbc_e 4 bits, U32, @OFFSET@, [0:1], "BMW", "FIAT", "VAG" , "MAZDA RX8" can_nbc_e canNbcType; int canSleepPeriod;CANbus thread period, ms;"ms", 1, 0, 0, 1000.0, 2 @@ -621,6 +621,13 @@ baro_corr_table_t baroCorrTable; float mapAccelEnrichmentThreshold;;"roc", 1, 0, 0, 200, 3 float mapAccelEnrichmentMultiplier;;"coeff", 1, 0, 0, 200, 3 + + brain_pin_e fatalErrorPin; + brain_pin_e warninigPin; + brain_pin_e configResetPin; + int[197] unused; + + end_struct engine_configuration_s engineConfiguration; diff --git a/firmware/rusefi.cpp b/firmware/rusefi.cpp index 3bbc0bfb5d..4565e41ba4 100644 --- a/firmware/rusefi.cpp +++ b/firmware/rusefi.cpp @@ -275,5 +275,5 @@ int getRusEfiVersion(void) { return 123; // this is here to make the compiler happy about the unused array if (UNUSED_CCM_SIZE[0] * 0 != 0) return 3211; // this is here to make the compiler happy about the unused array - return 20151124; + return 20151201; } diff --git a/firmware/tunerstudio/rusefi.ini b/firmware/tunerstudio/rusefi.ini index 2de22734a7..636c79cd78 100644 --- a/firmware/tunerstudio/rusefi.ini +++ b/firmware/tunerstudio/rusefi.ini @@ -3,8 +3,15 @@ ; this should stop TS from looking for the CAN ID in the 2nd byte location and allow the page reads to work correctly. enable2ndByteCanID = false +;This enables the "full" CAN/serial commands so this INI can be used anywhere on the CAN network. +#unset CAN_COMMANDS + [TunerStudio] +#if CAN_COMMANDS + queryCommand = "r\x00\x0f\x00\x00\x00\x14" ; Verify against signature. +#else queryCommand = "S" +#endif signature = "MShift v0.01" ; signature is expected to be 7 or more characters. [Constants] @@ -40,9 +47,9 @@ enable2ndByteCanID = false ; see PAGE_0_SIZE in C source code ; CONFIG_DEFINITION_START -; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Wed Nov 18 19:07:01 EST 2015 +; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Tue Dec 01 20:29:19 EST 2015 -pageSize = 15288 +pageSize = 16088 page = 1 engineType = bits, S32, 0, [0:2], "AUDI_AAN", "DODGE_NEON_1995", "FORD_ASPIRE_1996", "FORD_FIESTA", "NISSAN_PRIMERA", "HONDA_ACCORD", "FORD_INLINE_6_1995", "GY6_139QMB" ;skipping headerMagicValue offset 4 @@ -114,7 +121,7 @@ page = 1 fanOffTemperature = scalar, F32, 480, "*C", 1, 0, 0, 1000.0, 2 fuelLevelSensor = bits, U32, 484, [0:4] "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PB0", "PB1", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "Disabled", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" vehicleSpeedCoef = scalar, F32, 488, "coef", 1, 0, 0.01, 2000.0, 2 - canNbcType = bits, U32, 492, [0:1], "BMW", "FIAT", "VAG" , "INVALID" + canNbcType = bits, U32, 492, [0:1], "BMW", "FIAT", "VAG" , "MAZDA RX8" canSleepPeriod = scalar, S32, 496, "ms", 1, 0, 0, 1000.0, 2 operationMode = bits, U32, 500, [0:1], "INVALID", "4 stroke without cam sensor", "4 stroke with cam sensor", "2 stroke" displayMode = bits, U32, 504, [0:1], "none", "hd44780", "hd44780 over pcf8574", "INVALID" @@ -510,55 +517,59 @@ page = 1 decelEnleanmentMultiplier = scalar, F32, 2204, "coeff", 1, 0, 0, 200, 3 mapAccelEnrichmentThreshold = scalar, F32, 2208, "roc", 1, 0, 0, 200, 3 mapAccelEnrichmentMultiplier = scalar, F32, 2212, "coeff", 1, 0, 0, 200, 3 - le_formulas1 = array, U08, 2216, [200],"char", 1, 0, 0.0, 3.0, 2 - le_formulas2 = array, U08, 2416, [200],"char", 1, 0, 0.0, 3.0, 2 - le_formulas3 = array, U08, 2616, [200],"char", 1, 0, 0.0, 3.0, 2 - le_formulas4 = array, U08, 2816, [200],"char", 1, 0, 0.0, 3.0, 2 - le_formulas5 = array, U08, 3016, [200],"char", 1, 0, 0.0, 3.0, 2 - le_formulas6 = array, U08, 3216, [200],"char", 1, 0, 0.0, 3.0, 2 - le_formulas7 = array, U08, 3416, [200],"char", 1, 0, 0.0, 3.0, 2 - le_formulas8 = array, U08, 3616, [200],"char", 1, 0, 0.0, 3.0, 2 - le_formulas9 = array, U08, 3816, [200],"char", 1, 0, 0.0, 3.0, 2 - le_formulas10 = array, U08, 4016, [200],"char", 1, 0, 0.0, 3.0, 2 - le_formulas11 = array, U08, 4216, [200],"char", 1, 0, 0.0, 3.0, 2 - le_formulas12 = array, U08, 4416, [200],"char", 1, 0, 0.0, 3.0, 2 - le_formulas13 = array, U08, 4616, [200],"char", 1, 0, 0.0, 3.0, 2 - le_formulas14 = array, U08, 4816, [200],"char", 1, 0, 0.0, 3.0, 2 - le_formulas15 = array, U08, 5016, [200],"char", 1, 0, 0.0, 3.0, 2 - le_formulas16 = array, U08, 5216, [200],"char", 1, 0, 0.0, 3.0, 2 - timingMultiplier = array, U08, 5416, [200],"char", 1, 0, 0.0, 3.0, 2 - timingAdditive = array, U08, 5616, [200],"char", 1, 0, 0.0, 3.0, 2 - cltFuelCorrBins = array, F32, 5816, [16], "C", 1, 0, -100.0, 250.0, 2 - cltFuelCorr = array, F32, 5880, [16], "%", 1, 0, 0.0, 500.0, 2 - iatFuelCorrBins = array, F32, 5944, [16], "C", 1, 0, -100.0, 250.0, 2 - iatFuelCorr = array, F32, 6008, [16], "%", 1, 0, 0.0, 500.0, 2 - crankingFuelCoef = array, F32, 6072, [8], "%", 1, 0, 0.0, 700.0, 2 - crankingFuelBins = array, F32, 6104, [8], "C", 1, 0, -80.0, 170.0, 2 - crankingCycleCoef = array, F32, 6136, [8], "%", 1, 0, 0.0, 500.0, 2 - crankingCycleBins = array, F32, 6168, [8], "C", 1, 0, -80.0, 170.0, 2 - cltIdleCorrBins = array, F32, 6200, [16], "C", 1, 0, -100.0, 250.0, 2 - cltIdleCorr = array, F32, 6264, [16], "%", 1, 0, 0.0, 500.0, 2 - mafDecoding = array, F32, 6328, [256], "kg/hour", 1, 0, -500.0, 4000.0, 2 - mafDecodingBins = array, F32, 7352, [256], "V", 1, 0, -5.0, 150.0, 2 - ignitionIatCorrTable = array, F32, 8376, [16x16],"deg", 1, 0, -720, 720, 2 - ignitionIatCorrLoadBins = array, F32, 9400, [16], "Load", 1, 0.0, 0, 300.0, 2 - ignitionIatCorrRpmBins = array, F32, 9464, [16], "RPM", 1, 0.0, 0, 18000.0, 2 - injectionPhase = array, F32, 9528, [16x16],"deg", 1, 0, -720, 720, 2 - injPhaseLoadBins = array, F32, 10552, [16], "Load", 1, 0.0, 0, 300.0, 2 - injPhaseRpmBins = array, F32, 10616, [16], "RPM", 1, 0.0, 0, 18000.0, 2 - fuelTable = array, F32, 10680, [16x16],"ms", 1, 0, 0.0, 300.0, 2 - fuelLoadBins = array, F32, 11704, [16], "V", 1, 0, 0.0, 300.0, 2 - fuelRpmBins = array, F32, 11768, [16], "RPM", 1, 0, 0.0, 25500.0, 2 - ignitionTable = array, F32, 11832, [16x16],"deg", 1, 0, -720, 720, 2 - ignitionLoadBins = array, F32, 12856, [16], "Load", 1, 0.0, 0, 300.0, 2 - ignitionRpmBins = array, F32, 12920, [16], "RPM", 1, 0.0, 0, 18000.0, 2 - veTable = array, F32, 12984, [16x16],"%", 1, 0, 0, 999.0, 2 - veLoadBins = array, F32, 14008, [16], "%", 1, 0.0, 0, 300.0, 2 - veRpmBins = array, F32, 14072, [16], "RPM", 1, 0.0, 0, 18000.0, 2 - afrTable = array, F32, 14136, [16x16],"deg", 1, 0, 0, 25.0, 2 - afrLoadBins = array, F32, 15160, [16], "%", 1, 0.0, 0, 300.0, 2 - afrRpmBins = array, F32, 15224, [16], "RPM", 1, 0.0, 0, 18000.0, 2 -; total TS size = 15288 + fatalErrorPin = bits, U32, 2216, [0:6], "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6", "PE7", "PE8", "PE9", "PE10", "PE11", "PE12", "PE13", "PE14", "PE15", "NONE", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" + warninigPin = bits, U32, 2220, [0:6], "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6", "PE7", "PE8", "PE9", "PE10", "PE11", "PE12", "PE13", "PE14", "PE15", "NONE", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" + configResetPin = bits, U32, 2224, [0:6], "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6", "PE7", "PE8", "PE9", "PE10", "PE11", "PE12", "PE13", "PE14", "PE15", "NONE", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" +;skipping unused offset 2228 + le_formulas1 = array, U08, 3016, [200],"char", 1, 0, 0.0, 3.0, 2 + le_formulas2 = array, U08, 3216, [200],"char", 1, 0, 0.0, 3.0, 2 + le_formulas3 = array, U08, 3416, [200],"char", 1, 0, 0.0, 3.0, 2 + le_formulas4 = array, U08, 3616, [200],"char", 1, 0, 0.0, 3.0, 2 + le_formulas5 = array, U08, 3816, [200],"char", 1, 0, 0.0, 3.0, 2 + le_formulas6 = array, U08, 4016, [200],"char", 1, 0, 0.0, 3.0, 2 + le_formulas7 = array, U08, 4216, [200],"char", 1, 0, 0.0, 3.0, 2 + le_formulas8 = array, U08, 4416, [200],"char", 1, 0, 0.0, 3.0, 2 + le_formulas9 = array, U08, 4616, [200],"char", 1, 0, 0.0, 3.0, 2 + le_formulas10 = array, U08, 4816, [200],"char", 1, 0, 0.0, 3.0, 2 + le_formulas11 = array, U08, 5016, [200],"char", 1, 0, 0.0, 3.0, 2 + le_formulas12 = array, U08, 5216, [200],"char", 1, 0, 0.0, 3.0, 2 + le_formulas13 = array, U08, 5416, [200],"char", 1, 0, 0.0, 3.0, 2 + le_formulas14 = array, U08, 5616, [200],"char", 1, 0, 0.0, 3.0, 2 + le_formulas15 = array, U08, 5816, [200],"char", 1, 0, 0.0, 3.0, 2 + le_formulas16 = array, U08, 6016, [200],"char", 1, 0, 0.0, 3.0, 2 + timingMultiplier = array, U08, 6216, [200],"char", 1, 0, 0.0, 3.0, 2 + timingAdditive = array, U08, 6416, [200],"char", 1, 0, 0.0, 3.0, 2 + cltFuelCorrBins = array, F32, 6616, [16], "C", 1, 0, -100.0, 250.0, 2 + cltFuelCorr = array, F32, 6680, [16], "%", 1, 0, 0.0, 500.0, 2 + iatFuelCorrBins = array, F32, 6744, [16], "C", 1, 0, -100.0, 250.0, 2 + iatFuelCorr = array, F32, 6808, [16], "%", 1, 0, 0.0, 500.0, 2 + crankingFuelCoef = array, F32, 6872, [8], "%", 1, 0, 0.0, 700.0, 2 + crankingFuelBins = array, F32, 6904, [8], "C", 1, 0, -80.0, 170.0, 2 + crankingCycleCoef = array, F32, 6936, [8], "%", 1, 0, 0.0, 500.0, 2 + crankingCycleBins = array, F32, 6968, [8], "C", 1, 0, -80.0, 170.0, 2 + cltIdleCorrBins = array, F32, 7000, [16], "C", 1, 0, -100.0, 250.0, 2 + cltIdleCorr = array, F32, 7064, [16], "%", 1, 0, 0.0, 500.0, 2 + mafDecoding = array, F32, 7128, [256], "kg/hour", 1, 0, -500.0, 4000.0, 2 + mafDecodingBins = array, F32, 8152, [256], "V", 1, 0, -5.0, 150.0, 2 + ignitionIatCorrTable = array, F32, 9176, [16x16],"deg", 1, 0, -720, 720, 2 + ignitionIatCorrLoadBins = array, F32, 10200, [16], "Load", 1, 0.0, 0, 300.0, 2 + ignitionIatCorrRpmBins = array, F32, 10264, [16], "RPM", 1, 0.0, 0, 18000.0, 2 + injectionPhase = array, F32, 10328, [16x16],"deg", 1, 0, -720, 720, 2 + injPhaseLoadBins = array, F32, 11352, [16], "Load", 1, 0.0, 0, 300.0, 2 + injPhaseRpmBins = array, F32, 11416, [16], "RPM", 1, 0.0, 0, 18000.0, 2 + fuelTable = array, F32, 11480, [16x16],"ms", 1, 0, 0.0, 300.0, 2 + fuelLoadBins = array, F32, 12504, [16], "V", 1, 0, 0.0, 300.0, 2 + fuelRpmBins = array, F32, 12568, [16], "RPM", 1, 0, 0.0, 25500.0, 2 + ignitionTable = array, F32, 12632, [16x16],"deg", 1, 0, -720, 720, 2 + ignitionLoadBins = array, F32, 13656, [16], "Load", 1, 0.0, 0, 300.0, 2 + ignitionRpmBins = array, F32, 13720, [16], "RPM", 1, 0.0, 0, 18000.0, 2 + veTable = array, F32, 13784, [16x16],"%", 1, 0, 0, 999.0, 2 + veLoadBins = array, F32, 14808, [16], "%", 1, 0.0, 0, 300.0, 2 + veRpmBins = array, F32, 14872, [16], "RPM", 1, 0.0, 0, 18000.0, 2 + afrTable = array, F32, 14936, [16x16],"deg", 1, 0, 0, 25.0, 2 + afrLoadBins = array, F32, 15960, [16], "%", 1, 0.0, 0, 300.0, 2 + afrRpmBins = array, F32, 16024, [16], "RPM", 1, 0.0, 0, 18000.0, 2 +; total TS size = 16088 ; CONFIG_DEFINITION_END @@ -606,7 +617,12 @@ page = 1 ; see TS_FILE_VERSION in firmware code fileVersion = { 20150625 } +#if CAN_COMMANDS +;full version that works anywhere - be sure to change the no. bytes requested + ochGetCommand = "r\x00\x07\x00\x00\x01\x98" +#else ochGetCommand = "O" +#endif ; see OUTPUT_CHANNELS_SIZE in console source code ochBlockSize = 196 diff --git a/java_console/.idea/libraries/jcip_annotations_1_0.xml b/java_console/.idea/libraries/jcip_annotations.xml similarity index 77% rename from java_console/.idea/libraries/jcip_annotations_1_0.xml rename to java_console/.idea/libraries/jcip_annotations.xml index 33c8236843..3f7017513f 100644 --- a/java_console/.idea/libraries/jcip_annotations_1_0.xml +++ b/java_console/.idea/libraries/jcip_annotations.xml @@ -1,5 +1,5 @@ - + diff --git a/java_console/.idea/libraries/jlatexmath.xml b/java_console/.idea/libraries/jlatexmath.xml new file mode 100644 index 0000000000..eb594b5d59 --- /dev/null +++ b/java_console/.idea/libraries/jlatexmath.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/java_console/.idea/libraries/miglayout_4_0.xml b/java_console/.idea/libraries/miglayout.xml similarity index 79% rename from java_console/.idea/libraries/miglayout_4_0.xml rename to java_console/.idea/libraries/miglayout.xml index 527499cd32..1fc7c4a7e8 100644 --- a/java_console/.idea/libraries/miglayout_4_0.xml +++ b/java_console/.idea/libraries/miglayout.xml @@ -1,5 +1,5 @@ - + diff --git a/java_console/.idea/libraries/swing_layout_1_0.xml b/java_console/.idea/libraries/swing_layout.xml similarity index 78% rename from java_console/.idea/libraries/swing_layout_1_0.xml rename to java_console/.idea/libraries/swing_layout.xml index 4893bfcb0c..835872eb08 100644 --- a/java_console/.idea/libraries/swing_layout_1_0.xml +++ b/java_console/.idea/libraries/swing_layout.xml @@ -1,5 +1,5 @@ - + diff --git a/java_console/build.xml b/java_console/build.xml index e2a52309b2..173e1b970a 100644 --- a/java_console/build.xml +++ b/java_console/build.xml @@ -8,7 +8,7 @@ + classpath="lib/jcip-annotations-1.0.jar:lib/jlatexmath-1.0.3.jar:lib/swing-layout-1.0.jar:lib/jep.jar:lib/log4j.jar:lib/junit.jar:lib/jssc.jar:lib/SteelSeries-3.9.30.jar:lib/annotations.jar:lib/miglayout-4.0.jar:lib/surfaceplotter-2.0.1.jar"> @@ -68,6 +68,7 @@ + diff --git a/java_console/io/io.iml b/java_console/io/io.iml index 743cadfef6..16f29aca3b 100644 --- a/java_console/io/io.iml +++ b/java_console/io/io.iml @@ -12,6 +12,6 @@ - + \ No newline at end of file diff --git a/java_console/io/src/com/rusefi/TsPageSize.java b/java_console/io/src/com/rusefi/TsPageSize.java index f658c6e164..701eaf7f19 100644 --- a/java_console/io/src/com/rusefi/TsPageSize.java +++ b/java_console/io/src/com/rusefi/TsPageSize.java @@ -1,5 +1,5 @@ package com.rusefi; public interface TsPageSize { - int IMAGE_SIZE = 15288; + int IMAGE_SIZE = 16088; } diff --git a/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java b/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java index a521ab95b2..929b15189e 100644 --- a/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java +++ b/java_console/io/src/com/rusefi/binaryprotocol/BinaryProtocol.java @@ -33,7 +33,8 @@ import static com.rusefi.binaryprotocol.IoHelper.*; * 3/6/2015 */ public class BinaryProtocol { - private static final int OUTPUT_CHANNELS_SIZE = 196; + // todo: is this auto-synched with rusefi.ini? + public static final int OUTPUT_CHANNELS_SIZE = 196; private static final int BLOCKING_FACTOR = 256; private static final byte RESPONSE_OK = 0; @@ -51,6 +52,10 @@ public class BinaryProtocol { public static final char COMMAND_HELLO = 'S'; public static final char COMMAND_PROTOCOL = 'F'; public static final char COMMAND_CRC_CHECK_COMMAND = 'k'; + public static final char COMMAND_PAGE = 'P'; + public static final char COMMAND_READ = 'R'; + public static final char COMMAND_CHUNK_WRITE = 'C'; + public static final char COMMAND_BURN = 'B'; private final Logger logger; private final IoStream stream; @@ -65,6 +70,8 @@ public class BinaryProtocol { @Deprecated public static BinaryProtocol instance; public boolean isClosed; + // todo: make a singleton? + public static byte[] currentOutputs; public BinaryProtocol(final Logger logger, IoStream stream) { this.logger = logger; @@ -269,7 +276,7 @@ public class BinaryProtocol { byte[] packet = new byte[packetSize]; incomingData.getData(packet); int packetCrc = swap32(incomingData.getInt()); - int actualCrc = crc32(packet); + int actualCrc = getCrc32(packet); boolean isCrcOk = actualCrc == packetCrc; if (!isCrcOk) { @@ -298,7 +305,7 @@ public class BinaryProtocol { int requestSize = Math.min(remainingSize, BLOCKING_FACTOR); byte packet[] = new byte[7]; - packet[0] = 'R'; + packet[0] = COMMAND_READ; putShort(packet, 1, 0); // page putShort(packet, 3, swap16(offset)); putShort(packet, 5, swap16(requestSize)); @@ -357,7 +364,7 @@ public class BinaryProtocol { isBurnPending = true; byte packet[] = new byte[7 + size]; - packet[0] = 'C'; + packet[0] = COMMAND_CHUNK_WRITE; putShort(packet, 1, 0); // page putShort(packet, 3, swap16(offset)); putShort(packet, 5, swap16(size)); @@ -383,7 +390,7 @@ public class BinaryProtocol { while (true) { if (isClosed) return; - byte[] response = executeCommand(new byte[]{'B'}, "burn", false); + byte[] response = executeCommand(new byte[]{COMMAND_BURN}, "burn", false); if (!checkResponseCode(response, RESPONSE_BURN_OK) || response.length != 1) { continue; } @@ -461,6 +468,8 @@ public class BinaryProtocol { if (response == null || response.length != (OUTPUT_CHANNELS_SIZE + 1) || response[0] != RESPONSE_OK) return; + currentOutputs = response; + for (Sensor sensor : Sensor.values()) { if (sensor.getType() == FieldType.FLOAT) { diff --git a/java_console/io/src/com/rusefi/binaryprotocol/IncomingDataBuffer.java b/java_console/io/src/com/rusefi/binaryprotocol/IncomingDataBuffer.java index 38eb8de361..7ad6d48b36 100644 --- a/java_console/io/src/com/rusefi/binaryprotocol/IncomingDataBuffer.java +++ b/java_console/io/src/com/rusefi/binaryprotocol/IncomingDataBuffer.java @@ -29,7 +29,7 @@ public class IncomingDataBuffer { logger.trace(freshData.length + " byte(s) arrived"); synchronized (cbb) { if (cbb.size() - cbb.length() < freshData.length) { - logger.error("buffer overflow not expected"); + logger.error("IncomingDataBuffer: buffer overflow not expected"); cbb.clear(); } cbb.put(freshData); diff --git a/java_console/io/src/com/rusefi/binaryprotocol/IoHelper.java b/java_console/io/src/com/rusefi/binaryprotocol/IoHelper.java index 2925b6fdac..e6e6c8f859 100644 --- a/java_console/io/src/com/rusefi/binaryprotocol/IoHelper.java +++ b/java_console/io/src/com/rusefi/binaryprotocol/IoHelper.java @@ -9,9 +9,13 @@ import java.util.zip.CRC32; * 3/6/2015 */ public class IoHelper { - public static int crc32(byte[] packet) { + public static int getCrc32(byte[] packet) { + return getCrc32(packet, 0, packet.length); + } + + public static int getCrc32(byte[] packet, int offset, int length) { CRC32 c = new CRC32(); - c.update(packet); + c.update(packet, offset, length); return (int) c.getValue(); } @@ -25,7 +29,7 @@ public class IoHelper { packet[1] = (byte) command.length; System.arraycopy(command, 0, packet, 2, command.length); - int crc = crc32(command); + int crc = getCrc32(command); putInt(packet, packet.length - 4, crc); return packet; diff --git a/java_console/io/src/com/rusefi/binaryprotocol/test/CRCTest.java b/java_console/io/src/com/rusefi/binaryprotocol/test/CRCTest.java index 4ff8333de4..b6ca6ab785 100644 --- a/java_console/io/src/com/rusefi/binaryprotocol/test/CRCTest.java +++ b/java_console/io/src/com/rusefi/binaryprotocol/test/CRCTest.java @@ -17,11 +17,11 @@ public class CRCTest { public void testCrc() { { byte[] a = {'A'}; - assertEquals(0xD3D99E8B, IoHelper.crc32(a)); + assertEquals(0xD3D99E8B, IoHelper.getCrc32(a)); } { byte[] a = {'S'}; - assertEquals(0x2060EFC3, IoHelper.crc32(a)); + assertEquals(0x2060EFC3, IoHelper.getCrc32(a)); } } diff --git a/java_console/io/src/com/rusefi/io/tcp/BinaryProtocolServer.java b/java_console/io/src/com/rusefi/io/tcp/BinaryProtocolServer.java index 00300afeac..313fc76e7e 100644 --- a/java_console/io/src/com/rusefi/io/tcp/BinaryProtocolServer.java +++ b/java_console/io/src/com/rusefi/io/tcp/BinaryProtocolServer.java @@ -4,10 +4,7 @@ import com.rusefi.FileLog; import com.rusefi.binaryprotocol.BinaryProtocol; import com.rusefi.binaryprotocol.IoHelper; -import java.io.ByteArrayInputStream; -import java.io.DataInputStream; -import java.io.IOException; -import java.io.OutputStream; +import java.io.*; import java.net.ServerSocket; import java.net.Socket; @@ -86,11 +83,11 @@ public class BinaryProtocolServer { System.out.println("Got [" + (char) command + "/" + command + "] command"); int crc = in.readInt(); - if (crc != IoHelper.crc32(packet)) + if (crc != IoHelper.getCrc32(packet)) throw new IllegalStateException("CRC mismatch"); - TcpIoStream stream = new TcpIoStream(clientSocket.getOutputStream(), null); + TcpIoStream stream = new TcpIoStream(clientSocket.getInputStream(), clientSocket.getOutputStream()); if (command == BinaryProtocol.COMMAND_HELLO) { BinaryProtocol.sendCrcPacket((TS_OK + TS_SIGNATURE).getBytes(), FileLog.LOGGER, stream); } else if (command == BinaryProtocol.COMMAND_PROTOCOL) { @@ -99,12 +96,42 @@ public class BinaryProtocolServer { } else if (command == BinaryProtocol.COMMAND_CRC_CHECK_COMMAND) { short page = dis.readShort(); short offset = dis.readShort(); - short count = dis.readShort(); + short count = dis.readShort(); // no swap here? interesting! System.out.println("CRC check " + page + "/" + offset + "/" + count); + BinaryProtocol bp = BinaryProtocol.instance; + int result = IoHelper.getCrc32(bp.getController().getContent(), offset, count); + ByteArrayOutputStream response = new ByteArrayOutputStream(); + response.write(TS_OK.charAt(0)); + new DataOutputStream(response).write(result); + BinaryProtocol.sendCrcPacket(response.toByteArray(), FileLog.LOGGER, stream); + } else if (command == BinaryProtocol.COMMAND_PAGE) { + BinaryProtocol.sendCrcPacket(TS_OK.getBytes(), FileLog.LOGGER, stream); + } else if (command == BinaryProtocol.COMMAND_READ) { + short page = dis.readShort(); + short offset = swap16(dis.readShort()); + short count = swap16(dis.readShort()); + System.out.println("read " + page + "/" + offset + "/" + count); + BinaryProtocol bp = BinaryProtocol.instance; + + byte[] response = new byte[1 + count]; + response[0] = (byte) TS_OK.charAt(0); + System.arraycopy(bp.getController().getContent(), offset, response, 1, count); + BinaryProtocol.sendCrcPacket(response, FileLog.LOGGER, stream); + } else if (command == BinaryProtocol.COMMAND_OUTPUTS) { + + byte[] response = new byte[1 + BinaryProtocol.OUTPUT_CHANNELS_SIZE]; + response[0] = (byte) TS_OK.charAt(0); + byte[] currentOutputs = BinaryProtocol.currentOutputs; + if (currentOutputs != null) + System.arraycopy(currentOutputs, 1, response, 1, BinaryProtocol.OUTPUT_CHANNELS_SIZE); + BinaryProtocol.sendCrcPacket(response, FileLog.LOGGER, stream); + } else { + FileLog.MAIN.logLine("Error: unknown command " + command); } - - } + } + private static short swap16(short x) { + return (short) (((x) << 8) | ((x) >> 8)); } } \ No newline at end of file diff --git a/java_console/io/src/com/rusefi/io/tcp/TcpConnector.java b/java_console/io/src/com/rusefi/io/tcp/TcpConnector.java index 3cd132619d..fea39fb68c 100644 --- a/java_console/io/src/com/rusefi/io/tcp/TcpConnector.java +++ b/java_console/io/src/com/rusefi/io/tcp/TcpConnector.java @@ -100,7 +100,7 @@ public class TcpConnector implements LinkConnector { }; // ioStream.setDataListener(listener1); - bp = new BinaryProtocol(FileLog.LOGGER, new TcpIoStream(os, stream)); + bp = new BinaryProtocol(FileLog.LOGGER, new TcpIoStream(stream, os)); boolean result = bp.connectAndReadConfiguration(listener1); if (result) { diff --git a/java_console/io/src/com/rusefi/io/tcp/TcpIoStream.java b/java_console/io/src/com/rusefi/io/tcp/TcpIoStream.java index 185586d790..63dcb0a7ea 100644 --- a/java_console/io/src/com/rusefi/io/tcp/TcpIoStream.java +++ b/java_console/io/src/com/rusefi/io/tcp/TcpIoStream.java @@ -5,7 +5,6 @@ import com.rusefi.io.DataListener; import com.rusefi.io.IoStream; import com.rusefi.io.LinkManager; -import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -15,12 +14,16 @@ import java.io.OutputStream; * 5/11/2015. */ public class TcpIoStream implements IoStream { - private final OutputStream os; - private final InputStream stream; + private final InputStream input; + private final OutputStream output; - public TcpIoStream(OutputStream os, InputStream stream) { - this.os = os; - this.stream = stream; + public TcpIoStream(InputStream input, OutputStream output) { + if (input == null) + throw new NullPointerException("input"); + if (output == null) + throw new NullPointerException("output"); + this.output = output; + this.input = input; } @Override @@ -30,8 +33,8 @@ public class TcpIoStream implements IoStream { @Override public void write(byte[] bytes) throws IOException { - os.write(bytes); - os.flush(); + output.write(bytes); + output.flush(); } @Override @@ -50,13 +53,12 @@ public class TcpIoStream implements IoStream { byte b[] = new byte[1]; while (true) { try { - int result = stream.read(b); - if (result == -1) { - System.err.println("End of stream?"); - } + int result = input.read(b); + if (result == -1) + throw new IOException("TcpIoStream: End of input?"); listener.onDataArrived(b); } catch (IOException e) { - System.err.println("End of connection"); + System.err.println("TcpIoStream: End of connection"); return; } } diff --git a/java_console/io/src/com/rusefi/io/tcp/test/BinaryProtocolServerSandbox.java b/java_console/io/src/com/rusefi/io/tcp/test/BinaryProtocolServerSandbox.java index f760a22d95..eb31f8c215 100644 --- a/java_console/io/src/com/rusefi/io/tcp/test/BinaryProtocolServerSandbox.java +++ b/java_console/io/src/com/rusefi/io/tcp/test/BinaryProtocolServerSandbox.java @@ -1,9 +1,20 @@ package com.rusefi.io.tcp.test; +import com.rusefi.ConfigurationImage; +import com.rusefi.FileLog; +import com.rusefi.binaryprotocol.BinaryProtocol; import com.rusefi.io.tcp.BinaryProtocolServer; +import com.rusefi.io.tcp.TcpIoStream; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; class BinaryProtocolServerSandbox { public static void main(String[] args) { + TcpIoStream stream = new TcpIoStream(new ByteArrayInputStream(new byte[0]), new ByteArrayOutputStream()); + BinaryProtocol.instance = new BinaryProtocol(FileLog.LOGGER, stream); + BinaryProtocol.instance.setController(new ConfigurationImage(new byte[14008])); + BinaryProtocol.currentOutputs = new byte[1 + BinaryProtocol.OUTPUT_CHANNELS_SIZE]; BinaryProtocolServer.start(); } } \ No newline at end of file diff --git a/java_console/lib/jlatexmath-1.0.3.jar b/java_console/lib/jlatexmath-1.0.3.jar new file mode 100644 index 0000000000..d9b2223e2d Binary files /dev/null and b/java_console/lib/jlatexmath-1.0.3.jar differ diff --git a/java_console/lib/jlatexmath-src-1.0.3.zip b/java_console/lib/jlatexmath-src-1.0.3.zip new file mode 100644 index 0000000000..675b9b3365 Binary files /dev/null and b/java_console/lib/jlatexmath-src-1.0.3.zip differ diff --git a/java_console/models/src/com/rusefi/config/Fields.java b/java_console/models/src/com/rusefi/config/Fields.java index 4481aade06..08ad035cfe 100644 --- a/java_console/models/src/com/rusefi/config/Fields.java +++ b/java_console/models/src/com/rusefi/config/Fields.java @@ -1,6 +1,6 @@ package com.rusefi.config; -// this file was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Wed Nov 18 19:07:01 EST 2015 +// this file was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Tue Dec 01 20:29:19 EST 2015 public class Fields { public static final Field ENGINETYPE = new Field("ENGINETYPE", 0, FieldType.INT); public static final Field HEADERMAGICVALUE = new Field("HEADERMAGICVALUE", 4, FieldType.INT); @@ -454,28 +454,31 @@ public class Fields { public static final Field DECELENLEANMENTMULTIPLIER = new Field("DECELENLEANMENTMULTIPLIER", 2204, FieldType.FLOAT); public static final Field MAPACCELENRICHMENTTHRESHOLD = new Field("MAPACCELENRICHMENTTHRESHOLD", 2208, FieldType.FLOAT); public static final Field MAPACCELENRICHMENTMULTIPLIER = new Field("MAPACCELENRICHMENTMULTIPLIER", 2212, FieldType.FLOAT); - public static final Field LE_FORMULAS1 = new Field("LE_FORMULAS1", 2216, FieldType.INT); - public static final Field LE_FORMULAS2 = new Field("LE_FORMULAS2", 2416, FieldType.INT); - public static final Field LE_FORMULAS3 = new Field("LE_FORMULAS3", 2616, FieldType.INT); - public static final Field LE_FORMULAS4 = new Field("LE_FORMULAS4", 2816, FieldType.INT); - public static final Field LE_FORMULAS5 = new Field("LE_FORMULAS5", 3016, FieldType.INT); - public static final Field LE_FORMULAS6 = new Field("LE_FORMULAS6", 3216, FieldType.INT); - public static final Field LE_FORMULAS7 = new Field("LE_FORMULAS7", 3416, FieldType.INT); - public static final Field LE_FORMULAS8 = new Field("LE_FORMULAS8", 3616, FieldType.INT); - public static final Field LE_FORMULAS9 = new Field("LE_FORMULAS9", 3816, FieldType.INT); - public static final Field LE_FORMULAS10 = new Field("LE_FORMULAS10", 4016, FieldType.INT); - public static final Field LE_FORMULAS11 = new Field("LE_FORMULAS11", 4216, FieldType.INT); - public static final Field LE_FORMULAS12 = new Field("LE_FORMULAS12", 4416, FieldType.INT); - public static final Field LE_FORMULAS13 = new Field("LE_FORMULAS13", 4616, FieldType.INT); - public static final Field LE_FORMULAS14 = new Field("LE_FORMULAS14", 4816, FieldType.INT); - public static final Field LE_FORMULAS15 = new Field("LE_FORMULAS15", 5016, FieldType.INT); - public static final Field LE_FORMULAS16 = new Field("LE_FORMULAS16", 5216, FieldType.INT); - public static final Field TIMINGMULTIPLIER = new Field("TIMINGMULTIPLIER", 5416, FieldType.INT); - public static final Field TIMINGADDITIVE = new Field("TIMINGADDITIVE", 5616, FieldType.INT); - public static final Field IGNITIONIATCORRTABLE = new Field("IGNITIONIATCORRTABLE", 8376, FieldType.INT); - public static final Field INJECTIONPHASE = new Field("INJECTIONPHASE", 9528, FieldType.INT); - public static final Field FUELTABLE = new Field("FUELTABLE", 10680, FieldType.INT); - public static final Field IGNITIONTABLE = new Field("IGNITIONTABLE", 11832, FieldType.INT); - public static final Field VETABLE = new Field("VETABLE", 12984, FieldType.INT); - public static final Field AFRTABLE = new Field("AFRTABLE", 14136, FieldType.INT); + public static final Field FATALERRORPIN = new Field("FATALERRORPIN", 2216, FieldType.INT, brain_pin_e); + public static final Field WARNINIGPIN = new Field("WARNINIGPIN", 2220, FieldType.INT, brain_pin_e); + public static final Field CONFIGRESETPIN = new Field("CONFIGRESETPIN", 2224, FieldType.INT, brain_pin_e); + public static final Field LE_FORMULAS1 = new Field("LE_FORMULAS1", 3016, FieldType.INT); + public static final Field LE_FORMULAS2 = new Field("LE_FORMULAS2", 3216, FieldType.INT); + public static final Field LE_FORMULAS3 = new Field("LE_FORMULAS3", 3416, FieldType.INT); + public static final Field LE_FORMULAS4 = new Field("LE_FORMULAS4", 3616, FieldType.INT); + public static final Field LE_FORMULAS5 = new Field("LE_FORMULAS5", 3816, FieldType.INT); + public static final Field LE_FORMULAS6 = new Field("LE_FORMULAS6", 4016, FieldType.INT); + public static final Field LE_FORMULAS7 = new Field("LE_FORMULAS7", 4216, FieldType.INT); + public static final Field LE_FORMULAS8 = new Field("LE_FORMULAS8", 4416, FieldType.INT); + public static final Field LE_FORMULAS9 = new Field("LE_FORMULAS9", 4616, FieldType.INT); + public static final Field LE_FORMULAS10 = new Field("LE_FORMULAS10", 4816, FieldType.INT); + public static final Field LE_FORMULAS11 = new Field("LE_FORMULAS11", 5016, FieldType.INT); + public static final Field LE_FORMULAS12 = new Field("LE_FORMULAS12", 5216, FieldType.INT); + public static final Field LE_FORMULAS13 = new Field("LE_FORMULAS13", 5416, FieldType.INT); + public static final Field LE_FORMULAS14 = new Field("LE_FORMULAS14", 5616, FieldType.INT); + public static final Field LE_FORMULAS15 = new Field("LE_FORMULAS15", 5816, FieldType.INT); + public static final Field LE_FORMULAS16 = new Field("LE_FORMULAS16", 6016, FieldType.INT); + public static final Field TIMINGMULTIPLIER = new Field("TIMINGMULTIPLIER", 6216, FieldType.INT); + public static final Field TIMINGADDITIVE = new Field("TIMINGADDITIVE", 6416, FieldType.INT); + public static final Field IGNITIONIATCORRTABLE = new Field("IGNITIONIATCORRTABLE", 9176, FieldType.INT); + public static final Field INJECTIONPHASE = new Field("INJECTIONPHASE", 10328, FieldType.INT); + public static final Field FUELTABLE = new Field("FUELTABLE", 11480, FieldType.INT); + public static final Field IGNITIONTABLE = new Field("IGNITIONTABLE", 12632, FieldType.INT); + public static final Field VETABLE = new Field("VETABLE", 13784, FieldType.INT); + public static final Field AFRTABLE = new Field("AFRTABLE", 14936, FieldType.INT); } diff --git a/java_console/models/src/com/rusefi/core/Sensor.java b/java_console/models/src/com/rusefi/core/Sensor.java index dfeb2afa9e..de39c97314 100644 --- a/java_console/models/src/com/rusefi/core/Sensor.java +++ b/java_console/models/src/com/rusefi/core/Sensor.java @@ -96,6 +96,8 @@ public enum Sensor { temperatureFuelCorrection(SensorCategory.OPERATIONS, FieldType.FLOAT, 164, BackgroundColor.MUD, 0, 5), wallFuelCorrection(SensorCategory.OPERATIONS, FieldType.FLOAT, 168, BackgroundColor.MUD), idlePosition(SensorCategory.OPERATIONS, FieldType.FLOAT, 172, BackgroundColor.MUD), + TARGET_AFR(SensorCategory.OPERATIONS, FieldType.FLOAT, 176, BackgroundColor.MUD), + CHARGE_AIR_MASS(SensorCategory.OPERATIONS, FieldType.FLOAT, 180, BackgroundColor.MUD), INJ_1_2_DELTA("inj 1-2 delta", SensorCategory.SNIFFING), INJ_3_4_DELTA("inj 3-4 delta", SensorCategory.SNIFFING), diff --git a/java_console/romraider/romraider.iml b/java_console/romraider/romraider.iml index d9a4ec812b..6f372bddde 100644 --- a/java_console/romraider/romraider.iml +++ b/java_console/romraider/romraider.iml @@ -10,7 +10,7 @@ - + diff --git a/java_console/rusefi.xml b/java_console/rusefi.xml index cf9077e0a8..1746c17ddd 100644 --- a/java_console/rusefi.xml +++ b/java_console/rusefi.xml @@ -7,21 +7,21 @@ RUSEFI rusEfi rusEfi - 15288 + 16088 -
-
@@ -29,16 +29,16 @@ -
-
@@ -46,16 +46,16 @@ -
-
@@ -63,16 +63,16 @@ -
-
@@ -80,15 +80,15 @@ -
+
- +
@@ -108,20 +108,20 @@ -
+
- -
+
diff --git a/java_console/ui/src/com/rusefi/Launcher.java b/java_console/ui/src/com/rusefi/Launcher.java index ea98a92aed..2213e545d3 100644 --- a/java_console/ui/src/com/rusefi/Launcher.java +++ b/java_console/ui/src/com/rusefi/Launcher.java @@ -29,11 +29,10 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig; * (c) Andrey Belomutskiy 2013-2015 * * @see StartupFrame - * @see com.rusefi.ui.engine.EngineSnifferPanel - * @see com.rusefi.StartupFrame + * @see EngineSnifferPanel */ public class Launcher { - public static final int CONSOLE_VERSION = 20151124; + public static final int CONSOLE_VERSION = 20151202; public static final boolean SHOW_STIMULATOR = false; private static final String TAB_INDEX = "main_tab"; protected static final String PORT_KEY = "port"; @@ -81,9 +80,9 @@ public class Launcher { tabbedPane.add("Log Viewer", new LogViewer(engineSnifferPanel)); ConnectionWatchdog.start(); - BinaryProtocolServer.start(); tabbedPane.addTab("Gauges", new GaugesPanel(getConfig().getRoot().getChild("gauges")).getContent()); + tabbedPane.addTab("Formulas", new FormulasPane().getContent()); tabbedPane.addTab("Engine Sniffer", engineSnifferPanel.getPanel()); tabbedPane.addTab("Sensor Sniffer", new SensorSnifferPane(getConfig().getRoot().getChild("sensor_sniffer")).getPanel()); @@ -134,6 +133,7 @@ public class Launcher { tableEditor.showContent(); settingsTab.showContent(); logsManager.showContent(); + BinaryProtocolServer.start(); } }); diff --git a/java_console/ui/src/com/rusefi/StartupFrame.java b/java_console/ui/src/com/rusefi/StartupFrame.java index 359a4dfd3b..4fed833c4b 100644 --- a/java_console/ui/src/com/rusefi/StartupFrame.java +++ b/java_console/ui/src/com/rusefi/StartupFrame.java @@ -40,6 +40,8 @@ public class StartupFrame { private static final String LOGO = "logo.gif"; private static final String LINK_TEXT = "rusEfi (c) 2012-2015"; private static final String URI = "http://rusefi.com/?java_console"; + private static final String VCP_DRIVER_TEXT = "vcp driver"; + private static final String VCP_DRIVER_URI = "http://www.st.com/st-web-ui/static/active/en/st_prod_software_internet/resource/technical/software/driver/stsw-stm32102.zip"; private final JFrame frame; private final Timer scanPortsTimes = new Timer(1000, new ActionListener() { @@ -104,6 +106,7 @@ public class StartupFrame { }); leftPanel.add(connectPanel); + leftPanel.add(new URLLabel(VCP_DRIVER_TEXT, VCP_DRIVER_URI)); leftPanel.add(horizontalLine); findAndApplyPorts(); diff --git a/java_console/ui/src/com/rusefi/maintenance/FirmwareFlasher.java b/java_console/ui/src/com/rusefi/maintenance/FirmwareFlasher.java index 8c90de79c0..236cff5c7a 100644 --- a/java_console/ui/src/com/rusefi/maintenance/FirmwareFlasher.java +++ b/java_console/ui/src/com/rusefi/maintenance/FirmwareFlasher.java @@ -26,7 +26,7 @@ public class FirmwareFlasher extends ProcessStatusWindow { button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { - int dialogResult = JOptionPane.showConfirmDialog(button, "Do you really want to update firmware? Please disconnect battery before erasing.", + int dialogResult = JOptionPane.showConfirmDialog(button, "Do you really want to update firmware? Please disconnect vehicle battery before erasing.", "Please disconnect from vehicle", JOptionPane.YES_NO_OPTION); if (dialogResult != JOptionPane.YES_OPTION) return; @@ -54,7 +54,7 @@ public class FirmwareFlasher extends ProcessStatusWindow { fileName + " verify reset exit 0x08000000\""); if (error.toString().contains(NO_DRIVER_MESSAGE_TAG)) { - wnd.appendMsg(" !!! ERROR: looks like stm32 driver is not installe? !!!"); + wnd.appendMsg(" !!! ERROR: looks like stm32 driver is not installed? The link is above !!!"); } else if (error.toString().contains(SUCCESS_MESSAGE_TAG) && !error.toString().contains(FAILED_MESSAGE_TAG)) { wnd.appendMsg("!!! Looks good!!!"); } else { diff --git a/java_console/ui/src/com/rusefi/ui/FormulasPane.java b/java_console/ui/src/com/rusefi/ui/FormulasPane.java new file mode 100644 index 0000000000..7913d53411 --- /dev/null +++ b/java_console/ui/src/com/rusefi/ui/FormulasPane.java @@ -0,0 +1,110 @@ +package com.rusefi.ui; + +import com.rusefi.ConfigurationImage; +import com.rusefi.binaryprotocol.BinaryProtocol; +import com.rusefi.config.Fields; +import com.rusefi.core.Sensor; +import com.rusefi.core.SensorCentral; +import com.rusefi.ui.config.ConfigField; +import org.scilab.forge.jlatexmath.TeXConstants; +import org.scilab.forge.jlatexmath.TeXFormula; +import org.scilab.forge.jlatexmath.TeXIcon; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.image.BufferedImage; + +public class FormulasPane { + private final JPanel content = new JPanel(new BorderLayout()); + private final JPanel centerProxy = new JPanel(new BorderLayout()); + + public FormulasPane() { + content.add(centerProxy, BorderLayout.CENTER); + + updateFormula(); + new Timer(200, new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + updateFormula(); + } + }).start(); + } + + private void updateFormula() { + + BinaryProtocol bp = BinaryProtocol.instance; + if (bp == null) + return; + ConfigurationImage ci = bp.getController(); + if (ci == null) + return; + + + + String IAT = oneDecimal(Sensor.IAT); + String MAP = oneDecimal(Sensor.MAP); + String T_CHARGE = oneDecimal(Sensor.T_CHARGE); + + double rpm = SensorCentral.getInstance().getValue(Sensor.RPM); + String RPM = "" + (int) rpm; + String VE = oneDecimal(Sensor.CURRENT_VE); + String TARGET_AFR = oneDecimal(Sensor.TARGET_AFR); + String tpsStr = oneDecimal(Sensor.TPS); + String chargeAirMass = String.format("%.3fgm", SensorCentral.getInstance().getValue(Sensor.CHARGE_AIR_MASS)); + + float displacement = (Float) ConfigField.getValue(ci, Fields.DISPLACEMENT); + int cylinderCount = (int) ConfigField.getValue(ci, Fields.CYLINDERSCOUNT); + String cylinderDisplacement = oneDecimal(displacement / cylinderCount); + String injectorFlow = oneDecimal((float)ConfigField.getValue(ci, Fields.INJECTOR_FLOW)); + + String tCharge = "$Tcharge=f(CLT=" + oneDecimal(Sensor.CLT) + "C,IAT=" + IAT + + "C,TPS=" + tpsStr + "\\%, RPM = " + RPM + ")=" + T_CHARGE + "C$"; + + String rpm_map = "RPM=" + RPM + ",MAP=" + MAP + "kPa"; + String mCharge = "$Airmass (g/cyl) =\\frac{(V_Cylinder = " + cylinderDisplacement + "L) " + + "* (VE(" + rpm_map + ") = " + VE + "\\%) " + + "* (MAP = " + MAP + "Kpa)" + + "}{" + + "(GAS_R = 0.28705) * ((Tcharge = " + T_CHARGE + "C) + 273.15)} = " + + chargeAirMass + + "$"; + + String injTime = "$Injection_Time (ms) = \\frac{" + + "($Airmass = " + chargeAirMass + ")" + + "}{" + + "(TargetAFR (" + rpm_map + ") = " + TARGET_AFR + ")" + + " * (injectorFlow = " + injectorFlow + " cc/min)" + + "} = " + "yyy" + "ms$"; + + String newLine = "\r\n \\\\ "; + String page = tCharge + newLine + newLine + newLine + + mCharge + newLine + newLine + newLine + + injTime + newLine; + + TeXFormula formula = new TeXFormula(page); + TeXIcon icon = formula.createTeXIcon(TeXConstants.STYLE_DISPLAY, 20); + + BufferedImage image = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB); + Graphics2D g2 = image.createGraphics(); + g2.setColor(Color.white); + g2.fillRect(0, 0, icon.getIconWidth(), icon.getIconHeight()); + JLabel label = new JLabel(icon); + + centerProxy.removeAll(); + centerProxy.add(label, BorderLayout.CENTER); + } + + private String oneDecimal(Sensor sensor) { + return oneDecimal(SensorCentral.getInstance().getValue(sensor)); + } + + private String oneDecimal(double ve) { + return String.format("%.1f", ve); + } + + public JPanel getContent() { + return content; + } +} \ No newline at end of file diff --git a/java_console/ui/src/com/rusefi/ui/StatusWindow.java b/java_console/ui/src/com/rusefi/ui/StatusWindow.java index 5b61d664df..d801e6b808 100644 --- a/java_console/ui/src/com/rusefi/ui/StatusWindow.java +++ b/java_console/ui/src/com/rusefi/ui/StatusWindow.java @@ -1,17 +1,21 @@ package com.rusefi.ui; import com.rusefi.ui.util.FrameHelper; +import com.rusefi.ui.util.URLLabel; import com.rusefi.ui.util.UiUtils; import javax.swing.*; import java.awt.*; /** - * Create(c) Andrey Belomutskiy 2013-2015 + * (c) Andrey Belomutskiy 2013-2015 * 3/7/2015 */ public class StatusWindow { + // todo: extract driver from console bundle? find a separate driver bundle? + private static final String CONSOLE_DRIVER_URI = "http://www.st.com/st-web-ui/static/active/en/st_prod_software_internet/resource/technical/software/utility/stsw-link004.zip"; private final JTextArea log = new JTextArea(); + private final JPanel content = new JPanel(new BorderLayout()); private final JScrollPane messagesScroll = new JScrollPane(log, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED) { @Override public Dimension getPreferredSize() { @@ -24,9 +28,12 @@ public class StatusWindow { } public void showFrame(String title) { + content.add(new URLLabel("stm32 driver", CONSOLE_DRIVER_URI), BorderLayout.NORTH); + content.add(messagesScroll, BorderLayout.CENTER); + FrameHelper f = new FrameHelper(); f.getFrame().setTitle(title); - f.showFrame(messagesScroll, false); + f.showFrame(content, false); UiUtils.centerWindow(f.getFrame()); log.setText(""); // let's remove stuff from previous invocation } diff --git a/java_console/ui/src/com/rusefi/ui/config/BaseConfigField.java b/java_console/ui/src/com/rusefi/ui/config/BaseConfigField.java index 9ea4e33f88..990d50ffab 100644 --- a/java_console/ui/src/com/rusefi/ui/config/BaseConfigField.java +++ b/java_console/ui/src/com/rusefi/ui/config/BaseConfigField.java @@ -93,6 +93,11 @@ abstract class BaseConfigField { @NotNull protected ByteBuffer getByteBuffer(ConfigurationImage ci) { + return getByteBuffer(ci, field); + } + + @NotNull + public static ByteBuffer getByteBuffer(ConfigurationImage ci, Field field) { byte data[] = ci.getRange(field.getOffset(), 4); ByteBuffer wrapped = ByteBuffer.wrap(data); wrapped.order(ByteOrder.LITTLE_ENDIAN); diff --git a/java_console/ui/src/com/rusefi/ui/config/ConfigField.java b/java_console/ui/src/com/rusefi/ui/config/ConfigField.java index 6d494be372..77dc81e81a 100644 --- a/java_console/ui/src/com/rusefi/ui/config/ConfigField.java +++ b/java_console/ui/src/com/rusefi/ui/config/ConfigField.java @@ -9,11 +9,9 @@ import com.rusefi.ui.util.JTextFieldWithWidth; import org.jetbrains.annotations.NotNull; import javax.swing.*; -import java.awt.*; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.nio.ByteBuffer; -import java.nio.ByteOrder; public class ConfigField extends BaseConfigField { private final JTextField view = new JTextFieldWithWidth(200); @@ -54,14 +52,20 @@ public class ConfigField extends BaseConfigField { @Override protected void loadValue(ConfigurationImage ci) { + Number value = getValue(ci, field); + setValue(value); + } + + @NotNull + public static Number getValue(ConfigurationImage ci, Field field) { Number value; - ByteBuffer wrapped = getByteBuffer(ci); + ByteBuffer wrapped = getByteBuffer(ci, field); if (field.getType() == FieldType.INT) { value = wrapped.getInt(); } else { value = wrapped.getFloat(); } - setValue(value); + return value; } } \ No newline at end of file diff --git a/java_console/ui/ui.iml b/java_console/ui/ui.iml index 19e309ada9..7967ad3d1b 100644 --- a/java_console/ui/ui.iml +++ b/java_console/ui/ui.iml @@ -10,7 +10,7 @@ - + @@ -19,5 +19,6 @@ +
\ No newline at end of file diff --git a/unit_tests/test_speed_density.cpp b/unit_tests/test_speed_density.cpp index 065806f6f2..bccc22ffd0 100644 --- a/unit_tests/test_speed_density.cpp +++ b/unit_tests/test_speed_density.cpp @@ -27,6 +27,10 @@ void testSpeedDensity(void) { eth.ec->injector.flow = gramm_second_to_cc_minute(5.303); + float airMass = getAirMass(eth.ec, 0.92, 98, 293.16); + + assertEquals(0.9371, airMass); + // 0.01414 sec or 14.14 ms - assertEquals(0.01414, sdMath(eth.ec, 0.92, 98, 12.5, 293.16)); + assertEquals(0.01414, sdMath(eth.ec, airMass, 12.5)); }