# tool/core/cmd/get_file.py import struct import zlib from pathlib import Path from core.utils import console, console_err from core.protocol import COMMANDS class get_file: def __init__(self, bus): self.bus = bus def get(self, source_path: str, dest_path: str): try: p = Path(dest_path) p.parent.mkdir(parents=True, exist_ok=True) with open(p, 'wb') as f: pass except Exception as e: console_err.print(f"Fehler: Kann Zieldatei nicht anlegen: {e}") return None source_path_bytes = source_path.encode('utf-8') payload = struct.pack('B', len(source_path_bytes)) + source_path_bytes device_file_crc = None try: self.bus.send_request(COMMANDS['crc_32'], payload) crc_resp = self.bus.receive_response(length=4) if crc_resp and crc_resp.get('type') == 'response': device_file_crc = struct.unpack('