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

How to detect if USB communication is up and ready?

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



Joined: 09 Mar 2010
Posts: 314
Location: Denmark

View user's profile Send private message

How to detect if USB communication is up and ready?
PostPosted: Mon May 03, 2010 2:23 pm     Reply with quote

Hello

The USB is connected as CDC and it work! But...

How to detect if the communication is up?

Look like usb_cdc_connected() is only set to false in the usb_init_cs(). This mean if it is return true just once, it will all time return true?

Any hints for detecting if connection is up or down. I know I can send keep alive package, but is there other ways.
Ttelmah



Joined: 11 Mar 2010
Posts: 19506

View user's profile Send private message

PostPosted: Tue May 04, 2010 2:31 am     Reply with quote

Do you have a connection sense pin?.
If so, then the first thing is to call 'usb_task', and 'usb_enumerated', will then tell you if there is a driver sitting 'connected' to the USB at the PC end. This will go false if the driver disconnects. It _won't_ tell you if there is an application attached to that driver.
For detecting the application, it is 'down to you'. An example would be my logging application. This sends a request for data every second. The PIC code has a timer running, and if it does not see such a request within 1.5 seconds, it turns on a hardware alarm, and resets the USB.

Best Wishes
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