Enhance logging functionality across multiple scripts, enabling debug mode checks and detailed communication logs for serial connections and firmware updates.

This commit is contained in:
“VeLiTi”
2025-11-14 16:38:05 +01:00
parent bd27bab30f
commit 04b9814c07
6 changed files with 214 additions and 19 deletions

View File

@@ -5,6 +5,11 @@ handshakeComplete = false;
// Function to log communication to API
async function logCommunication(data, direction) {
// Only log if debug mode is enabled
if (typeof DEBUG === 'undefined' || !DEBUG) {
return;
}
// Log all communication including connection/disconnection events
try {
// Get service token for API authentication
@@ -64,6 +69,7 @@ async function connectSerial() {
// Log selected port details
const portInfo = port.getInfo();
const portDetails = {
processStep: 'Assembly',
usbVendorId: portInfo.usbVendorId,
usbProductId: portInfo.usbProductId,
readable: !!port.readable,
@@ -84,6 +90,7 @@ async function connectSerial() {
// Log successful connection with details
const portInfoSuccess = port.getInfo();
const portDetailsSuccess = {
processStep: 'Assembly',
usbVendorId: portInfoSuccess.usbVendorId,
usbProductId: portInfoSuccess.usbProductId,
readable: !!port.readable,
@@ -528,6 +535,7 @@ async function closePort(){
// Log port closure start
const portInfo = port.getInfo();
const portDetails = {
processStep: 'Assembly',
usbVendorId: portInfo.usbVendorId,
usbProductId: portInfo.usbProductId,
readable: !!port.readable,
@@ -581,6 +589,7 @@ async function closePortCarTest(){
// Log port closure start
const portInfo = port.getInfo();
const portDetails = {
processStep: 'Assembly',
usbVendorId: portInfo.usbVendorId,
usbProductId: portInfo.usbProductId,
readable: !!port.readable,