From 6b40a7e891597b44db2be6c6daf491c998493184 Mon Sep 17 00:00:00 2001 From: Clemens Elflein Date: Mon, 27 Jan 2025 19:15:39 +0100 Subject: [PATCH] When the board is in application-mode, send a RESET command and retry discovery --- bootloader/.idea/workspace.xml | 3 +-- host-software/xbot-boot.py | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/bootloader/.idea/workspace.xml b/bootloader/.idea/workspace.xml index f54daeb..0cbbe40 100644 --- a/bootloader/.idea/workspace.xml +++ b/bootloader/.idea/workspace.xml @@ -44,7 +44,6 @@ - diff --git a/host-software/xbot-boot.py b/host-software/xbot-boot.py index a5bf908..c54f50d 100755 --- a/host-software/xbot-boot.py +++ b/host-software/xbot-boot.py @@ -123,9 +123,19 @@ def discover_boards(timeout, interface_ip=None): data, address = rx_sock.recvfrom(1024) # Ignore messages from ourselves message = data.decode().strip() - if message == 'DISCOVER_REQUEST': + if message == 'DISCOVER_REQUEST' or message == 'RESET': continue - print(f"Received advertisement from {address[0]}: {data.decode().strip()}") + info = data.decode().strip() + print(f"Received advertisement from {address[0]}: {info}") + # Reset the board, if in application mode + if info.endswith("application-mode"): + # only resend on timeout + print("Board in application mode, sending RESET to board") + tx_sock.sendto(b'RESET', (address[0], BROADCAST_PORT)) + try_number = 0 + sent = False + continue + # Return the IP of the first board that responds return address[0] except socket.timeout: