Using can0 interface within torizon container created by VS code

I am currently working on a software which is interacting with the CAN network via the can0 network interface (socketcan). Now I wanted to deploy my application to a new Torizon container via the Visual Studio Code Torion plugin. This generally works, but within the container the can0 interface is not available.

I can manually start a new container with the following arguments which work:
–net=host --cap-add=“NET_ADMIN”

How can I support this out-of-the-box in Visual-Studio? I tried setting the networks to “host” but then deploying does not work any more.

PS: I am using Torizon 5.4.0+build.10 with a Colibri iMX8QXP module (Rev. 1.1C)

Hi @oklemencic!

Have you enabled the CAN node on the device tree?

This can be done using TorizonCore Builder Tool - Customizing TorizonCore Images for the specific feature that you need. For CAN, it is worth reading also:

Colibri iMX8X has 3 CAN controllers, but the one on pins 63/55 is the recommended one due to its compatibility with the largest number of modules in the Colibri family.

Best regards,

Yes. When calling “docker run” manually using the –net=host --cap-add=“NET_ADMIN” command line arguments the container works fine.

How can I add those arguments using the VS Code extension?

Hi, @oklemencic !

I’m not sure that you understood my message.

The configuration that I’m talking about is related to the device tree. More specifically with device tree overlay, that you must manually create and apply using the TorizonCore Builder Tool - Customizing TorizonCore Images.

Have you enabled the CAN interface by applying a device tree overlay in your TorizonCore image?

Best regards,

Hi @henrique.tx ,

I have understood that. The device is properly working both in the host-OS and in the docker container.

My question is about the Torizon VS Code integration: I can not deploy the container from VS Code because of the default network configuration of the container. The CAN interface is not shown in the container then. How to properly configure the container to use host-networking?


Oh, sorry!

Then you are ahead of me. :stuck_out_tongue:

Please refer to the How to Use CAN on TorizonCore article. In the section " Developing a CAN application with Visual Studio Code and Python", you will see the setup needed.

Although the article is using a Python Project as an example, the stuff non-related to Python is independent from the language used.

Let me know if this helps you.

Best regards,

Thanks. I added the following values for extraparams which solved the issue:
cap_add: CAP_NET_ADMIN
network_mode: host