added Debug-CLI on WebUI
This commit is contained in:
parent
024a00e1bf
commit
0763fe2181
@ -159,8 +159,11 @@
|
|||||||
<p>
|
<p>
|
||||||
<h4>Live Debug</h4>
|
<h4>Live Debug</h4>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<textarea class="form-control" spellcheck="false" id="livedebug-out" rows="3" readonly></textarea>
|
<input id="livedebug-in" type="text" class="set-wsevent data-livedebug-in form-control">
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group row">
|
||||||
|
<textarea class="form-control" spellcheck="false" id="livedebug-out" rows="3" readonly></textarea>
|
||||||
|
</div>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<div class="col text-center">
|
<div class="col text-center">
|
||||||
<button id="debugstart" class="btn-wsevent btn btn-outline-primary ml-2">Start</button>
|
<button id="debugstart" class="btn-wsevent btn btn-outline-primary ml-2">Start</button>
|
||||||
|
@ -1,27 +1,42 @@
|
|||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$(".navbar-nav a").on("click", function () {
|
// Event-Listener für Navbar-Links
|
||||||
$(".navbar-collapse").collapse("hide");
|
$(".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");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
document
|
// Event-Listener für Passwort zeigen/verborgen
|
||||||
.querySelector(".custom-file-input")
|
$("#show_hide_password a").on("click", function (event) {
|
||||||
.addEventListener("change", function (e) {
|
event.preventDefault();
|
||||||
var fileName = document.getElementById("fw-update-file").files[0].name;
|
var inputField = $("#show_hide_password input");
|
||||||
var nextSibling = e.target.nextElementSibling;
|
var icon = $("#show_hide_password i");
|
||||||
nextSibling.innerText = fileName;
|
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
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
@ -139,6 +139,10 @@ function websocket_sendevent(element_id, element_value) {
|
|||||||
websocket.send(element_id + ":" + element_value);
|
websocket.send(element_id + ":" + element_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function websocket_sendDebugCommand(command) {
|
||||||
|
websocket.send("debug-in:" + command);
|
||||||
|
}
|
||||||
|
|
||||||
function do_resize(textbox) {
|
function do_resize(textbox) {
|
||||||
var maxrows = 15;
|
var maxrows = 15;
|
||||||
var minrows = 3;
|
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 Debug_pushMessage(const char *format, ...);
|
||||||
void SetDebugportStatus(DebugPorts_t port, DebugStatus_t status);
|
void SetDebugportStatus(DebugPorts_t port, DebugStatus_t status);
|
||||||
void Debug_Process();
|
void Debug_Process();
|
||||||
|
void Debug_ProcessCommand(uint8_t *command);
|
||||||
#endif
|
#endif
|
@ -525,6 +525,20 @@ void Debug_Reboot()
|
|||||||
globals.systemStatus = sysStat_Shutdown;
|
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.
|
* @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-"));
|
Websocket_HandleSettings(data + strlen("set-"));
|
||||||
}
|
}
|
||||||
|
else if (strncmp((char *)data, "debug", strlen("debug")) == 0)
|
||||||
|
{
|
||||||
|
Debug_ProcessCommand(data - strlen("debug"));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug_pushMessage("Got unknown Websocket-Message '%s' from client\n", (char *)data);
|
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)
|
void Websocket_RefreshClientData_Status(uint32_t client_id, bool send_mapping)
|
||||||
{
|
{
|
||||||
if (send_mapping)
|
if (send_mapping)
|
||||||
{
|
{
|
||||||
const char mapping[] = "MAPPING_STATUS:"
|
const char mapping[] = "MAPPING_STATUS:"
|
||||||
"batterylevel;"
|
"batterylevel;"
|
||||||
"systemstatus;"
|
"systemstatus;"
|
||||||
"activefaction;"
|
"activefaction;"
|
||||||
"time_faction1;"
|
"time_faction1;"
|
||||||
"time_faction2;"
|
"time_faction2;"
|
||||||
"time_faction3;";
|
"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 (client_id > 0)
|
if (client_id > 0)
|
||||||
{
|
webSocket.text(client_id, mapping);
|
||||||
webSocket.text(client_id, dataString);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
webSocket.textAll(mapping);
|
||||||
webSocket.textAll(dataString);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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.
|
* @brief Refreshes client data related to static configuration parameters on WebSocket clients.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user