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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user