noisymime / speeduino

Speeduino - Arduino based engine management
http://speeduino.com
GNU General Public License v2.0
1.31k stars 526 forks source link

Conditional Rule references Incorrect #654

Closed morrisman1 closed 2 years ago

morrisman1 commented 2 years ago

We have been trying to solve why my rules wouldn't work and came across the following issues:

1) When you create an AUX input under the accessories menu, the numbering starts from 0, and counts up from there. In the available rule condition inputs, the list starts at Aux 1, however this actually references the Aux 0 input. The whole aux list is out by one position

2) When you select from the list of conditions for the programmable outputs in Tunerstudio, at the point of VVT1 angle, the list goes out of sync by one position. For example to have a logic switching on WMI Tank Empty, you have to select the item above it on the list. A friend has explained it in the way that VVT1Angle is a 2-byte item, and the next item has the offset correct in main controller.ini, however in the list when you select the condition, it looks up 94 instead of 95, and puts the list out of sync.

I apologize that I'm not able detail much in relation to the code itself, I do not know the language. I hope the photos he sent me are useful.

240610498_1481890538836132_4361008875883237286_n

241198131_403478851199466_3224632871948526991_n

240471766_443605910207242_1931080963394591097_n

241184988_2390449764431989_6938772584618323267_n

240500191_585999479102577_5695005035911813826_n

Afroboltski commented 2 years ago

After some further digging (I was the one who generated the initial screenshots above), I have discovered the problem lies mostly in the .ini file. I've attached a "fixed" version, but the only changes are the defs near the top:

#define fullStatus_def_1= "seconds", "status bits", "Engine status", "syncLossCounter", "MAP (Kpa)", "INVALID", "IAT / MAT", "coolant", "batCorrection", "battery voltage x10", "O2", "egoCorrection", "iatCorrection", "wueCorrection", "RPM", "INVALID", "AEamount/2", "GammaE", "INVALID", "VE1", "VE2", "AFR Target", "TPS DOT", "Advance", "TPS", "loopsPerSecond", "INVALID", "free RAM", "INVALID", "boostTarget/2", "Boost duty", "spark bits"

#define fullStatus_def_2= "RPM DOT", "INVALID", "ethanolPct", "flexCorrection", "flexIgnCorrection", "idle Load", "testOutputs", "O2_2", "baro", "Aux in 0", "INVALID", "Aux in 1", "INVALID", "Aux in 2", "INVALID", "Aux in 3", "INVALID", "Aux in 4", "INVALID", "Aux in 5", "INVALID", "Aux in 6", "INVALID", "Aux in 7", "INVALID", "Aux in 8", "INVALID", "Aux in 9", "INVALID", "Aux in 10", "INVALID", "Aux in 11"

#define fullStatus_def_3= "INVALID", "Aux in 12", "INVALID", "Aux in 13", "INVALID", "Aux in 14", "INVALID", "Aux in 15", "INVALID", "TPS ADC", "Error code", "Pulsewidth 1", "INVALID", "Pulsewidth 2", "INVALID", "Pulsewidth 3", "INVALID", "Pulsewidth 4", "INVALID", "status bits 3", "engineProtectStatus", "Fuel load", "INVALID", "Ignition load", "INVALID", "dwell", "INVALID", "idle C.L. target", "MAP DOT", "VVT1 Angle", "INVALID", "VVT1 Target"

#define fullStatus_def_4= "VVT1 duty", "flexBoostCorrection", "INVALID", "baro correction", "Current VE", "ASE Value", "vss", "INVALID", "Gear", "Fuel Pressure", "Oil Pressure", "WMI duty", "WMI empty", "VVT2 angle", "INVALID", "VVT2 target", "VVT2 duty", "outputs status", "Fuel temp", "Fuel temp correction", "Advance 1", "Advance 2", "SD status", "running seconds x10", "INVALID", "Rule 1", "Rule 2", "Rule 3", "Rule 4", "Rule 5", "Rule 6", "Rule 7"

#define fullStatus_def_5= "Rule 8", "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"

#define fullStatus_def_6= "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"

#define fullStatus_def_7= "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"

(Generated with a script to prevent typos, but let me know if I've missed any special cases)

The key thing here being that "VVT1 Angle", "INVALID" did not have the "INVALID" placeholder that allows the byteNum parameter to match up with what the firmware expects (in the getStatusEntry(uint16_t byteNum) method). I believe there were a few more missing after this entry too.

Additionally I've renamed the Aux. inputs so they go from 0 - 15 (as they are in TS), instead of 1 - 16 (fixes the off-by-one error with the Aux. outputs).

Further, the fsIntIndex static EEPROM array in globals.ino (line 124) has a typo and is missing an entry. It should be:

const byte PROGMEM fsIntIndex[] = { 4, 14, 17, 25, 27, 32, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 75, 77, 79, 81, 85, 87, 89, 93, 97, 102, 109, 119 };

i.e., 190 changed to 109, and 119 added. Can someone with write access please fix? :)

Cheers Lance

speeduino-fixed-08.09.2021.ini.txt