I am currently testing a USB3 camera from ImagingSource on a Verdin IMX8-MP. I was able to interact with the camera in a little python docker application which was manually build and executed.
Now I would like to execute the application in debugging mode out of VSCode. In order to interact with the camera it is mandatory to execute a shell script in the very same shell as the python application will be started. Therefore my question is how to integrate the following docker application start command into the debugging structure of the Torizon PlugIn
Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!
Did you like my answer?
Hello,
To execute a shell script and a Python application in the same shell session while debugging with Visual Studio Code using the Torizon extension, you’ll need to adjust the launch.json configuration file. This file dictates how your application is launched during a debugging session.
Here’s how you can integrate your shell script execution into the debugging process:
Open the launch.json file: This file is typically found in the .vscode directory of your project. If it doesn’t exist, you can create it using the Visual Studio Code command palette by selecting “Torizon: Configure Debugging”.
Modify the launch.json file: Ensure the shell script runs before the Python application by setting up a preLaunchTask or modifying the program and args fields. Here’s an example configuration:
Ensure the shell script is executable: Make sure start.sh has the correct permissions by running chmod +x src/start.sh in your terminal.
Start the debugging session: With these configurations, the shell script will run first, followed by the Python application, allowing you to interact with your USB3 camera as needed.
I hope this helps you set up your debugging environment effectively.
Best regards,
Toradex AI Assistant
Please, also check if these links can help you solve your problem:
I want to clarify exactly what you want to do as I’m a little confused.
In your initial post you said:
Now I would like to execute the application in debugging mode out of VSCode.
Which I mean to understand you want to do this out/separate to VSCode, but then the rest of the thread it looks like you want to do it with VSCode. So you do want to do this with our VSCode extension then?
If that is correct, then you could try to modify the Dockerfile.debug file in your VSCode project. At the bottom of the file there is a CMD directive that tells the container to start sshd on container startup, which is used for debugging communication. You could try to modify this directive to start sshd, and then execute your script. As I understand your script only needs to be ran prior to your python application.
Though I see you did say:
with the camera it is mandatory to execute a shell script in the very same shell as the python application will be started.
I don’t understand the technical workings of your script, but if it’s really needed that these are executed in the same scope. Maybe you can just execute the shell script from the Python application, would this not work as well?
Sorry for confusion.
Yes you’re right. I want to use the VSCode plugin to debug my application.
The script only contains a start call for a service.
#!/bin/bash
# Start the first process
usr/bin/ic4-gentl-u3v-service &
I’ve already tried to call this script out of Python but for some reason it didn’t work while calling the script right before calling the Python application solves the issue in a local console.
I’ve already tried to call this script out of Python but for some reason it didn’t work while calling the script right before calling the Python application solves the issue in a local console.
That sounds strange though, no? Why would this only work when you call it on the console before the Python application?
I can’t really comment in-depth since I don’t know how this ic4-gentl-u3v-service is suppose to work. Judging from the script though it looks like it runs in the background, hence the &. But then you should be able to achieve a similar effect with a subprocess in Python.
That’s really odd if it only works as you described, it also makes it difficult to make this work then with the standard debug process.