Jetson Nano and TfMini Plus Lidar

Hello, I am having trouble trying to connect my TFMini plus to the Jetson Nano via the UART RX and TX. I will show my code below:

-- coding: utf-8 -

import serial
import time

ser = serial.Serial(“/dev/ttyTHS1”, 115200)

def getTFminiData():
while True:
#time.sleep(0.1)
count = ser.in_waiting
if count > 8:
recv = ser.read(9)
ser.reset_input_buffer()
# type(recv), ‘str’ in python2(recv[0] = ‘Y’), ‘bytes’ in python3(recv[0] = 89)
# type(recv[0]), ‘str’ in python2, ‘int’ in python3

        if recv[0] == 0x59 and recv[1] == 0x59:     #python3
            distance = recv[2] + recv[3] * 256
            strength = recv[4] + recv[5] * 256
            print('(', distance, ',', strength, ')')
            ser.reset_input_buffer()
            
        if recv[0] == 'Y' and recv[1] == 'Y':     #python2
            lowD = int(recv[2].encode('hex'), 16)      
            highD = int(recv[3].encode('hex'), 16)
            lowS = int(recv[4].encode('hex'), 16)      
            highS = int(recv[5].encode('hex'), 16)
            distance = lowD + highD * 256
            strength = lowS + highS * 256
            print(distance, strength)
        
        # you can also distinguish python2 and python3: 
        #import sys
        #sys.version[0] == '2'    #True, python2
        #sys.version[0] == '3'    #True, python3

if name == ‘main’:
try:
if ser.is_open == False:
ser.open()
getTFminiData()
except KeyboardInterrupt: # Ctrl+C
if ser != None:
ser.close()

Did you try any others tools like minicom or putty to check?

I haven’t tried it on either yet. It’s my first time using the Jetson Nano, so is there any guide for me to learn how to test it out on putty (since I have a windows computer)?

I don’t have experience about this kind of device but I think maybe below link can help.

Thanks for information. I have tried debugging the device by adding my user to the group ‘dialout’. After I did this, I tried running my code in Code-OSS and I dont get any error nor do I get an output. It runs the program and nothing is shown after. Below is a screenshot of my output when I “Run python file in terminal”.

This is output when I type this command:

~$ ls -l /dev/ttyS0
crw–w---- 1 root tty 4, 64 Sep 25 02:19 /dev/ttyS0

Screenshot of my terminal output: