In this article, we will show how you can manipulate UART using Visual Studio Code Extension for Torizon.
This article complies to the Typographic Conventions for Torizon Documentation
In the following sections, we will demonstrate how to use the VS Code Extension for Torizon.
In Linux systems, including TorizonCore, UART devices can be accessed through
/dev/tty*. Depending on the UART hardware implementation, those devices can have different names. Take a look to UART (Linux) article to understand the different
/dev/tty* names across the Toradex's Modules.
Once you identify the exact name for your UART device, you can add it to your application.
On VS Code, create a new Torizon Python Application. See the Python Development and Debugging on TorizonCore Using Visual Studio Code article for detailed instructions.
To add UART to your project, first, open the Torizon Configuration View. To do that, press F1 in Visual Studio Code command bar and then type "Torizon/Python: Focus on Configurations View"
On the device item, press the '+' button on the right.
On the same command box, type the selected tty device. As an example, we will add
/dev/tty0 is a ficticious example. Find your UART name on the previous section Define the UART Device.
Check if the device was added to your project.
By default UART devices are accessible only for users that belong to the dialout group, the torizon user is not part of that group in the base container configuration, but you can fix this by setting the "buildcommands" custom property to:
RUN usermod -a -G dialout torizon
The serial port can be used with several programming languages and libraries, same as with any Linux distribution. This article focuses on Python.
Documented use cases are provided in the following subsections.
The example application used in this article comes from the example Python: Connect to a Serial GPS. Please read the following sections from it:
Use the instructions from the beginning of this article to add the corresponding /dev/tty* to your project. On the Apalis iMX6, UART2 is accessible through
Remember to also add the user to the dialout group.
This example is very simple. From your new empty project template, you only need to replace the content of 2 files: requirements.txt and main.py:
F5 to build and run the example.
Time = 07:53:31 Latitude = 3340.18707, N Longitude = 07259.43225, E . .