Hi Guys. I connect jetson nano with arduino, that received data from HC-SR04 and transport to jetson by UART. There is a big delay (about 4 sec) during transportation data from arduino to jetson. Maybe it has something to do with buffer filling, or something else.
My Python code:
#!/usr/bin/python3
import time
import serial
serial_port = serial.Serial(
port="/dev/ttyTHS1",
baudrate=9600,
bytesize=serial.EIGHTBITS,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
)
time.sleep(1)
sp = str()
try:
while True:
if serial_port.inWaiting() > 0:
data = serial_port.read().decode("utf-8")
if data != '\n':
sp += data
else:
print(sp)
sp = str()
except KeyboardInterrupt:
print(' Stop')
except Exception as exception_error:
print("Error occurred. Exiting Program")
print("Error: " + str(exception_error))
finally:
serial_port.close()
pass
I will be grateful if you point out the problem. Thanks.