I have got UART on IoT card. Data transmission (Rx/Tx) works perfectly. However I have got problem with controlling RTS/CTS lines.
MangOH green:
Line RTS looks fine. When I change RTS on MangOH, CTS changes on connected device. BUT.
When I change RTS on connected device, CTS on MangOH does not react (It is always set).
FX30S:
Unable to control RTS/CTS.
Why FX30 and MangOH behave differently? Why CTS flag is always set?
Serial Port Setup:
//if ((FD = open(“/dev/ttyHS0”, O_RDWR)) == -1) return 0; //MangOH green
if ((FD = open(“/dev/ttyHSL1”, O_RDWR)) == -1) return 0; //FX30
struct termios attr;
//tcgetattr(FD, &oldterminfo)
memset(&attr,0, sizeof(attr));
cfsetispeed(&attr,B38400);
cfsetospeed(&attr,B38400);
attr.c_cflag &= ~PARENB;
attr.c_cflag |= CLOCAL;
attr.c_cflag |= CREAD;
attr.c_cflag &= ~CSTOPB;
attr.c_cflag &= ~CSIZE;
attr.c_cflag |= CS8;
attr.c_cflag &= ~CRTSCTS;
attr.c_iflag &= ~(IXON | IXOFF | IXANY);
attr.c_iflag &= ~(ICANON | ECHO | ECHOE | ISIG);
attr.c_cc[VMIN] = 0;
attr.c_cc[VTIME] = 0;
if (tcsetattr(FD, TCSANOW, &attr) == -1)
{
return 0;
}
RTS/CTS:
int status;
if (ioctl(FD, TIOCMGET, &status) == -1)
{
LE_DEBUG("ERROR: %s", strerror(errno));
}
if(status & TIOCM_CTS)
{
LE_INFO("CTS ON");
}
else
{
LE_INFO("CTS OFF");
}
if (level)
{
status |= TIOCM_RTS;
}
else
{
status &= ~TIOCM_RTS;
}
if (ioctl(FD, TIOCMSET, &status) == -1)
{
LE_DEBUG("ERROR: %s", strerror(errno));
return 0;
}