pre uart exchange

This commit is contained in:
2026-03-04 16:32:51 +01:00
parent b665cb5def
commit 4f3fbff258
46 changed files with 2820 additions and 3186 deletions

View File

@@ -0,0 +1,53 @@
# tool/core/cmd/fw_status.py
import struct
from core.utils import console, console_err
from core.protocol import COMMANDS, ERRORS
class fw_status:
def __init__(self, bus):
self.bus = bus
def get(self):
import struct
self.bus.send_request(COMMANDS['get_firmware_status'])
data = self.bus.receive_response(length=10)
if not data or data.get('type') == 'error':
return None
header = data['data']
status = header[0]
app_version_raw = struct.unpack('<I', header[1:5])[0]
ker_version_raw = struct.unpack('<I', header[5:9])[0]
str_len = header[9]
fw_string_bytes = self.bus.connection.read(str_len)
fw_string = fw_string_bytes.decode('utf-8')
result = {
'status': status,
'fw_version_raw': hex(app_version_raw),
'kernel_version_raw': hex(ker_version_raw),
'fw_major': (app_version_raw >> 24) & 0xFF,
'fw_minor': (app_version_raw >> 16) & 0xFF,
'fw_patch': (app_version_raw >> 8)& 0xFF,
'kernel_major': (ker_version_raw >> 16) & 0xFF,
'kernel_minor': (ker_version_raw >> 8) & 0xFF,
'kernel_patch': ker_version_raw & 0xFF,
'fw_string': fw_string,
'kernel_string': f"{(ker_version_raw >> 16) & 0xFF}.{(ker_version_raw >> 8) & 0xFF}.{ker_version_raw & 0xFF}"
}
return result
def print(self, result):
if not result:
return
status = "UNKNOWN"
if result['status'] == 0x00: status = "CONFIRMED"
elif result['status'] == 0x01: status = "PENDING"
elif result['status'] == 0x02: status = "TESTING"
console.print(f"[info]Firmware Status[/info] des Controllers ist [info]{status}[/info]:")
console.print(f" • Firmware: [info]{result['fw_string']}[/info] ({result['fw_major']}.{result['fw_minor']}.{result['fw_patch']})")
console.print(f" • Kernel: [info]{result['kernel_string']}[/info] ({result['kernel_major']}.{result['kernel_minor']}.{result['kernel_patch']})")