Nvidia jetson serial port problem

I bought tuf mini lidar for orin nano and made its connections. But when I ran the command on the screen, I received the following error. I connected the lidar pins as 2 (5v), 6 (GND) and 8,10 (UART). Energy is coming to the lidar, but there is no signal exchange.

What do you see from:
ls -l /dev/ttyTHS1

If the “group” is “dialout”, then you can fix this for any particular user without much trouble. If the “group” is “console”, then it gets more complicated because that port is already in use as a serial console.

Let’s pretend your user name that is using that port is “nvidia”, and that it is group “dialout”. You can add permission like this:
sudo usermod -aG dialout nvidia

Don’t use this port if the group is “console”. That requires different information.

It appeared to be in dialout mode, I did what you said, but it still gives the same error.

There is an error like this: Serial is seen when I run it on a single line (when I say >> import serial, there is no problem), but when I run it in a file with py extension, it gives the following error.

sudo python lidar.py
Traceback (most recent call last):
File “/home/fdemir/Downloads/lidar.py”, line 6, in
ser = serial.Serial(“/dev/ttyTHS1”, 115200)
NameError: name ‘serial’ is not defined

In this case you lack a user space library. It is the Python “serial” (serial.Serial()) call which fails, but not because of the ttyTHS1 being passed to it. It is because the library call itself does not exist.

I’m the wrong guy to ask Python questions to, but it looks like you need to include the PySerial library, and/or perhaps include it:
https://pyserial.readthedocs.io/en/latest/pyserial.html

Do note that there might be more than one installation source for this, and that the URL I gave might not give you the correct version. It is a start though. There is also an apt package for this. Check this out:
apt search python3-serial
(and then there is a possibility you are using python2…so many things I cannot answer)

The bottom line though is that it isn’t the Jetson with this issue; your program setup needs to be told what serial.Serial() actually is before it can attempt to use /dev/ttyTHS1.

I have the pyserial installation as follows.

Requirement already satisfied: pyserial in ./.local/lib/python3.10/site-packages (3.5)

Someone who knows Python and serial libraries can probably better answer. These lines though are fairly exact in naming the serial as being unknown:

ser = serial.Serial(“/dev/ttyTHS1”, 115200)
NameError: name ‘serial’ is not defined

Perhaps it is as simple as file permissions or not being in a search path, so on. Perhaps the version 2 or 3 of your library is incorrect for which python is actually running. Python itself though is the one that says that serial is unknown.

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