Hi, working on getting RTS/CTS run on r8a7795 I had some annoying issues. Measuring with a scope showed that RTS would become low on opening the tty device (regardless of having CRTSCTS set or not). So far this is expected. But if I used tcsetattr() to set/unset the CRTSCTS flag the RTS pin would become hi and stayed so. I then looked into the sh-sci driver and added some debug output. My analysis was that upon opening the tty device the functions set_termios and set_mctrl are called. In the sh-sci driver the set_mctrl function is the only place where the internal 'autorts' flag is actually written to a register. As obviously the RTSCTS flow control flag can only be set after the device is opened, the flag isn't propagated to the corresponding register. To make it more confusing the flag is kept in .c_cflag even after closing the device and is then taken care of the next time the device is opened again. To fix this I set the bit in set_termios after the line where it was previously only stored in the bool variable 'autorts' (see attachment). Regards, Christoph
Attachment:
sh-sci_fix_RTSCTS_init.patch
Description: sh-sci_fix_RTSCTS_init.patch