Problem using RTS/CTS with USB serial

Discussion and questions about programming with Ultibo.
sbk58
Posts: 25
Joined: Fri Jul 21, 2017 7:48 pm
Location: Canada

Re: Problem using RTS/CTS with USB serial

Postby sbk58 » Thu Apr 11, 2019 12:12 am

If we post an updated version of the PL2303 driver containing these changes are you able to undertake some testing or do you need it to be the FTDI driver instead?

I can test the PL2303 driver changes when you are ready. I did not study the PL2303 driver but should not be an issue.
User avatar
Ultibo
Site Admin
Posts: 2206
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: Problem using RTS/CTS with USB serial

Postby Ultibo » Wed Apr 17, 2019 10:38 am

sbk58 wrote:
If we post an updated version of the PL2303 driver containing these changes are you able to undertake some testing or do you need it to be the FTDI driver instead?

I can test the PL2303 driver changes when you are ready. I did not study the PL2303 driver but should not be an issue.

Okay, we've finished our tests to make sure nothing is obviously broken with this change so we've pushed an update to GitHub with the modified PL2303 driver.

If you download the latest RTL from GitHub and apply it as per the Wiki instructions you should be able to rerun your tests with RTS/CTS enabled and (hopefully) the driver should now stop and start the reception of data from the USB as the Ultibo buffer fills and empties.

Let us know your results.
Ultibo.org | Make something amazing
https://ultibo.org
sbk58
Posts: 25
Joined: Fri Jul 21, 2017 7:48 pm
Location: Canada

Re: Problem using RTS/CTS with USB serial

Postby sbk58 » Sat Apr 20, 2019 5:40 pm

Thanks for the driver update...

Sorry it took so long for me to reply. I have seen mixed results with the new driver. When a Ultibo based Pi is connected to a Linux system seams to work, no data bytes lost. When I connect two Ultibo based Pis using PL2303 serial devices it is hit and miss. Some times the RTS/CTS works perfectly and at other times it drops bytes. At this point I am at a loss to explain why this is happening.

For all of my tests I am using two PL2303 USB to 9 pin serial addapters connect using a 9 pin cross over cable. I run the tests at 460800 baud which should cause a data overrun when RTS/CTS handshaking is not used. I need to get the scope connected and do some deaper testing. I will perform futher testing over the weekend and post my results as soon as I learn more.
User avatar
Ultibo
Site Admin
Posts: 2206
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: Problem using RTS/CTS with USB serial

Postby Ultibo » Sun Apr 21, 2019 10:18 am

Excellent, it will be great if you can narrow it down any further.

Since the results are positive overall we'll move on with applying the current changes to the FTDI driver as well in the meantime.
Ultibo.org | Make something amazing
https://ultibo.org
sbk58
Posts: 25
Joined: Fri Jul 21, 2017 7:48 pm
Location: Canada

Re: Problem using RTS/CTS with USB serial

Postby sbk58 » Thu Apr 25, 2019 12:00 pm

Ultibo wrote:Excellent, it will be great if you can narrow it down any further.

Since the results are positive overall we'll move on with applying the current changes to the FTDI driver as well in the meantime.


Had a chance to do more tests. It turns out that the Linux driver for the PL2303 does not signal the RTS line correctly. I tested the PL2303 Linux driver on both the newest Raspberian os and an i7 based Ubuntu 16.04 system. Didn't notice this before because the Linux system was able to handle hundreds of kbytes of data at 460800 baud without dropping a byte. I had assumed the Linux driver correctly signaled the RTS line so I did not check the signal on a scope. So all my prior tests that assumed the Linux drivers worked correctly and it was the Ultibo system that failed are invalid.

Since the PL2303 devices do not work under Windows I decided to test the RTS/CTS signaling using only pi 2B and 3B devices running Ultibo. In that scenario the RTS/CTS signaling is operating correctly between any two Ultibo systems.

I did notice one issue where the RTS line goes inactive for a long pause before becoming active again. On average the RTS line is active for about 30 to 40 mill-seconds then it goes inactive for about 120 to 140 milli-seconds. I will need to see if this is caused by my code or is caused by the PL2303 driver changes.

Will be great to have the patches applied to Ultibo FTDI driver. At least I know the FTDI devices work correctly on Windows and Linux so I can fully test the changes to the Ultibo driver against a known working systems.
User avatar
Ultibo
Site Admin
Posts: 2206
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: Problem using RTS/CTS with USB serial

Postby Ultibo » Fri Apr 26, 2019 12:10 am

sbk58 wrote:Will be great to have the patches applied to Ultibo FTDI driver. At least I know the FTDI devices work correctly on Windows and Linux so I can fully test the changes to the Ultibo driver against a known working systems.

We've dug out our FTDI device and will go ahead with porting the changes, it shouldn't take long as the logic will be almost identical to the PL2303.

I'm not sure of the details of your test program but one thing worth bearing in mind, if you haven't already noticed the default RX and TX buffer size in the Ultibo serial API is 2K which is pretty small. While it's a good way to test out the driver for real usage I'd suggest increasing the buffer sizes (when calling SerialDeviceOpen) to something a bit higher, for a baud rate of 460800 then buffers of 512K would be a good starting point.

We'll post an update as soon as the FTDI driver is ready to test.
Ultibo.org | Make something amazing
https://ultibo.org
User avatar
Ultibo
Site Admin
Posts: 2206
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: Problem using RTS/CTS with USB serial

Postby Ultibo » Mon May 06, 2019 11:32 pm

We've now updated the FTDI driver with the same receive buffer changes as the PL2303, we've also applied your flow control fix from earlier in this thread and added the latest supported VID/PID values for good measure.

If you can run your tests again with the FTDI device and let us know the results that will be great.
Ultibo.org | Make something amazing
https://ultibo.org
sbk58
Posts: 25
Joined: Fri Jul 21, 2017 7:48 pm
Location: Canada

Re: Problem using RTS/CTS with USB serial

Postby sbk58 » Thu May 09, 2019 4:42 pm

Ultibo wrote:We've now updated the FTDI driver with the same receive buffer changes as the PL2303, we've also applied your flow control fix from earlier in this thread and added the latest supported VID/PID values for good measure.

If you can run your tests again with the FTDI device and let us know the results that will be great.


Tested new FTDI driver on PiB, Pi2B, P3B, PiZW, seams to be working fine on all the devices. The RTS/CTS signaling looks exactly the way you would expect on the scope and best of all no dropped data bytes.

Thanks for the great support.
User avatar
Ultibo
Site Admin
Posts: 2206
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: Problem using RTS/CTS with USB serial

Postby Ultibo » Fri May 10, 2019 12:17 am

sbk58 wrote:Tested new FTDI driver on PiB, Pi2B, P3B, PiZW, seams to be working fine on all the devices. The RTS/CTS signaling looks exactly the way you would expect on the scope and best of all no dropped data bytes.

That's a really good result, thanks for your help in testing this and for figuring out the change to make the driver obey CTS from the other end.

So at this stage we have the FTDI driver working well with RTS/CTS signalling and the PL2303 driver working but with a possible intermittent delay, we'll also go ahead and update the USBCDCACM driver with the same change to make the complete set.
Ultibo.org | Make something amazing
https://ultibo.org
sbk58
Posts: 25
Joined: Fri Jul 21, 2017 7:48 pm
Location: Canada

Re: Problem using RTS/CTS with USB serial

Postby sbk58 » Wed May 15, 2019 11:54 am

So at this stage we have the FTDI driver working well with RTS/CTS signalling and the PL2303 driver working but with a possible intermittent delay

I have tested the PL2303 again and it does seam to work properly. I believe that the delay was caused by my software not the PL2303 driver. I have been using two pi systems connected via PL2303 devices operating at 460800 baud for over a week and the link is very stable. Given that the PL2303 has no support in Windows and the Linux driver does not correctly signal the RTS line I would not spend any more time on it. Anyone who used the PL2303 device is probably going to use one of the low cost USB to serial devices and they do not expose the RTS or CTS signals. If anyone does use a PL2303 device and enables hardware flow control the Ultibo driver will work.

From my perspective the plus from all of this is that the Ultibo project now has a working model for USB serial devices that supports hardware flow control. This should allow future drivers to be developed for the ever changing list of current devices being used by various hardware maker platforms.


Again thanks for all the help....

Return to “General”

Who is online

Users browsing this forum: asjsmile and 0 guests