-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tesla bugfixes #818
base: main
Are you sure you want to change the base?
Tesla bugfixes #818
Conversation
Debug updated to display accurate data including PCS temps in more battery info.
@@ -1144,9 +1145,9 @@ void update_values_battery() { //This function maps all the values fetched via | |||
logging.print(", setState: "); | |||
logging.print(contactorState[battery_packContactorSetState]); | |||
logging.print(", close allowed: "); | |||
logging.print(battery_packCtrsClosingAllowed); | |||
logging.print(noYes[battery_packCtrsClosingAllowed]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This use of indexing into an arrray has a great risk of array out-of-bounds accesses which can lead to crashes. Either and the input with 0x01, to reduce it to 0 or 1. Or, and perhaps better, define an inline function returning the string, but then as result of an if/else or switch statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this be acceptable option for an inline function?
inline const char* getContactorText(int index) {
switch (index) {
case 0: return "Open";
case 1: return "Closed";
default: return "Unknown";
}
}
inline const char* getHvilStatusState(int index) {
switch (index) {
case 0: return "Disconnected";
case 1: return "Connected";
default: return "Unknown";
}
}
inline const char* getContactorState(int index) {
switch (index) {
case 0: return "Inactive";
case 1: return "Active";
default: return "Unknown";
}
}
inline const char* getNoYes(int index) {
switch (index) {
case 0: return "No";
case 1: return "Yes";
default: return "Unknown";
}
}
void logStatus() {
logging.print("STATUS: Contactor: ");
logging.print(getContactorText(battery_contactor)); // Display what state the contactor is in
logging.print(", HVIL: ");
logging.print(getHvilStatusState(battery_hvil_status));
logging.print(", NegativeState: ");
logging.print(getContactorState(battery_packContNegativeState));
logging.print(", PositiveState: ");
logging.print(getContactorState(battery_packContPositiveState));
logging.print(", setState: ");
logging.print(getContactorState(battery_packContactorSetState));
logging.print(", close allowed: ");
logging.print(getNoYes(battery_packCtrsClosingAllowed));
logging.print(", Pyrotest: ");
logging.println(getNoYes(battery_pyroTestInProgress));
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, much better imho.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this change is going to apply to the webserver as well. More of an improvement PR, I think I will work on this separately to make sure I test it on my bench. Sound good?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, but indeed better as a separate PR.
print_int_with_units("DC/DC 12V current: ", battery_dcdcLvOutputCurrent, "A"); | ||
logging.printf("Low Voltage: %.2f V", (battery_dcdcLvBusVolt * 0.0390625)); | ||
logging.print(", "); | ||
logging.printf("DC/DC 12V current: %.2f A", (battery_dcdcLvOutputCurrent * 0.1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps better to combine the println(".") below with the printf on this line %.2f A.\n");
|
||
logging.printf("PCS_ambientTemp: %.2f°C, DCDC_Temp: %.2f°C, ChgPhA: %.2f°C, ChgPhB: %.2f°C, ChgPhC: %.2f°C", | ||
PCS_ambientTemp * 0.1 + 40, PCS_dcdcTemp * 0.1 + 40, PCS_chgPhATemp * 0.1 + 40, | ||
PCS_chgPhBTemp * 0.1 + 40, PCS_chgPhCTemp * 0.1 + 40); | ||
logging.println(""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for this one, just add \n to the printf string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will approve if you change to the inline functions and fix the end of line comments I added.
Updte loggingprint for DEBUG, Update advanced battery by removing static and add inline. Update notes for Rty Cnt frames.
Remove duplicate inline
Update additional Strings to inline function names.
added inline const char* to TESLA-BATTERY.h and include in advanced battery to utilize inline const char*
Revert back to static const char* due to compile issues
@mvgalen I have made the requested changes and would appreciate your review comments. |
//0x252 594 BMS_powerAvailable | ||
content += "<h4>Max Regen Power: " + String(BMS_maxRegenPower) + " KW</h4>"; | ||
content += "<h4>Max Discharge Power: " + String(BMS_maxDischargePower) + " KW</h4>"; | ||
//content += "<h4>Max Stationary Heat Power: " + String(BMS_maxStationaryHeatPower) + " KWh</h4>"; // Not giving useable data | ||
//content += "<h4>HVAC Power Budget: " + String(BMS_hvacPowerBudget) + " KW</h4>"; // Not giving useable data | ||
//content += "<h4>Not Enough Power For Heat Pump: " + String(falseTrue[datalayer_extended.tesla.BMS_notEnoughPowerForHeatPump]) + "</h4>"; // Not giving useable data | ||
//content += "<h4>Not Enough Power For Heat Pump: " + String(getNoYes[datalayer_extended.tesla.BMS_notEnoughPowerForHeatPump]) + "</h4>"; // Not giving useable data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a bug, the [ ... ] should be ( ... ) since getNoYes is a function and we are now indexing the pointer to the function.
What
Bugs noted in Tesla to fix:
More Battery Info 0x352 displaying non mux data when it should display mux.
PCS temperatures not accurate in More Battery Info.
DEBUG data not displaying 0x2B4 HV, LV data accurately.
Why
@josiahhiggs was here
How
Added BMS352_mux = true
Revised bitwise for PCS
Revised 0x2B4 data display in DEBUG
151.000 ERROR: BMS_a035_SW_Isolation
151.000 ERROR: BMS_a036_SW_HvpHvilFault
151.000 STATUS: Contactor: CLOSED, HVIL: STATUS_OK, NegativeState: ECONOMIZED, PositiveState: ECONOMIZED, setState:
OPENING, close allowed: Yes, Pyrotest: No
151.000 Battery values: Real SOC: 90.3, Battery voltage: 353V, Battery HV current: 0A, Fully charged?: YES, LFP chemistry detected!
151.000 Cellstats, Max: 3328mV (cell 13), Min: 3324mV (cell 16), Imbalance: 4mV.
151.000 High Voltage Output Pins: 352.59 V, Low Voltage: 14.18 V, DC/DC 12V current: 4.50 A.
151.000 PCS_ambientTemp: 47.70°C, DCDC_Temp: 59.30°C, ChgPhA: 46.70°C, ChgPhB: 46.70°C, ChgPhC: 46.40°C
151.000 Values passed to the inverter:
151.000 SOC: 90.30%
151.001 Max discharge power: 60000W, Max charge power: 14550W
151.001 Max temperature: 25°C, Min temperature: 29°C