From 1a79744abc0398706fb72c425c5367396250cf65 Mon Sep 17 00:00:00 2001 From: ndrsnhs Date: Thu, 26 Jun 2025 15:23:17 +0200 Subject: [PATCH 1/2] extend debug: section form data; add usb devices --- packages/helpermodules/create_debug.py | 49 ++++---------------------- 1 file changed, 6 insertions(+), 43 deletions(-) diff --git a/packages/helpermodules/create_debug.py b/packages/helpermodules/create_debug.py index 279ea88a55..c99d74dd4d 100644 --- a/packages/helpermodules/create_debug.py +++ b/packages/helpermodules/create_debug.py @@ -4,7 +4,6 @@ from pathlib import Path from typing import Any, Optional import requests -import re from control import data from control.chargepoint.chargepoint import Chargepoint @@ -78,11 +77,9 @@ def get_hardware_data(): else: parsed_data += "aktuell: okay" if throttled & mask_undervoltage_reboot: - parsed_data += ", seit Reboot: Undervoltage (< 4.63V)\n" + parsed_data += ", seit Reboot: Undervoltage (< 4.63V)" else: - parsed_data += ", seit Reboot: okay\n" - parsed_data += f'{get_usb_rs()}' - parsed_data += f'{get_rfid_reader()}\n' + parsed_data += ", seit Reboot: okay" return parsed_data @@ -351,42 +348,6 @@ def merge_log_files(log_name, num_lines): return ''.join(lines[-num_lines:]) -def get_rfid_reader(): - devices = ["ffff:0035"] - device_count = 0 - parsed_data = "RFID_Reader: " - for device in devices: - result = re.sub(re.compile(r"Bus [0-9]+ Device [0-9]+: ID [0-9a-f]+:[0-9a-f]+ "), '', - run_shell_command(f"lsusb | grep {device} | tail -1")) - count = run_shell_command(f"lsusb | grep -c {device}") - device_count += int(count) - if int(count) > 0: - parsed_data += f"{int(count)}x {result}" - if device_count == 0: - parsed_data += "Kein RFID Reader gefunden" - elif device_count > 1: - parsed_data += f"Fehler: Es sind {device_count} RFID Reader gefunden worden\n" - return parsed_data - - -def get_usb_rs(): - devices = ["0403:6001", "1a86:55d3"] - device_count = 0 - parsed_data = "USB_RS: " - for device in devices: - result = re.sub(re.compile(r"Bus [0-9]+ Device [0-9]+: ID [0-9a-f]+:[0-9a-f]+ "), '', - run_shell_command(f"lsusb | grep {device} | tail -1")) - count = run_shell_command(f"lsusb | grep -c {device}") - device_count += int(count) - if int(count) > 0: - parsed_data += f"{int(count)}x {result}" - if device_count == 0: - parsed_data += "Kein USB/RS Wandler gefunden\n" - elif device_count > 1: - parsed_data += f"Fehler: Es sind {device_count} USB/RS Wandler gefunden worden\n" - return parsed_data - - def get_uuids(): try: with open(openwb_base_dir / 'data/log/uuid', 'r') as uuid_file: @@ -410,14 +371,15 @@ def write_to_file(file_handler, func, default: Optional[Any] = None): header = (f"{input_data['message']}\n{debug_email}\n{input_data['serialNumber']}\n" f"{input_data['installedComponents']}\n{input_data['vehicles']}\n") with open(debug_file, 'w+') as df: + write_to_file(df, lambda: "# section: form data #") write_to_file(df, lambda: header) write_to_file(df, lambda: f'# section: system #\n{get_common_data()}' f'Kernel: {run_shell_command("uname -s -r -v -m -o")}\n' f'Uptime:{run_command(["uptime"])}{run_command(["free"])}\n') - write_to_file(df, lambda: f'# section: hardware #\n{get_hardware_data()}\n') + write_to_file(df, lambda: f'# section: hardware #\n{get_hardware_data()}') + write_to_file(df, lambda: f'USB_Devices:{run_shell_command(["lsusb"])}\n') write_to_file(df, lambda: f"# section: configuration and state #\n{config_and_state()}") write_to_file(df, lambda: f"# section: uuids #\n{get_uuids()}\n") - write_to_file(df, lambda: f'# section: network #\n{run_command(["ip", "-s", "address"])}\n') write_to_file(df, lambda: f'# section: storage #\n{run_command(["df", "-h"])}\n') write_to_file(df, lambda: f"# section: broker essentials #\n{broker.get_broker_essentials()}\n") write_to_file( @@ -437,6 +399,7 @@ def write_to_file(file_handler, func, default: Optional[Any] = None): write_to_file(df, lambda: f'# section: soc log #\n{merge_log_files("soc", 1000)}\n') write_to_file(df, lambda: f'# section: charge log #\n{merge_log_files("chargelog", 1000)}\n') write_to_file(df, lambda: f"# section: broker #\n{broker.get_broker()}") + write_to_file(df, lambda: f'# section: network #\n{run_command(["ip", "-s", "address"])}\n') log.info("***** uploading debug log...") with open(debug_file, 'rb') as f: From d4413b0b0739591ca583bc60bd0229ba03a3a54b Mon Sep 17 00:00:00 2001 From: ndrsnhs Date: Mon, 30 Jun 2025 12:11:49 +0200 Subject: [PATCH 2/2] add filesystem dirty to uuid section --- runs/uuid.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/runs/uuid.sh b/runs/uuid.sh index c3f7e0b545..b1735b4da3 100755 --- a/runs/uuid.sh +++ b/runs/uuid.sh @@ -16,7 +16,7 @@ MAXTIMEDIFF=$((7 * 24 * 60 * 60)) # one week if [ ! -e "$LOGFILE" ]; then # create log file and header - echo "Date Time;Timestamp;openWB Serial Number;processor name;processor id;mac addr;ip addr;openWB Version;mmc serial number;mmc manufacturing date;Kernel" >"$LOGFILE" + echo "Date Time;Timestamp;openWB Serial Number;processor name;processor id;mac addr;ip addr;openWB Version;mmc serial number;mmc manufacturing date;Kernel;FS" >"$LOGFILE" else # check file size and truncate lines=$(wc -l "$LOGFILE" | cut -d " " -f 1) @@ -71,8 +71,16 @@ fi # kernel revision kernel=$(uname -r) +# filesystem dirtyflag +fs="-" +if (sudo dmesg | grep -i "recovery required on readonly filesystem"); then + fs=$(echo "dirty") +else + fs=$(echo "clean") +fi + # check for changes and time since last entry -newData="$owbSerial;$cpuName;$cpuId;$ethMac;$ipAddresses;$owbVersion;$mmcSerial;$mmcManufacturing;$kernel" +newData="$owbSerial;$cpuName;$cpuId;$ethMac;$ipAddresses;$owbVersion;$mmcSerial;$mmcManufacturing;$kernel;$fs" oldData=$(tail -n 1 "$LOGFILE" | cut -d ";" -f 3-) oldTimestamp=$(tail -n 1 "$LOGFILE" | cut -d ";" -f 2) if [[ $newData != "$oldData" ]] || ((now - oldTimestamp > MAXTIMEDIFF)); then