-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Feature: Single Step Debugger Support #49
Comments
you can deploy in debug mode already, no need for a complex ssh command ./robot.py deploy --debug this can be detected with if __name__ == "__main__":
if __debug__:
try:
import debugpy
except ModuleNotFoundError:
pass
else:
debugpy.listen(('0.0.0.0', 5678))
wpilib.run(MyRobot) |
that is way better than magic files. One moment please... |
https://github.com/RobotCasserole1736/firstRoboPy/blob/chris_daves_dandy_debug_design/robot.py#L117 Updated, works well. Tasks is a bit more complex now, to keep a "single button" paradigm I had to chain together the deploy with --debug and a short pause to let the RIO get up and running before the host PC tries to connect (otherwise vscode was giving me a connection refused error) Also, in the code stnippet, I added inspection to check that we were indeed running the code, not deploying or simulating. Otherwise, it's likely that debug is true, which will stall things out. I do think it's valid for teams to want to be able to walk through |
See also previous discussion: robotpy/robotpy-wpilib#99 |
Problem description
Basic debug support through
debugpy
works well today with vsCode.Documenting this here for potential future integration.
Overall design goal: single-click debugger activation that lets you walk code line by line on a development computer, while execution is happening on the RIO.
debugpy
on both the RIO and local desktoptasks.json:
launch.json:
Robot Code:
The real trick is just to make sure the robot code gets restarted with the correct value for
enableDebug
- it does slow down execution noticeably, and isn't something I think you'd want all the time.I've got no idea if there's a better way than a file (environment variables?), but that just seemed to be the most reliable way.
One nice thingabout using a file: if the code is simply redeployed, the file is wiped away, so the code goes back to "normal/non-debug" mode.
Hopefully helps? Other than the funkiness of the file itself, I'd highly recommend the rest.
Operating System
Windows
Installed Python Packages
Reproducible example code
The text was updated successfully, but these errors were encountered: