'Please teach me how to resolve the delay of UART communication
Please teach me how to resolve the delay of UART communication.
【Implementation environment】
Flight control unit:Pixhawk 4
Companion computer:Jetson Nano 4GB
Communication method:UART
Communication direction:Jetson ⇒ Pixhawk4
Transmission data: Altitude acquired by LiDAR
Pixhawk4:Write the code generated from the Simulink model and receive the data using the 「Serial Receive block」.
Jetson:Data is sent by importing the Serial module of Python.
Although the value can be gotten by communication, the delay in communication speed is large, and there is a delay of about 1.5 seconds.
We believe that there is no problem with the hardware and hardware connection because we are able to communicate.
【Settings】
Pixhawk4 settings shown below.
Serial Receive block of UAV Tollbox.
Port:/dev/ttyS2
Data type:uint16
Data length(N):1
Sample time:0.004
Hardware settings for configuration parameters.
Baud rate:921600
Parity:NONE
Stop bit:1
Jetson settings shown below.
import sys
import serial
import struct
import numpy
import get_sensor
ser = serial.Serial(
port = '/dev/ttyTHS1',
baudrate = 921600,
bytesize = serial.EIGHTBITS,
parity = serial.PARITY_NONE,
stopbits = serial.STOPBITS_ONE,
timeout = None,
)
while(True):
altitude = get_sensor.get_lidar():
na_int = numpy.array([altitude], numpy.uint16)
ser.write(na_int)
There is little knowledge about communication and the cause cannot be identified.
【Question】
・Are there any missing parts in the settings described above?
・One of the causes may be that interrupt processing occurs frequently due to buffer overflow.
Is there a way to check if a buffer overflow has occurred? Also, is there a way to solve it when it is assumed that a buffer overflow has occurred?
(Reduce the number of times the value is sent, increase the area of the receive / send buffer, discard the buffer to prevent it from overflowing, etc.)
・When I was looking for a solution on Stackoverflow, there was a person who set termios.
Is the termios setting effective for solving this problem? (Can't set termios on Pixhawk side?)
・Are there any other possible causes?
Thank you.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
