When the UART is set to /dev/ttyTHS0, packets cannot be received and many verification errors occur

This problem has troubled me for a long time, I hope you can help me look at this problem, thank you.This is my code:
int Init_Serial(const char *portname) {
int fd = open(portname, O_RDWR | O_NOCTTY | O_NONBLOCK);
if (fd < 0) {
printf(“Error opening %s: %s\n”, portname, strerror(errno));
return -1;
}

struct termios tty;
memset(&tty, 0, sizeof tty);

if (tcgetattr(fd, &tty) != 0) {
    printf("Error from tcgetattr: %s\n", strerror(errno));
    close(fd);
    return -1;
}

cfsetospeed(&tty, B460800);
cfsetispeed(&tty, B460800);

tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8;  
tty.c_iflag &= ~(IXON | IXOFF | IXANY);     
tty.c_lflag = 0;                            
tty.c_oflag = 0;                            
tty.c_cflag |= (CLOCAL | CREAD);           
tty.c_cflag &= ~(PARENB | PARODD);      
tty.c_cflag &= ~CSTOPB;                    
tty.c_cflag &= ~CRTSCTS;                    

tty.c_cc[VMIN] = 0;
tty.c_cc[VTIME] = 0;

if (tcsetattr(fd, TCSANOW, &tty) != 0) {
    printf("Error from tcsetattr: %s\n", strerror(errno));
    close(fd);
    return -1;
}

return fd;

}

The length of the sensor data I received was 71, but when I actually ran it, I could not receive the data and the length of the received data was very abnormal. The length printed out was 200 and 96.

This is the part of my receiving code, when receiving, there will always be about 10% of the data fails to pass the check.
void* Ium_Recive_Task(void* arg)
{
fd_set read_fds;

struct timeval timeout;
int ret;

int uart_fd;


uart_fd = Init_Serial("/dev/ttyTHS0");

if (uart_fd < 0) {
    return NULL;

}

Recive_Buffer_Init();

while (1) {
FD_ZERO(&read_fds);
FD_SET(uart_fd, &read_fds);

  timeout.tv_sec = 0; 
  timeout.tv_usec = 5000;	

  ret = select(uart_fd + 1, &read_fds, NULL, NULL, &timeout);

  if (ret == -1) {
      printf("Select error: %s\n", strerror(errno));
      break;
  } else if (ret == 0) {
      //printf("Timeout, no data received.\n");
      continue;
  }

  if (FD_ISSET(uart_fd, &read_fds)) {          
      int read_len = read(uart_fd, (uint8_t *)Get_FIFO_Enqueue_Position(&imu_buffer_fifo), IMU_BUFERR_LEN);

      if (read_len == XSENSE_IMU_DATA_LEN || read_len == YESENSE_IMU_DATA_LEN) 
      {  
          FIFO_Perform_Enqueue(&imu_buffer_fifo);
      }
  }

}

return NULL;
}

The problem of receiving the wrong length described before is that the baud rate is not set correctly, and the correct number of bytes can be received normally after the baud rate is corrected, mainly to solve the problem that the data cannot be verified

There is no update from you for a period, assuming this is not an issue anymore.
Hence, we are closing this topic. If need further support, please open a new one.
Thanks

Hi 19179921356,

Are you using the devkit or custom board for Orin NX?
What’s your Jetpack version in use?

Have you verified Uart loopback test before connecting with your sensor?

Do you enable HW flow control in your case?

Do you mean the issue get resolved after configuring the correct baud rate?