CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

USB to Serial and detecting RTS state

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
sjones



Joined: 16 Feb 2009
Posts: 5
Location: England

View user's profile Send private message

USB to Serial and detecting RTS state
PostPosted: Wed Mar 04, 2009 8:21 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Mar 04, 2009 10:35 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Mar 04, 2009 10:51 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Mar 04, 2009 3:27 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Mar 05, 2009 3:35 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Mar 05, 2009 4:58 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group