Serial Port Communication using .net Core on NVIDIA JETSON NANO/Xavier NX/NX2 TX Modules.
Jetson Nano Jetson TX2 NX Jetson Xavier NX 01 April 2021

In this article, we will explain how to use Serial communication with .net Core on ARM64 which has an operating system as Ubuntu 18.04 for NVIDIA Jetson Nano/Xavier NX modules.

For this application, we will be using our custom carrier board Forecr DSBOARD-NX2 carrier board. You can find detailed information about DSBOARD-NX2 from the link below;

https://www.forecr.io/dsboard

Also, we will be using MOXA USB to serial RS232 adaptor for serial communication. You can find the drivers for this adapter from the link below;

https://www.moxa.com/en/support/product-support/software-and-documentation/search?psid=114473

After, we have finished the installation process, let’s create a sample C# serial port application using a VS code. We need to create a new console app with the following command:

Next, we should install "System.IO.Ports" and "System. Threading". To do this, navigate to the Project Directory and type following command:

 

Now, let’s open the application with the VSCode. Then,type the following command:

 

Our main focus in this application will be to read a value entered from the console and send it back to the console to see the values we have entered.

We can get our port names with this method:

“String[] ports=SerialPort.GetPortNames()”;

The output will be as follows:

 

In this application, we use our DSBOARD-NX2 with NVIDIA Jetson Nano module, so the name of the port is “/dev/ttyTHS1”. If we use Jetson Xavier NX we should use “/dev/ttyTHS1” and for Jetson TX2 NX “/dev/ttyTHS2”.  This serial port corresponds to pins 203,205,207,209 on module pinout.

Now, we created a new serial port object with default settings and set all the properties.

 

Then, we create a new thread. In this thread, we can read and send serial port inputs from another PC console.

 

Right now you can see what we send and write as an input and output.

 

Finally, we close the ports we have opened before with “serialPort.Close();”

 

 Thanks for reading.