diff --git a/Software/src/battery/JAGUAR-IPACE-BATTERY.cpp b/Software/src/battery/JAGUAR-IPACE-BATTERY.cpp index 4f499411..618b32c8 100644 --- a/Software/src/battery/JAGUAR-IPACE-BATTERY.cpp +++ b/Software/src/battery/JAGUAR-IPACE-BATTERY.cpp @@ -106,8 +106,8 @@ void update_values_battery() { /*Finally print out values to serial if configured to do so*/ #ifdef DEBUG_LOG logging.println("Values going to inverter"); - print_units("SOH: ", (datalayer.battery.status.soh_pptt * 0.01), "pct "); - print_units(", SOC: ", (datalayer.battery.status.reported_soc * 0.01), "pct "); + print_units("SOH%: ", (datalayer.battery.status.soh_pptt * 0.01), "% "); + print_units(", SOC%: ", (datalayer.battery.status.reported_soc * 0.01), "% "); print_units(", Voltage: ", (datalayer.battery.status.voltage_dV * 0.1), "V "); print_units(", Max discharge power: ", datalayer.battery.status.max_discharge_power_W, "W "); print_units(", Max charge power: ", datalayer.battery.status.max_charge_power_W, "W "); diff --git a/Software/src/battery/KIA-E-GMP-BATTERY.cpp b/Software/src/battery/KIA-E-GMP-BATTERY.cpp index 8d218687..70f9fd45 100644 --- a/Software/src/battery/KIA-E-GMP-BATTERY.cpp +++ b/Software/src/battery/KIA-E-GMP-BATTERY.cpp @@ -695,11 +695,11 @@ void update_values_battery() { //This function maps all the values fetched via logging.println("Values from battery: "); logging.print("SOC BMS: "); logging.print((uint16_t)SOC_BMS / 10.0, 1); - logging.print("pct | SOC Display: "); + logging.print("% | SOC Display: "); logging.print((uint16_t)SOC_Display / 10.0, 1); - logging.print("pct | SOH "); + logging.print("% | SOH "); logging.print((uint16_t)batterySOH / 10.0, 1); - logging.println("pct"); + logging.println("%"); logging.print((int16_t)batteryAmps / 10.0, 1); logging.print(" Amps | "); logging.print((uint16_t)batteryVoltage / 10.0, 1); diff --git a/Software/src/battery/KIA-HYUNDAI-64-BATTERY.cpp b/Software/src/battery/KIA-HYUNDAI-64-BATTERY.cpp index 084d6549..d14e78cd 100644 --- a/Software/src/battery/KIA-HYUNDAI-64-BATTERY.cpp +++ b/Software/src/battery/KIA-HYUNDAI-64-BATTERY.cpp @@ -147,11 +147,11 @@ void update_values_battery() { //This function maps all the values fetched via logging.println("Values from battery: "); logging.print("SOC BMS: "); logging.print((uint16_t)SOC_BMS / 10.0, 1); - logging.print("pct | SOC Display: "); + logging.print("% | SOC Display: "); logging.print((uint16_t)SOC_Display / 10.0, 1); - logging.print("pct | SOH "); + logging.print("% | SOH "); logging.print((uint16_t)batterySOH / 10.0, 1); - logging.println("pct"); + logging.println("%"); logging.print((int16_t)batteryAmps / 10.0, 1); logging.print(" Amps | "); logging.print((uint16_t)batteryVoltage / 10.0, 1); diff --git a/Software/src/battery/RENAULT-KANGOO-BATTERY.cpp b/Software/src/battery/RENAULT-KANGOO-BATTERY.cpp index 80430db1..4fa4a6e4 100644 --- a/Software/src/battery/RENAULT-KANGOO-BATTERY.cpp +++ b/Software/src/battery/RENAULT-KANGOO-BATTERY.cpp @@ -105,9 +105,9 @@ void update_values_battery() { //This function maps all the values fetched via #ifdef DEBUG_LOG logging.println("Values going to inverter:"); - logging.print("SOH: "); + logging.print("SOH%: "); logging.print(datalayer.battery.status.soh_pptt); - logging.print(", SOC scaled: "); + logging.print(", SOC% scaled: "); logging.print(datalayer.battery.status.reported_soc); logging.print(", Voltage: "); logging.print(datalayer.battery.status.voltage_dV); diff --git a/Software/src/battery/TESLA-BATTERY.cpp b/Software/src/battery/TESLA-BATTERY.cpp index 50112449..3f31068d 100644 --- a/Software/src/battery/TESLA-BATTERY.cpp +++ b/Software/src/battery/TESLA-BATTERY.cpp @@ -2713,7 +2713,7 @@ void print_SOC(char* header, int SOC) { if (hundredth < 10) logging.print(0); logging.print(hundredth); - logging.println("pct"); + logging.println("%"); } void printFaultCodesIfActive() { diff --git a/Software/src/battery/TEST-FAKE-BATTERY.cpp b/Software/src/battery/TEST-FAKE-BATTERY.cpp index 234726fc..fb1cf729 100644 --- a/Software/src/battery/TEST-FAKE-BATTERY.cpp +++ b/Software/src/battery/TEST-FAKE-BATTERY.cpp @@ -56,8 +56,8 @@ void update_values_battery() { /* This function puts fake values onto the parame /*Finally print out values to serial if configured to do so*/ #ifdef DEBUG_LOG logging.println("FAKE Values going to inverter"); - print_units("SOH: ", (datalayer.battery.status.soh_pptt * 0.01), "pct "); - print_units(", SOC: ", (datalayer.battery.status.reported_soc * 0.01), "pct "); + print_units("SOH%: ", (datalayer.battery.status.soh_pptt * 0.01), "% "); + print_units(", SOC%: ", (datalayer.battery.status.reported_soc * 0.01), "% "); print_units(", Voltage: ", (datalayer.battery.status.voltage_dV * 0.1), "V "); print_units(", Max discharge power: ", datalayer.battery.status.max_discharge_power_W, "W "); print_units(", Max charge power: ", datalayer.battery.status.max_charge_power_W, "W "); @@ -109,8 +109,8 @@ void update_values_battery2() { // Handle the values coming in from battery #2 /*Finally print out values to serial if configured to do so*/ #ifdef DEBUG_LOG logging.println("FAKE Values battery 2 going to inverter"); - print_units("SOH 2: ", (datalayer.battery2.status.soh_pptt * 0.01), "pct "); - print_units(", SOC 2: ", (datalayer.battery2.status.reported_soc * 0.01), "pct "); + print_units("SOH 2 %: ", (datalayer.battery2.status.soh_pptt * 0.01), "% "); + print_units(", SOC 2 %: ", (datalayer.battery2.status.reported_soc * 0.01), "% "); print_units(", Voltage 2: ", (datalayer.battery2.status.voltage_dV * 0.1), "V "); print_units(", Max discharge power 2: ", datalayer.battery2.status.max_discharge_power_W, "W "); print_units(", Max charge power 2: ", datalayer.battery2.status.max_charge_power_W, "W "); diff --git a/Software/src/battery/VOLVO-SPA-BATTERY.cpp b/Software/src/battery/VOLVO-SPA-BATTERY.cpp index 15c3c7b8..2d27b02f 100644 --- a/Software/src/battery/VOLVO-SPA-BATTERY.cpp +++ b/Software/src/battery/VOLVO-SPA-BATTERY.cpp @@ -95,11 +95,11 @@ void update_values_battery() { //This function maps all the values fetched via } #ifdef DEBUG_LOG - logging.print("BMS reported SOC: "); + logging.print("BMS reported SOC%: "); logging.println(SOC_BMS); - logging.print("Calculated SOC: "); + logging.print("Calculated SOC%: "); logging.println(SOC_CALC); - logging.print("Rescaled SOC: "); + logging.print("Rescaled SOC%: "); logging.println(datalayer.battery.status.reported_soc / 100); logging.print("Battery current: "); logging.println(BATT_I); diff --git a/Software/src/charger/CHEVY-VOLT-CHARGER.cpp b/Software/src/charger/CHEVY-VOLT-CHARGER.cpp index 849e219e..618c7d2a 100644 --- a/Software/src/charger/CHEVY-VOLT-CHARGER.cpp +++ b/Software/src/charger/CHEVY-VOLT-CHARGER.cpp @@ -101,6 +101,9 @@ void map_can_frame_to_variable_charger(CAN_frame rx_frame) { case 0x308: break; default: +#ifdef DEBUG_LOG + logging.printf("CAN Rcv unknown frame MsgID=%x\n", rx_frame.MsgID); +#endif break; } } diff --git a/Software/src/communication/can/comm_can.cpp b/Software/src/communication/can/comm_can.cpp index e85eca7e..3c9e1be4 100644 --- a/Software/src/communication/can/comm_can.cpp +++ b/Software/src/communication/can/comm_can.cpp @@ -90,7 +90,7 @@ void init_CAN() { logging.println(settings2517.exactArbitrationBitRate() ? "yes)" : "no)"); logging.print("Arbitration Sample point: "); logging.print(settings2517.arbitrationSamplePointFromBitStart()); - logging.println("pct"); + logging.println("%"); #endif // DEBUG_LOG } else { #ifdef DEBUG_LOG diff --git a/Software/src/devboard/webserver/can_logging_html.cpp b/Software/src/devboard/webserver/can_logging_html.cpp index e64de232..146566c7 100644 --- a/Software/src/devboard/webserver/can_logging_html.cpp +++ b/Software/src/devboard/webserver/can_logging_html.cpp @@ -1,68 +1,67 @@ #include "can_logging_html.h" #include #include "../../datalayer/datalayer.h" +#include "index_html.h" -String can_logger_processor(const String& var) { - if (var == "X") { - if (!datalayer.system.info.can_logging_active) { - datalayer.system.info.logged_can_messages_offset = 0; - datalayer.system.info.logged_can_messages[0] = '\0'; - } - datalayer.system.info.can_logging_active = - true; // Signal to main loop that we should log messages. Disabled by default for performance reasons - String content = ""; - // Page format - content += ""; - content += " "; - content += " "; -#ifdef LOG_CAN_TO_SD - content += " "; -#endif - content += ""; - - // Start a new block for the CAN messages - content += "
"; - - // Check for messages - if (datalayer.system.info.logged_can_messages[0] == 0) { - content += "CAN logger started! Refresh page to display incoming(RX) and outgoing(TX) messages"; - } else { - // Split the messages using the newline character - String messages = String(datalayer.system.info.logged_can_messages); - int startIndex = 0; - int endIndex = messages.indexOf('\n'); - while (endIndex != -1) { - // Extract a single message and wrap it in a styled div - String singleMessage = messages.substring(startIndex, endIndex); - content += "
" + singleMessage + "
"; - startIndex = endIndex + 1; // Move past the newline character - endIndex = messages.indexOf('\n', startIndex); - } - } - - content += "
"; - - // Add JavaScript for navigation - content += ""; - return content; +String can_logger_processor(void) { + if (!datalayer.system.info.can_logging_active) { + datalayer.system.info.logged_can_messages_offset = 0; + datalayer.system.info.logged_can_messages[0] = '\0'; } - return String(); + datalayer.system.info.can_logging_active = + true; // Signal to main loop that we should log messages. Disabled by default for performance reasons + String content = index_html_header; + // Page format + content += ""; + content += " "; + content += " "; +#ifdef LOG_CAN_TO_SD + content += " "; +#endif + content += ""; + + // Start a new block for the CAN messages + content += "
"; + + // Check for messages + if (datalayer.system.info.logged_can_messages[0] == 0) { + content += "CAN logger started! Refresh page to display incoming(RX) and outgoing(TX) messages"; + } else { + // Split the messages using the newline character + String messages = String(datalayer.system.info.logged_can_messages); + int startIndex = 0; + int endIndex = messages.indexOf('\n'); + while (endIndex != -1) { + // Extract a single message and wrap it in a styled div + String singleMessage = messages.substring(startIndex, endIndex); + content += "
" + singleMessage + "
"; + startIndex = endIndex + 1; // Move past the newline character + endIndex = messages.indexOf('\n', startIndex); + } + } + + content += "
"; + + // Add JavaScript for navigation + content += ""; + content += index_html_footer; + return content; } diff --git a/Software/src/devboard/webserver/can_logging_html.h b/Software/src/devboard/webserver/can_logging_html.h index f208c3ff..8d68e684 100644 --- a/Software/src/devboard/webserver/can_logging_html.h +++ b/Software/src/devboard/webserver/can_logging_html.h @@ -11,6 +11,6 @@ * * @return String */ -String can_logger_processor(const String& var); +String can_logger_processor(void); #endif diff --git a/Software/src/devboard/webserver/debug_logging_html.cpp b/Software/src/devboard/webserver/debug_logging_html.cpp index 7dd9ede4..ce274068 100644 --- a/Software/src/devboard/webserver/debug_logging_html.cpp +++ b/Software/src/devboard/webserver/debug_logging_html.cpp @@ -1,10 +1,11 @@ #include "debug_logging_html.h" #include #include "../../datalayer/datalayer.h" +#include "index_html.h" #ifdef DEBUG_VIA_WEB -String debug_logger_processor(const String& var) { - String content = ""; +String debug_logger_processor(void) { + String content = String(index_html_header); // Page format content += "%X% -)rawliteral"; +#include "index_html.h" + +#define INDEX_HTML_HEADER \ + R"rawliteral(Battery Emulator)rawliteral" +#define INDEX_HTML_FOOTER R"rawliteral()rawliteral"; + +const char index_html[] = INDEX_HTML_HEADER "%X%" INDEX_HTML_FOOTER; +const char index_html_header[] = INDEX_HTML_HEADER; +const char index_html_footer[] = INDEX_HTML_FOOTER; /* The above code is minified (https://kangax.github.io/html-minifier/) to increase performance. Here is the full HTML function: diff --git a/Software/src/devboard/webserver/index_html.h b/Software/src/devboard/webserver/index_html.h new file mode 100644 index 00000000..8a095650 --- /dev/null +++ b/Software/src/devboard/webserver/index_html.h @@ -0,0 +1,8 @@ +#ifndef INDEX_HTML_H +#define INDEX_HTML_H + +extern const char index_html[]; +extern const char index_html_header[]; +extern const char index_html_footer[]; + +#endif // INDEX_HTML_H diff --git a/Software/src/devboard/webserver/webserver.cpp b/Software/src/devboard/webserver/webserver.cpp index 61c28f30..696873c7 100644 --- a/Software/src/devboard/webserver/webserver.cpp +++ b/Software/src/devboard/webserver/webserver.cpp @@ -21,7 +21,7 @@ unsigned long ota_progress_millis = 0; #include "cellmonitor_html.h" #include "debug_logging_html.h" #include "events_html.h" -#include "index_html.cpp" +#include "index_html.h" #include "settings_html.h" MyTimer ota_timeout_timer = MyTimer(15000); @@ -31,8 +31,6 @@ const char get_firmware_info_html[] = R"rawliteral(%X%)rawliteral"; void init_webserver() { - String content = index_html; - server.on("/logout", HTTP_GET, [](AsyncWebServerRequest* request) { request->send(401); }); // Route for firmware info from ota update page @@ -63,13 +61,15 @@ void init_webserver() { // Route for going to CAN logging web page server.on("/canlog", HTTP_GET, [](AsyncWebServerRequest* request) { - request->send_P(200, "text/html", index_html, can_logger_processor); + AsyncWebServerResponse* response = request->beginResponse(200, "text/html", can_logger_processor()); + request->send(response); }); #ifdef DEBUG_VIA_WEB // Route for going to debug logging web page server.on("/log", HTTP_GET, [](AsyncWebServerRequest* request) { - request->send_P(200, "text/html", index_html, debug_logger_processor); + AsyncWebServerResponse* response = request->beginResponse(200, "text/html", debug_logger_processor()); + request->send(response); }); #endif // DEBUG_VIA_WEB