How to use serial port ttyS0 at TX2 and astro carrier board

I am using TX2 with actro carrier board.
To make sure whether ttyS0 works or not, I made loop back.
I connect 232TX1 and 232RX1 of astro carrier board that is UART.

To get permission, I typed ‘sudo chmod 660 /dev/ttyS0’
and I added tty to groups.
I printed my setting

ls -la /dev/ttyS*
crw-rw---- 1 nvidia tty 4, 64 Jul 23 02:56 /dev/ttyS0
crw-rw---- 1 root dialout 4, 65 Feb 11 2016 /dev/ttyS1
crw-rw---- 1 root dialout 4, 66 Feb 11 2016 /dev/ttyS2
crw-rw---- 1 root dialout 4, 67 Feb 11 2016 /dev/ttyS3
id
uid=1001(nvidia) gid=1001(nvidia) groups=1001(nvidia),4(adm),5(tty),20(dialout),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video)

I send data through write function of termios.
But, the read function of my code cannot receive data.
How can i receive data?

hello nory9023,

there are several discussion thread talking about this,
suggest you refer to similar issue, such as Topic 1025894, and Topic 1056970 for setting up serial communication.
thanks

Thank you for your reply.

I followed Topic 1056970.
I want to use ttyS0 which has 57600 baud.
So, I typed bellow as.

gtkterm -b 8 -t 1 -s 57600 -p /dev/ttyS0

But, only black screen comes out.

The other topics do mostly cover this, but I want to add a comment about the permissions for debug purposes:

>> ls -la /dev/ttyS*
crw-rw---- 1 nvidia tty 4, 64 Jul 23 02:56 /dev/ttyS0
crw-rw---- 1 root dialout 4, 65 Feb 11 2016 /dev/ttyS1
crw-rw---- 1 root dialout 4, 66 Feb 11 2016 /dev/ttyS2
crw-rw---- 1 root dialout 4, 67 Feb 11 2016 /dev/ttyS3

Any port which is open for use as a regular UART will be owner root, group dialout. The reason ttyS0 is group tty is because terminal software owns this device (the device is not available under current configuration as a general UART).

The ttyS* devices are not real files. These pseudo files were created by drivers, and possibly modified by udev. These devices start as “root/dialout” ownership. The software which bound ttyS0 to console function is the reason that particular device is “nvidia/tty” (tty as group tells more than who the owner is).

In the case of a serial console you should not attempt to access this directly on the Jetson…the kernel is already accessing this from the TX2 side. Any UART connection to an external serial console terminal program is how you would use this.

The other UARTs are available for general use. To use ttyS0 you would have to remove the serial console, and in that case, ownership would revert to “root/dialout”. FYI, you can add your user to group “dialout” for convenience if needed.

Were you using an external UART to talk to ttyS0? FYI, loopback for ttyS0 will be a disaster when a terminal talks to itself.

Astro carrier board support ttyS0 and ttyTHS2.
And I found that ttyS0 and ttyTHS2 ports are the opposite of what are described in the manual of astro carrier board.
So, I changed connection pins. Then, it works.

When I tested loopback at ttyS0, the read function can receives some datas, which are maybe from console. And, in loopback test of ttyTHS2, I could receive datas that I send.

About permissions, I thick we don’t need to give permissions to serial port.
We just need to add groups.

The bellow is my setting when it works.

ls -la /dev/ttyS*
crw------- 1 nvidia tty 4, 64 Jul 23 02:56 /dev/ttyS0
crw-rw---- 1 root dialout 4, 65 Feb 11 2016 /dev/ttyS1
crw-rw---- 1 root dialout 4, 66 Feb 11 2016 /dev/ttyS2
crw-rw---- 1 root dialout 4, 67 Feb 11 2016 /dev/ttyS3
id
uid=1001(nvidia) gid=1001(nvidia) groups=1001(nvidia),4(adm),5(tty),20(dialout),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video)

Yes, that should be good for permissions.

Hi Nory9023,

Did you manage to get the second serial port working on the astro carrier?
Can you elaborate on what you mean by “… ttyS0 and ttyTHS2 ports are the opposite of what are described in the manual of astro carrier board” ?

Thank you