Serial Port Communication using .net Core on NVIDIA® Jetson™ Nano™/Jetson™ Xavier™ NX/ Jetson™ TX2 NX Modules.
WHAT YOU WILL LEARN?
1- How to create a new console Application using VS Code
2- How to install extension packages using dotnet framework on console window
3- How to read and send values from using serial port communication.on C#
ENVIRONMENT
Hardware: DSBOARD-NX2 and MOXA USB to Serial RS232 adapter
OS: JetPack 4.5 (L4T-32.5)
Power Mode: MAXN
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/collections/carrier-boards
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
How to install extension packages using dotnet framework on console window
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.
How to read and send values from using serial port communication.on C#
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();”
Thank you for reading our blog post.