UART RTS/CTS control problem


#1

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 a 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;
}

#2

Can you check if RTS/CTS can be enabled on your module

  1. check status: stty –F /dev/ttyHS0 –a

  2. Enable crtscts: Stty –F /dev/ttyHS0 crtscts

  3. check status again: stty –F /dev/ttyHS0 –a


#3

I have disabled CRTSCTS intentionally (please look at my code attr.c_cflag &= ~CRTSCTS;). I don’t want hardware control, I want software control. FX30 and mangOH green are unable to read CTS status. I can set up RTS line on mangOH green but I cannot do it on FX30. Please look at source code in my post.


#4

I will have to dig deeper into the CTS status not working on mangoh green. I am not aware of any reason for that


#5

what module are you using?


#6

I use WP8548
on mangOH green. Legato 16.10.3.wp85-wp75-native-x86_64-201705311410

Legato on FX30S - 16.10.1.fx30_wp85-pdk-x86_64-201706301655

FX30S has got:

/sys/devices/platform/msm_serial_hsl.1/rs_mode

/sys/devices/platform/msm_serial_hsl.1/rs485_term

/sys/devices/platform/msm_serial_hsl.0/rs_mode

/sys/devices/platform/msm_serial_hsl.0/rs485_term

Where can I find documentation for these?

Is it possible, I cannot control RTS/CTS on FX30S because of wrong rs_mode

setting?

(mangOH green does not have /sys/devices/platform/msm_serial_hs.0/rs_mode )


#7

i dont think UART on FX30 is 4 wire


#8

I would be extremely surprised, if FX30 does not have 4 wires UART. Please look at documentation of FX30, page 53 figure 3-6. FX30S has got RS485. FX30S does not use RTS/CTS for flow control? I do not think so.


#9

I have noticed one more thing. I can control RTS line on mangOH green as I said before. However I can control RTS line on UART1 but I can NOT control RTS line on UART2.
UART2 on mangOH green behaves like both UARTs on FX30S.

Only UART1 on mangOH green controls RTS.

CTS is dead in all cases.


#10

it all depends on the module you are using.
WPx5 : UART1 is 4 wire and UART2 is 2 wire.
so on a mangOH Green/Red: IoT card slot will show 4 wire (UART1)
on FX30, UART2 is used on IoT card , so it is 2 wire.

i am not sure why UART1 is showing as 2 wire for you on FX30.

Anyways, what is the problem you are trying to solve?


#11

I want to use RTS/CTS lines to control flow on my designed IoT card. Unfortunately I cannot do it. All technical drawings show RTS/CTS lines, so I have assumed, both UARTS are 4-wire. My assumption was wrong. After your last response, I checked architecture of WP8548, WP7502, WP7504. All 3 processors has got 2 UARTS. UART1 is 8-wire and UART2 is only 2-wire.
I cannot use RTS/CTS lines because:

  1. FX30 has got UART2 on IoT card, so only Rx,Tx are available (no RTS/CTS). FX30S has got RS232 on the back based on UART1, but lines RTS/CTS are dead/unresponsive.

  2. I have got UART1 on mangOH green on IoT0 or IoT1 slot. But I can control only RTS line. I cannot read status of CTS.

  3. mangOH Red has got UART1 on IoT slot, but I don’t know if I can control RTS/CTS lines, because I don’t have the board.

I can NOT use RTS/CTS lines on my IoT card because it will not be working. FX30 has not got MUX to redirect UART1 to IoT. So it will not be working because of design of FX30. mangOH green thinks that CTS line is always set, so my IoT will not be working.

I like legato and mangOH project a lot, but this is a little disappointing.

Lets close the post. I will try to solve it other way.

Many thanks for your help @asyal


#12

This is not a mangOH question. You might want to redirect your question regarding RTS not working on mangOH to this forum: https://forum.sierrawireless.com/c/airprime-embedded-wireless-modules/wp-series

I dont believe there is any technical reason related to mangOH that is causing issues with item 2.
And yes, for item 3, it is a 4 wire UARt on IoT slot.


#13

You said :
“I dont believe there is any technical reason related to mangOH that is causing issues with item 2.”

I put in Universal Converter to mangOH green and I have connected the unit with PC. When program on mangOH sets RTS line, CTS is ON on RealTerm program and orange RTS diode is ON on Universal Converter

When program on mnagOH green, turns off RTS, everything is OFF.

When I press “Set” button on RealTerm (section RTS ). RTS box is ON on RealTerm and red CTS diode is ON on Universal Converter.

Everything is ok so far. But When I read CTS status on mangOH green programmatically, status of CTS is always on (“CTS ON” on terminal). Please look at the source:

int Status;

if (ioctl(FD, TIOCMGET, &Status) == -1)
{
	LE_DEBUG("RTS ON: %s", strerror(errno));
}

if(Status & TIOCM_CTS)
{
	LE_INFO("CTS ON");
}
else
{
	LE_INFO("CTS OFF");
}

if (BoolRts)
{
	Status |= TIOCM_RTS;
}
else
{
	Status &= ~TIOCM_RTS;
}
if (ioctl(FD, TIOCMSET, &Status) == -1)
{
	LE_DEBUG("SetRTS OFF: %s", strerror(errno));
}

4

You DO NOT have to believe, it is the issue with mangOH green, but I can proof it that IT IS.

If you assume mangOH green is always a host, so it is fine, because mangOH green will not have to read CTS line. But if someone uses mangOH as client, it will be a problem.

If I am doing something wrong and I CAN read CTS line in other way, please let me know.


#14

Thank you for the detailed log.
I will open a ticket and we will fix this issue.