hmmpic
Joined: 09 Mar 2010 Posts: 314 Location: Denmark
|
How to detect if USB communication is up and ready? |
Posted: Mon May 03, 2010 2:23 pm |
|
|
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
|
|
Posted: Tue May 04, 2010 2:31 am |
|
|
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 |
|