Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 6 additions & 43 deletions packages/helpermodules/create_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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:
Expand All @@ -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(
Expand All @@ -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:
Expand Down
12 changes: 10 additions & 2 deletions runs/uuid.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down