2

I am trying to debug (and get an understanding of what is happening) a Python script that runs on a Raspberry Pi and uses Pygatt to communicate with a BLE peripheral device. I am trying to make it work using Visual Studio Code (because I use it for JavaScript) on a Linux Mint PC. My Python experience is minimal.

The script works fine on the Linux Mint PC with a CSR 4.0 dongle. I open a terminal and enter:

$ /usr/local/bin/python3.6 -i /home/rob/python-test/BLETestTool.py

The script runs, sets up the BLE adapter, and I get the >>> prompt. From there I can issue commands to connect and communicate with the device. The key to this is the "-i" argument. If I leave it out, the script just sets up the BLE adapter, which flashes a bit, and then terminates.

When I try to debug using VS Code the script starts without the "-i" argument and terminates. I have tried numerous settings in launch.json and I have been searching for hours.

Is it possible to invoke the -i argument when debugging Python in VS Code, or any other IDE? Alternatively, is there an alternative way to get the interactive command line experience working?

Any clues would be greatly appreciated.

Thanks in advance,

Rob

Rob
  • 29
  • 5

1 Answers1

0

The -i argument tells Python to exit into the REPL when the script is done running. It doesn't make sense to do that with the debugger. Instead, set a breakpoint in the script that gets hit before it exits. Then if you need to do interactive exploration you can use the debug console.

Brett Cannon
  • 14,438
  • 3
  • 45
  • 40