How can I use 'pyserial' to communicate between my Ubuntu PC and JetsonOrin?

How can I use ‘pyserial’ to communicate between my Ubuntu PC and my Jetson AGX Orin?

The configuration of Jetson AGX Orin is as follows.

  • Jetson AGX Orin Dev Kit.
  • Jetpack 5.0.2.
  • Headless mode.

The USB port uses the type-C port next to the GPIO pins.
I’m guessing that /dev/ttyACM0 should be used for dmesg on the Ubuntu PC side below.

[19971.006930] usb 2-1: new SuperSpeed Gen 1 USB device number 4 using xhci_hcd
[19971.027486] usb 2-1: New USB device found, idVendor=0955, idProduct=7020, bcdDevice= 0.02
[19971.027490] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[19971.027492] usb 2-1: Product: Linux for Tegra
[19971.027495] usb 2-1: Manufacturer: NVIDIA
[19971.027496] usb 2-1: SerialNumber: 1421922016941
[19971.033425] rndis_host 2-1:1.0 usb0: register 'rndis_host' at usb-0000:00:14.0-1, RNDIS device, 0a:66:59:96:aa:d5
[19971.034296] cdc_acm 2-1:1.2: ttyACM0: USB ACM device
[19971.035037] usb-storage 2-1:1.4: USB Mass Storage device detected
[19971.035595] scsi host9: usb-storage 2-1:1.4
[19971.055598] cdc_ncm 2-1:1.5: MAC-Address: 4e:aa:f3:18:4f:5a
[19971.055817] cdc_ncm 2-1:1.5 usb1: register 'cdc_ncm' at usb-0000:00:14.0-1, CDC NCM, 4e:aa:f3:18:4f:5a
[19971.072185] rndis_host 2-1:1.0 enp0s20f0u1: renamed from usb0
[19971.103378] cdc_ncm 2-1:1.5 enp0s20f0u1i5: renamed from usb1
[19971.173542] cdc_ncm 2-1:1.5 enp0s20f0u1i5: 3750 mbit/s downlink 3750 mbit/s uplink
[19971.237609] IPv6: ADDRCONF(NETDEV_CHANGE): enp0s20f0u1i5: link becomes ready
[19972.059297] scsi 9:0:0:0: Direct-Access     Linux    File-Stor Gadget 0510 PQ: 0 ANSI: 2
[19972.059798] sd 9:0:0:0: Attached scsi generic sg3 type 0
[19972.060002] sd 9:0:0:0: Power-on or device reset occurred
[19972.060275] sd 9:0:0:0: [sdc] 32768 512-byte logical blocks: (16.8 MB/16.0 MiB)
[19972.060408] sd 9:0:0:0: [sdc] Write Protect is on
[19972.060411] sd 9:0:0:0: [sdc] Mode Sense: 0f 00 80 00
[19972.060537] sd 9:0:0:0: [sdc] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[19972.083823]  sdc:
[19972.104166] sd 9:0:0:0: [sdc] Attached SCSI removable disk
[20083.042616] perf: interrupt took too long (2505 > 2500), lowering kernel.perf_event_max_sample_rate to 79750

On the other hand, the Jetson side searched for the serial port using the following python script, but could not find it.

from serial.tools import list_ports
import pprint
pprint.pprint(list(list_ports.comports()))
# []

Here is the result of dmesg | grep tty on the Jetson side.

[    0.000000] Kernel command line: root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 mminit_loglevel=4 console=ttyTCU0,115200 console=ttyAMA0,115200 console=tty0 firmware_class.path=/etc/firmware fbcon=map:0 net.ifnames=0 nv-auto-config 
[    0.000930] printk: console [tty0] enabled
[    0.404105] 31d0000.serial: ttyAMA0 at MMIO 0x31d0000 (irq = 66, base_baud = 0) is a SBSA
[    1.705860] printk: console [ttyAMA0] enabled
[    2.484256] printk: console [ttyTCU0] enabled
[    9.753970] 3100000.serial: ttyTHS0 at MMIO 0x3100000 (irq = 13, base_baud = 0) is a TEGRA_UART
[    9.770213] 3130000.serial: ttyTHS3 at MMIO 0x3130000 (irq = 65, base_baud = 0) is a TEGRA_UART
[   14.432416] systemd[1]: Created slice system-serial\x2dgetty.slice.

Hi,
Please check if it is good to get uart log in your use-case. The uart log is outputted in the micro-B port. If you connect it to your host PC through type-A to micro-B adapter, you can read log on the host PC.

Hi. thank you for your reply.

I immediately tried using the type-A to type micro-B adapter.
The output of dmesg on the Ubuntu PC side is below.

[28727.531927] rndis_host 2-1:1.0 enp0s20f0u1: unregister 'rndis_host' usb-0000:00:14.0-1, RNDIS device
[28727.677159] cdc_ncm 2-1:1.5 enp0s20f0u1i5: unregister 'cdc_ncm' usb-0000:00:14.0-1, CDC NCM
[28783.573855] usb 1-3: new full-speed USB device number 15 using xhci_hcd
[28783.723618] usb 1-3: New USB device found, idVendor=0955, idProduct=7045, bcdDevice= 0.01
[28783.723623] usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[28783.723626] usb 1-3: Product: Tegra On-Platform Operator
[28783.723629] usb 1-3: Manufacturer: NVIDIA
[28783.723631] usb 1-3: SerialNumber: TOPO6492DB4B
[28783.729493] hid-generic 0003:0955:7045.000E: hiddev1,hidraw3: USB HID v1.10 Device [NVIDIA Tegra On-Platform Operator] on usb-0000:00:14.0-3/input0
[28783.729821] cdc_acm 1-3:1.1: ttyACM0: USB ACM device
[28783.730422] cdc_acm 1-3:1.3: ttyACM1: USB ACM device
[28783.730977] cdc_acm 1-3:1.5: ttyACM2: USB ACM device
[28783.731500] cdc_acm 1-3:1.7: ttyACM3: USB ACM device

Found 4 serial ports.
Which port should I use?

I tried the below python script again on the Jetson side and it didn’t find the port.

from serial.tools import list_ports
import pprint
pprint.pprint(list(list_ports.comports()))
# []

dmesg on JetsonOrinAgx side does not show new logs.

I look forward to hearing from you.

Hi,
Please refer to this page and see if you can use minicom successfully first:
NVIDIA Jetson Orin - Serial Console

And for using pyserial, it would need other users to share experience.

1 Like

Hi, thanks for the reply.
Communication using minicom was successful with both:

  • Type-A to micro-B
  • Type-A to Type-C

I’m waiting for someone to tell me how to communicate using ‘pyserial’.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.