Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
07cacfc
change code sending script to stay connected to robot indefinitely
shaggysa Aug 27, 2025
9dfd844
add a menu to select options
shaggysa Aug 30, 2025
018af5a
move code resending to optional argument
shaggysa Aug 31, 2025
e1683b1
disable code resending when using usb
shaggysa Aug 31, 2025
aa342f4
bring longdemo.py back to original form
shaggysa Aug 31, 2025
1180a0d
fix poetry lock file
shaggysa Aug 31, 2025
e83e1e9
implement all suggestions
shaggysa Aug 31, 2025
004b3f5
move import statement to more suitable location
shaggysa Aug 31, 2025
4e878ee
move import statement to be in alphabetical order
shaggysa Aug 31, 2025
41e7a77
change unit tests to use the stay_connected arg
shaggysa Aug 31, 2025
dc1ecac
fix formatting issues
shaggysa Aug 31, 2025
c4e0745
fix additional formatting problem
shaggysa Aug 31, 2025
f76600c
Merge remote-tracking branch 'origin/master'
shaggysa Aug 31, 2025
3a595e4
fix the stdout echoing issue
shaggysa Sep 8, 2025
87ce5bc
fix some linting issues
shaggysa Sep 8, 2025
39d6675
fix more linting issues
shaggysa Sep 8, 2025
31561dc
linter fix V3
shaggysa Sep 8, 2025
888aa70
linter fix V4
shaggysa Sep 8, 2025
2b2ace0
Merge pull request #1 from shaggysa/stay-connected
shaggysa Sep 8, 2025
5bc6a3b
refactor and change the time to wait after power button is pressed
shaggysa Sep 9, 2025
f4dede9
make custom errors for the hub disconnect and power button press events
shaggysa Sep 9, 2025
52f055f
add proper handling of the new hub errors in the stay-connected code
shaggysa Sep 9, 2025
745a588
minor fixes and cleanup
shaggysa Sep 10, 2025
0633bfd
change uses of the exit function to return instead when possible
shaggysa Sep 10, 2025
476a1cd
Merge branch 'pybricks:master' into master
shaggysa Sep 10, 2025
2fa86cb
fix a windows specific issue where the wait_for_user_program_stop fun…
shaggysa Sep 10, 2025
3bec955
add a special case in the stay-connected implementation for when the …
shaggysa Sep 10, 2025
f088c1a
minor stability changes to the behavior when using the stay-connected…
shaggysa Sep 10, 2025
7429c39
remove unnecessary parameters from the hub wait_for methods
shaggysa Sep 10, 2025
76a0b89
CHANGELOG.md: Add entry for the --stay-connected arg
shaggysa Sep 11, 2025
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
15 changes: 14 additions & 1 deletion poetry.lock

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

29 changes: 24 additions & 5 deletions pybricksdev/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import argcomplete
from argcomplete.completers import FilesCompleter
import simple_term_menu

from pybricksdev import __name__ as MODULE_NAME
from pybricksdev import __version__ as MODULE_VERSION
Expand Down Expand Up @@ -160,6 +161,13 @@ def add_parser(self, subparsers: argparse._SubParsersAction):
default=True,
)

parser.add_argument(
"--resend",
help="Add a menu option to resend the code with bluetooth instead of disconnecting from the robot after the program ends.",
action=argparse.BooleanOptionalAction,
default=False,
)

async def run(self, args: argparse.Namespace):

# Pick the right connection
Expand Down Expand Up @@ -213,11 +221,22 @@ def is_pybricks_usb(dev):
# Connect to the address and run the script
await hub.connect()
try:
with _get_script_path(args.file) as script_path:
if args.start:
await hub.run(script_path, args.wait)
else:
await hub.download(script_path)
while True:
with _get_script_path(args.file) as script_path:
if args.start:
await hub.run(script_path, args.wait)
else:
await hub.download(script_path)

if args.conntype == "usb" or not args.wait or not args.resend:
break

menu = simple_term_menu.TerminalMenu(["Resend Code", "Exit"])
entry = menu.show()

if entry:
break

finally:
await hub.disconnect()

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ typing-extensions = ">=4.3.0"
reactivex = {version = ">=4.0.4", python = "<4"}
hidapi = ">=0.14.0"
pybricks = {version = ">=3", allow-prereleases = true, python = "<4"}
simple-term-menu = {version = ">=1.6.6", python = "<4"}

[tool.poetry.group.lint.dependencies]
black = ">=23,<25"
Expand Down
Loading