Skip to content

Commit

Permalink
When the board is in application-mode, send a RESET command and retry…
Browse files Browse the repository at this point in the history
… discovery
  • Loading branch information
ClemensElflein committed Jan 27, 2025
1 parent 2b89be2 commit 6b40a7e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
3 changes: 1 addition & 2 deletions bootloader/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions host-software/xbot-boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 6b40a7e

Please sign in to comment.