Reading UART devices not working from Visual Studio


I am trying to connect to serial devices connected to my Apalis iMX8 module from visual studio professional 2019. Before I build and deploy my solution in the debug configuration, I have added the following devices in the torizon c++ application properties:
devices: /dev/ttyACM0 /dev/ttyACM1

I can connect and read the data from these devices from the running container on the module (if I step into the running container and execute the binary from there). But the same program does not work if I try to deploy the solution from visual studio.

int serialfd = open(constr, O_RDWR | O_NOCTTY | O_SYNC); ← returns -1 when deployed from visual studio.

I would expect that the output shown in Debug->Linux Console in Visual studio to be coming from module on which it is deployed. What could be that I am missing here?



Hi @jeremias.tx ,

Thanks for the answer. The issue was due to not adding RUN usermod -a -G dialout to torizon buildcommands property. It started working as soon as I added this property.

It would be great if you would make a documentation about all the properties need to be set(or most of them that would be frequently needed) in Torizon c++ project in visual studio. Most of my issues were due to not knowing the right properties and I always had to wait for someone (mostly you!) from the community to answer/help me.

Thanks and regards,


Greetings @rudhi31,

I have a couple of theories and ideas. So first of all in both cases is the container being launched with the same set of arguments/flags? Though it sounds like in both cases you’re starting the container from VS, but I just want to make sure.

Next are you adding RUN usermod -a -G dialout torizon to the buildcommands property? This property will give the “torizon” user in the container permissions to use the serial/UART interface. What might be happening is that you’re not giving the container the proper permissions to use the serial devices. However when you step into the container manually you typically do so as the root user which eliminates the need for extra permissions. This might explain the difference in behavior you’re seeing.

Best Regards,

Glad it worked for you! Yes we’re still trying to catch up on documentation here and there with Torizon and the IDE extensions. For example this little tidbit about that property is noted in our general UART on Torizon guide: How to Use UART with Torizon Visual Studio Code Extension (Python) | Toradex Developer Center

Though you are correct that this can be hard to find if you’re unsure what you’re looking for. I’ll see what we can do to improve this.

Best Regards,