From 87aef9b4eede52125516ab3db1cb8cc43adc35f1 Mon Sep 17 00:00:00 2001 From: David Vo Date: Mon, 11 Feb 2019 19:55:11 +1100 Subject: [PATCH] Add way to remote debug with VS Code --- .vscode/tasks.json | 12 ++++++++++++ robot.py | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 238b157..e0816fd 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -24,6 +24,18 @@ "deploy" ] }, + { + "label": "deploy (debug mode)", + "type": "process", + "group": "build", + "command": "${config:python.pythonPath}", + "args": [ + "robot.py", + "deploy", + "--debug", + "--nc" + ] + }, { "label": "test", "type": "process", diff --git a/robot.py b/robot.py index 5973be8..7b388c3 100755 --- a/robot.py +++ b/robot.py @@ -269,5 +269,14 @@ def closest_field_angle(self, robot_heading): return label +# Allow attaching the Visual Studio/VS Code debugger if ptvsd is installed. +# Deploy with --debug to use this on the roboRIO. +if __debug__: + try: + import ptvsd + ptvsd.enable_attach() + except Exception: + pass + if __name__ == "__main__": wpilib.run(Robot)