“TX2NX uses uartc: serial@c280000, which is /dev/ttyTHS2 to receive data. It can only receive data that is aligned to 8 bytes, for example, 8, 16, 24. When sending 22 bytes, the serial port only receives 16 bytes of data, and the other 6 bytes of data are not received. I tested the same program on XAVIER with /dev/ttyTHS0, which worked normally. When sending 22 bytes, 22 bytes were received, proving that my test program was not the problem. This is different from the behavior of TX2NX.”
Hi TrevinN,
Are you using the devkit or custom board for TX2-NX?
What’s your Jetpack version in use?
Could you help to provide the serial console log for further check?
Do you have the detailed steps to send 22 bytes data?
HI kevin,
we using custom board ,and jetpack ver is 4.6.3 “In my case, the console port is UARTA, and it works fine. We use UARTC to communicate with an external device. During testing, when the external device accurately sends 22 bytes of data, we can only receive 16 bytes of data. When we send 24 bytes of data (i.e., aligned to 8 bytes), we can receive all the data. We confirmed that there are no problems with the serial cable or the program sending the data. How can I rule out problems on the receiving end of TX2NX? Are there any methods? Thank you.”
hi this is sample code:
send:
int main(int argc, char *argv) {
if (argc != 2) {
fprintf(stderr, “Usage: %s \n”, argv[0]);
return -1;
}
int fd = open("/dev/ttyTHS0", O_RDWR | O_NOCTTY | O_NDELAY);
if (fd == -1) {
fprintf(stderr, "Failed to open serial port\n");
return -1;
}
struct termios options;
tcgetattr(fd, &options);
options.c_cflag = B115200 | CS8 | CLOCAL | CREAD;
options.c_iflag = IGNPAR;
options.c_oflag = 0;
options.c_lflag = 0;
tcflush(fd, TCIFLUSH);
tcsetattr(fd, TCSANOW, &options);
const char *data = argv[1];
int len = strlen(data);
int n = write(fd, data, len);
if (n != len) {
fprintf(stderr, "Failed to write to serial port\n");
return -1;
}
close(fd);
return 0;
}
recv:
int main() {
int fd;
struct termios options;
fd = open(“/dev/ttyTHS2”, O_RDWR | O_NOCTTY | O_NDELAY);
if (fd == -1) {
perror(“open”);
return -1;
}
// 配置串口
tcgetattr(fd, &options);
cfsetispeed(&options, B115200 );
cfsetospeed(&options, B115200 );
options.c_cflag |= (CLOCAL | CREAD);
options.c_cflag &= ~CSIZE;
options.c_cflag |= CS8;
options.c_cflag &= ~PARENB;
options.c_cflag &= ~CSTOPB;
options.c_oflag = 0;
options.c_lflag = 0;
tcsetattr(fd, TCSANOW, &options);
printf(“main\n”);
char buf[255];
while (1) {
ssize_t len = read(fd, buf, sizeof(buf));
if (len == -1) {
perror(“read”);
continue;
}
if (len > 0) {
printf(“Received %ld bytes: %.*s\n”, len, (int)len, buf);
}
}
close(fd);
return 0;
}
I’m closing this topic due to there is no update from you for a period, assuming this issue was resolved.
If still need the support, please open a new topic. Thanks
Do you mean that only UARTC has this issue and UARTA works even if receiving 22 bytes data?
Have you tried to reproduce the same behavior on the devkit?