Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

How to check that the ANT USB dongle was unplugged ?

Rank

Total Posts: 2

Joined 2014-05-16

PM

Currently i am developing one window application in .Net C#.
In order to manage ANT+ recovery scenario, how can I know that there is a problem with the USB stick ?
For example, how can I know that the ANT USB device has been unplugged from the windows system ?
In that situation, my program does not get any device or channel event...
Thanks for your help !      
Avatar
RankRankRankRank

Total Posts: 744

Joined 2012-09-14

PM

From the "ANT_Device" class, you can register a delegate for the "ANT_Device.dSerialErrorHandler". Any event which reaches this handler will indicate a connection error, where you can assume you've lost the USB connection, including that it was probably unplugged somehow.      
Rank

Total Posts: 2

Joined 2014-05-16

PM

Thanks for your reply.
Yes, I tried to use ANT_Device.dSerialErrorHandler but I do not receive any "error event" when the dongle is disconnected...
I am not sure that it is the best method... But I had to implement an infinite loop sending "dummy broadcast messages"... And then I get a "error event" when the dongle is disconnected... So I can enter in the recovery procedure waiting for the dongle to be reconnected...
Any better idea ?      
Avatar
RankRankRankRank

Total Posts: 744

Joined 2012-09-14

PM

You'll need some method of polling the device as the driver does not send an event to library automatically. A more useful message would be to request channel status on a timer, instead of a dummy broadcast message.

ANT_Common.enableDebugLogs() can also show the serial log of when the disconnection occurred.