added Debug-CLI on WebUI
This commit is contained in:
parent
024a00e1bf
commit
0763fe2181
@ -158,6 +158,9 @@
|
||||
<hr />
|
||||
<p>
|
||||
<h4>Live Debug</h4>
|
||||
<div class="form-group row">
|
||||
<input id="livedebug-in" type="text" class="set-wsevent data-livedebug-in form-control">
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<textarea class="form-control" spellcheck="false" id="livedebug-out" rows="3" readonly></textarea>
|
||||
</div>
|
||||
|
@ -1,27 +1,42 @@
|
||||
$(document).ready(function () {
|
||||
// Event-Listener für Navbar-Links
|
||||
$(".navbar-nav a").on("click", function () {
|
||||
$(".navbar-collapse").collapse("hide");
|
||||
});
|
||||
|
||||
// Event-Listener für Passwort zeigen/verborgen
|
||||
$("#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");
|
||||
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");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
document
|
||||
.querySelector(".custom-file-input")
|
||||
.addEventListener("change", function (e) {
|
||||
// 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
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -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;
|
||||
|
@ -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
|
@ -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.
|
||||
*
|
||||
|
@ -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);
|
||||
@ -642,7 +646,6 @@ void Websocket_RefreshClientData_Status(uint32_t client_id, bool send_mapping)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Refreshes client data related to static configuration parameters on WebSocket clients.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user