-
Notifications
You must be signed in to change notification settings - Fork 178
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
Merged
+375
−82
Merged
Tesla bugfixes #818
Changes from 3 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
66c141c
Debug_log bugfix
josiahhiggs 102db63
format
josiahhiggs 19cd5c5
Update advanced_battery_html.cpp
josiahhiggs f77d32a
Change static const char* to inline
josiahhiggs eeb2abd
Formating
josiahhiggs 0636971
Update TESLA-BATTERY.cpp
josiahhiggs e994b51
Update advanced_battery_html.cpp
josiahhiggs 08181cc
format
josiahhiggs 14f944f
Update TESLA-BATTERY.h
josiahhiggs dbb5cc6
update
josiahhiggs d57d853
formatting
josiahhiggs 87ac87c
Merge branch 'dalathegreat:main' into tesla-bugfixes
josiahhiggs 3acb810
Update advanced_battery_html.cpp
josiahhiggs 292d7df
Merge branch 'dalathegreat:main' into tesla-bugfixes
josiahhiggs 23a728b
Update advanced_battery_html.cpp
josiahhiggs 30de0d8
Merge branch 'main' into tesla-bugfixes
mvgalen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -827,6 +827,7 @@ static const char* hvilStatusState[] = {"NOT OK", | |
"UNKNOWN(13)", | ||
"UNKNOWN(14)", | ||
"UNKNOWN(15)"}; | ||
static const char* noYes[] = {"No", "Yes"}; | ||
|
||
void clearIsolationFault() { | ||
//CAN UDS messages to clear a latched isolation fault | ||
|
@@ -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]); | ||
logging.print(", Pyrotest: "); | ||
logging.println(battery_pyroTestInProgress); | ||
logging.println(noYes[battery_pyroTestInProgress]); | ||
|
||
logging.print("Battery values: "); | ||
logging.print("Real SOC: "); | ||
|
@@ -1174,11 +1175,16 @@ void update_values_battery() { //This function maps all the values fetched via | |
logging.print(battery_cell_deviation_mV); | ||
logging.println("mV."); | ||
|
||
print_int_with_units("High Voltage Output Pins: ", battery_dcdcHvBusVolt, "V"); | ||
logging.printf("High Voltage Output Pins: %.2f V", (battery_dcdcHvBusVolt * 0.146484)); | ||
logging.print(", "); | ||
print_int_with_units("Low Voltage: ", battery_dcdcLvBusVolt, "V"); | ||
logging.println(""); | ||
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 commentThe 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.println("."); | ||
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Same for this one, just add \n to the printf string. |
||
|
||
logging.println("Values passed to the inverter: "); | ||
|
@@ -1230,6 +1236,7 @@ void handle_incoming_can_frame_battery(CAN_frame rx_frame) { | |
if (mux0_read && mux1_read) { | ||
mux0_read = false; | ||
mux1_read = false; | ||
BMS352_mux = true; //Set flag to true | ||
} | ||
// older BMS <2021 without mux | ||
battery_nominal_full_pack_energy = //BMS_nominalFullPackEnergy : 0|11@1+ (0.1,0) [0|204.6] "KWh" //((_d[1] & (0x07U)) << 8) | (_d[0] & (0xFFU)); | ||
|
@@ -1449,17 +1456,15 @@ void handle_incoming_can_frame_battery(CAN_frame rx_frame) { | |
BMS_pcsNoFlowRequest = ((rx_frame.data.u8[7] >> 6) & (0x01U)); // 62|1@1+ (1,0) [0|0] "" | ||
BMS_noFlowRequest = ((rx_frame.data.u8[7] >> 7) & (0x01U)); //63|1@1+ (1,0) [0|0] "" | ||
break; | ||
case 0x2A4: //676 PCS_thermalStatus | ||
PCS_chgPhATemp = | ||
(((rx_frame.data.u8[1] & 0x07) << 8) | (rx_frame.data.u8[0] & 0xFF)); //0|11@1- (0.1,40) [0|0] "C" | ||
case 0x2A4: //676 PCS_thermalStatus | ||
PCS_chgPhATemp = (rx_frame.data.u8[0] & 0xFF) | ((rx_frame.data.u8[1] & 0x07) << 8); //0|11@1- (0.1,40) [0|0] "C" | ||
PCS_chgPhBTemp = | ||
(((rx_frame.data.u8[2] & 0x3F) << 5) | ((rx_frame.data.u8[1] >> 3) & 0x1F)); //11|11@1- (0.1,40) [0|0] "C" | ||
PCS_chgPhCTemp = (((rx_frame.data.u8[2] & 0xC0) >> 6) | ((rx_frame.data.u8[3] & 0xFF) << 2) | | ||
((rx_frame.data.u8[4] & 0x03) << 10)); //22|11@1- (0.1,40) [0|0] "C" | ||
((rx_frame.data.u8[1] & 0xF8) >> 3) | ((rx_frame.data.u8[2] & 0x3F) << 5); //11|11@1- (0.1,40) [0|0] "C" | ||
PCS_chgPhCTemp = ((rx_frame.data.u8[2] & 0xC0) >> 6) | (rx_frame.data.u8[3] << 2) | | ||
((rx_frame.data.u8[4] & 0x01) << 10); //22|11@1- (0.1,40) [0|0] "C" | ||
PCS_dcdcTemp = | ||
(((rx_frame.data.u8[4] >> 1) & 0x1F) | ((rx_frame.data.u8[5] & 0x3F) << 5)); //33|11@1- (0.1,40) [0|0] "C" | ||
PCS_ambientTemp = | ||
(((rx_frame.data.u8[7] & 0x07) << 8) | (rx_frame.data.u8[6] & 0xFF)); //44|11@1- (0.1,40) [0|0] "C" | ||
((rx_frame.data.u8[4] & 0xFE) >> 1) | ((rx_frame.data.u8[5] & 0x0F) << 7); //33|11@1- (0.1,40) [0|0] "C" | ||
PCS_ambientTemp = ((rx_frame.data.u8[5] & 0xF0) >> 4) | (rx_frame.data.u8[6] << 4); //44|11@1- (0.1,40) [0|0] "C" | ||
break; | ||
case 0x2C4: // 708 PCS_logging: not all frames are listed, just ones relating to dcdc | ||
mux = (rx_frame.data.u8[0] & (0x1FU)); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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?
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.