diff --git a/Software/data_src/index.htm b/Software/data_src/index.htm
index 1ebc688..d28047e 100644
--- a/Software/data_src/index.htm
+++ b/Software/data_src/index.htm
@@ -159,8 +159,11 @@
Live Debug
-
-
+
+
+
+
+
diff --git a/Software/data_src/static/js/script.js b/Software/data_src/static/js/script.js
index 0cc7c8c..c84cfda 100644
--- a/Software/data_src/static/js/script.js
+++ b/Software/data_src/static/js/script.js
@@ -1,27 +1,42 @@
$(document).ready(function () {
- $(".navbar-nav a").on("click", function () {
- $(".navbar-collapse").collapse("hide");
- });
-
- $("#show_hide_password a").on("click", function (event) {
- event.preventDefault();
- if ($("#show_hide_password input").attr("type") == "text") {
- $("#show_hide_password input").attr("type", "password");
- $("#show_hide_password i").addClass("fa-eye-slash");
- $("#show_hide_password i").removeClass("fa-eye");
- } else if ($("#show_hide_password input").attr("type") == "password") {
- $("#show_hide_password input").attr("type", "text");
- $("#show_hide_password i").removeClass("fa-eye-slash");
- $("#show_hide_password i").addClass("fa-eye");
- }
- });
+ // Event-Listener für Navbar-Links
+ $(".navbar-nav a").on("click", function () {
+ $(".navbar-collapse").collapse("hide");
});
-
- document
- .querySelector(".custom-file-input")
- .addEventListener("change", function (e) {
- var fileName = document.getElementById("fw-update-file").files[0].name;
- var nextSibling = e.target.nextElementSibling;
- nextSibling.innerText = fileName;
- });
-
\ No newline at end of file
+
+ // Event-Listener für Passwort zeigen/verborgen
+ $("#show_hide_password a").on("click", function (event) {
+ event.preventDefault();
+ var inputField = $("#show_hide_password input");
+ var icon = $("#show_hide_password i");
+ if (inputField.attr("type") == "text") {
+ inputField.attr("type", "password");
+ icon.addClass("fa-eye-slash");
+ icon.removeClass("fa-eye");
+ } else if (inputField.attr("type") == "password") {
+ inputField.attr("type", "text");
+ icon.removeClass("fa-eye-slash");
+ icon.addClass("fa-eye");
+ }
+ });
+
+ // Event-Listener für Datei-Upload
+ $(".custom-file-input").on("change", function (e) {
+ var fileName = document.getElementById("fw-update-file").files[0].name;
+ var nextSibling = e.target.nextElementSibling;
+ nextSibling.innerText = fileName;
+ });
+
+ // Event-Listener für Live-Debug-Eingabe
+ $('#livedebug-in').on('keydown', function(event) {
+ if (event.key === 'Enter' || event.keyCode === 13) {
+ event.preventDefault(); // Verhindert, dass die Enter-Taste die Standardaktion ausführt (z.B. Absenden eines Formulars)
+
+ const command = $('#livedebug-in').val(); // Den Befehl aus dem Eingabefeld holen
+ executeCommand(command); // Den Befehl an die Funktion übergeben
+
+ $('#livedebug-in').val(''); // Leert das Eingabefeld
+ $('#livedebug-in').focus(); // Setzt den Fokus zurück auf das Eingabefeld
+ }
+ });
+});
diff --git a/Software/data_src/static/js/websocket.js b/Software/data_src/static/js/websocket.js
index 57a89a9..15e8165 100644
--- a/Software/data_src/static/js/websocket.js
+++ b/Software/data_src/static/js/websocket.js
@@ -139,6 +139,10 @@ function websocket_sendevent(element_id, element_value) {
websocket.send(element_id + ":" + element_value);
}
+function websocket_sendDebugCommand(command) {
+ websocket.send("debug-in:" + command);
+}
+
function do_resize(textbox) {
var maxrows = 15;
var minrows = 3;
diff --git a/Software/include/debugger.h b/Software/include/debugger.h
index 60e0d36..74020ef 100644
--- a/Software/include/debugger.h
+++ b/Software/include/debugger.h
@@ -57,5 +57,5 @@ void pushCANDebug(uint32_t id, uint8_t dlc, uint8_t *data);
void Debug_pushMessage(const char *format, ...);
void SetDebugportStatus(DebugPorts_t port, DebugStatus_t status);
void Debug_Process();
-
+void Debug_ProcessCommand(uint8_t *command);
#endif
\ No newline at end of file
diff --git a/Software/src/debugger.cpp b/Software/src/debugger.cpp
index 30d940e..b7fe3e1 100644
--- a/Software/src/debugger.cpp
+++ b/Software/src/debugger.cpp
@@ -525,6 +525,20 @@ void Debug_Reboot()
globals.systemStatus = sysStat_Shutdown;
}
+/**
+ * @brief Processes a debug command.
+ *
+ * This function takes a pointer to a debug command and processes it by
+ * passing it to the `processCmdDebug` function. The command is expected
+ * to be a string, so it is cast to `const char *` before being processed.
+ *
+ * @param command Pointer to the debug command, expected to be a null-terminated string.
+ */
+void Debug_ProcessCommand(uint8_t *command)
+{
+ processCmdDebug((const char *)command);
+}
+
/**
* @brief Convert a uint32_t value to a binary string with nibbles separated by a space.
*
diff --git a/Software/src/webui.cpp b/Software/src/webui.cpp
index 77958cb..24edf67 100644
--- a/Software/src/webui.cpp
+++ b/Software/src/webui.cpp
@@ -424,6 +424,10 @@ void Websocket_HandleMessage(void *arg, uint8_t *data, size_t len)
{
Websocket_HandleSettings(data + strlen("set-"));
}
+ else if (strncmp((char *)data, "debug", strlen("debug")) == 0)
+ {
+ Debug_ProcessCommand(data - strlen("debug"));
+ }
else
{
Debug_pushMessage("Got unknown Websocket-Message '%s' from client\n", (char *)data);
@@ -604,44 +608,43 @@ void Websocket_RefreshClientData_DTCs(uint32_t client_id)
*/
void Websocket_RefreshClientData_Status(uint32_t client_id, bool send_mapping)
{
- if (send_mapping)
- {
- const char mapping[] = "MAPPING_STATUS:"
- "batterylevel;"
- "systemstatus;"
- "activefaction;"
- "time_faction1;"
- "time_faction2;"
- "time_faction3;";
-
- if (client_id > 0)
- webSocket.text(client_id, mapping);
- else
- webSocket.textAll(mapping);
-
- Debug_pushMessage("send MAPPING_STATUS WS-Client Data\n");
- }
-
- char dataString[200] = {0}; // Maximal 200 Zeichen für den Data-String
-
- sprintf(dataString, "STATUS:%d;%s;%d;%ld;%ld;%ld;",
- globals.battery_level,
- globals.systemStatustxt,
- PersistenceData.activeFaction,
- PersistenceData.faction_1_timer,
- PersistenceData.faction_2_timer,
- PersistenceData.faction_3_timer);
+ if (send_mapping)
+ {
+ const char mapping[] = "MAPPING_STATUS:"
+ "batterylevel;"
+ "systemstatus;"
+ "activefaction;"
+ "time_faction1;"
+ "time_faction2;"
+ "time_faction3;";
if (client_id > 0)
- {
- webSocket.text(client_id, dataString);
- }
+ webSocket.text(client_id, mapping);
else
- {
- webSocket.textAll(dataString);
- }
-}
+ webSocket.textAll(mapping);
+ Debug_pushMessage("send MAPPING_STATUS WS-Client Data\n");
+ }
+
+ char dataString[200] = {0}; // Maximal 200 Zeichen für den Data-String
+
+ sprintf(dataString, "STATUS:%d;%s;%d;%ld;%ld;%ld;",
+ globals.battery_level,
+ globals.systemStatustxt,
+ PersistenceData.activeFaction,
+ PersistenceData.faction_1_timer,
+ PersistenceData.faction_2_timer,
+ PersistenceData.faction_3_timer);
+
+ if (client_id > 0)
+ {
+ webSocket.text(client_id, dataString);
+ }
+ else
+ {
+ webSocket.textAll(dataString);
+ }
+}
/**
* @brief Refreshes client data related to static configuration parameters on WebSocket clients.