View previous topic :: View next topic |
Author |
Message |
sjones
Joined: 16 Feb 2009 Posts: 5 Location: England
|
USB to Serial and detecting RTS state |
Posted: Wed Mar 04, 2009 8:21 am |
|
|
I am using CCS example USB code to implement a USB to serial convertor (PIC18F66J50) Using windows CDC driver as a virtual com port I can detect windows DTR state but not the RTS state. A packet is not sent from the host to the device when RTS changes state, though it does when DTR does, does the windows driver support RTS flow control? |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Wed Mar 04, 2009 10:35 am |
|
|
It's not clear to me, what you're talking about. In the terminology of CDC device class specification as well in the usual PC RS232 signal definition, RTS and DTR are outputs from the PC to the peripheral device. They are supported by a CDC specific request SetControlLineState, it's reflected by a variable usb_cdc_carrier in the CCS CDC driver, but without causing any action. It can be used at the application level. In ex_usb_serial.c, the DTR signal, incorrectly named dte_present is driving a LED. The opposite direction control lines are DCD, CTS and DSR. The CDC specification provides an option to signal their state by a SERIAL_STATE notification element, but as far as I see, notification elements aren't implemented in the CCS CDC driver. Alternatively, DSR input could be used at the application level to stop sending. |
|
|
sjones
Joined: 16 Feb 2009 Posts: 5 Location: England
|
|
Posted: Wed Mar 04, 2009 10:51 am |
|
|
After enumeration I open a serial terminal on the PC to the virtual com port. If I monitor the USB packets from the PC if I toggle the DTR out in the terminal program I can see a usb control packet is generated. However if I do the same with the RTS line I get no packet sent. In the usb device I can detect the DTR state with the following code
if(usb_cdc_carrier.dte_present&&usb_cdc_carrier.active)
However as no packet is sent for a RTS change how can the device detect it and stop sending the PC data?
Thanks |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Wed Mar 04, 2009 3:27 pm |
|
|
I understood now, that you have been also talking about the SetControlLineState request. I could verify, that changes to RTS state are apparently absorbed by the Windows VCP driver, although you can see with Portmon, that they are signaled to the driver correctly. This seems to be a limitation of the VCP driver. I found however a workaround. If you set or reset RTS (regularly by EscapeCommFunction() API function) then the new RTS state is reflected with the next DTR change. Also refreshing the present DTR state causes a new request. So you can control RTS as intended. |
|
|
sjones
Joined: 16 Feb 2009 Posts: 5 Location: England
|
|
Posted: Thu Mar 05, 2009 3:35 am |
|
|
Thanks, yes that is exactly what happens, at least I now understand it. Toggling DTR updates the RTS status as well. |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Thu Mar 05, 2009 4:58 am |
|
|
Quote: | Toggling DTR updates the RTS status as well. | Yes, also sending the same DTR repeatedly, not possible e.g. with SIOW, but by generic Windows API calls. |
|
|
|