in default status. use echo "verify..." > /dev/ttyTHS0, serial can output this log. But when test code execute “ioctl(fd, TIOCSRS485, rs485conf);” , it always error. error code was -1.
pin UART1_RTS and UART1_CTS always no signal.
for Kernel, it was based on 4.9.253 from Jetpack4.6
I want to ask:
Did this kernel support ioctl for TIOCSRS485, what I should do to make it support this comond.
if this ioctl was not support TIOCSRS485, is there any other comond or ioctl micro can replace it.
For this module, What should I do to make uart1 switch to RS422/RS485 mode.
I had add patch, IOCTL was not meet error now, but RTS pin and CTS pin seem always 0 and 1, when send date at rs485 mode, RTS pin has no signal change at all。
I tried both previous code and this code. no signal change at all.
struct termios term;
fd = open(uartdev, O_RDWR);
memset(&term, 0, sizeof(term));
if ( -1 == tcgetattr(fd, &term))
perror("Can not get standart input discription:");
term.c_cflag |= (CLOCAL | CREAD); // ignore modem controls
term.c_cflag &= ~CSIZE;
term.c_cflag |= CS8; // 8-bit parity bit
term.c_cflag &= ~PARENB; // no parity bot
term.c_cflag &= ~CSTOPB; // only need 1 stop bit
// term.c_cflag &= ~CRTSTS; // no hardware flow control, not use at here
term.c_cflag |= CRTSCTS; // use RTS/CTS
// setup for non-canonical mode
term.c_iflag &= !(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR| IGNCR | ICRNL | IXON);
term.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
term.c_oflag &= ~OPOST;
// fetch bytes as they become available
term.c_cc[VMIN] = 1; //
term.c_cc[VTIME] = 1; // 100ms
if (-1 == tcflush(fd, TCIOFLUSH))
printf("error at tcflush. error no:%d", errno);
if (0 != tcsetattr(fd, TCSANOW, &term))
printf("error at tcsetattr. error no:%d", errno);
and I find there is no RTS pin at device tree, should I add them (something like pin control ) to device tree. is there any example for it?
value of RTS_EN and CTS_EN was both set to 1, But it always no signal change on RTS and CTS, both of then low status.
I found that GPIO 428 was RTS pin, if I set GPIO AS output, and echo 1 > /sys/clase/gpio/gpio428/value, then it found that RTS pin was pull up. at least.