Frameworks > Serial Framework

Disconnection from USB

(1/2) > >>

craigTheBrit:
Our code uses the USB connection to exchange data between a phone and a PC. At the moment we're having trouble in the scenario that goes like this:
 1. Program runs
 2. Phone connected to PC
 3. Program connects to the right port
 4. Phone disconnected from PC
 ...
 5. Program quits

When the program quits it seems to hang. Further, it seems that the wclClient isn't receiving an OnDisconnect event when the cable is taken out. Can you think of why that would be?

Mike Petrichenko:
Hi

Serial ports do not generate Disconnect event because there is no way to know is device connected or not. You should terminate connection by timeout or use TwclSerialDiscovery monitoring feature (added in 6.6.2.0) to detect moment when used port disappears.

craigTheBrit:
I'm having a little trouble detecting those DeviceLost events. It seems that they aren't triggered when a device is unplugged if it is connected via the serial client component. Can you confirm?

So the program contains both a wclSerialDiscovery and a wclClient. When the wclClient is connected (via USB), the wclSerialDiscovery is blinded to connections and disconnections, it seems. The result is that I never get to disconnect properly, and when my program quits it just hangs...

Really appreciate the speed of your replies Mike, I'm very impressed!

Mike Petrichenko:
Hi,

I will take a look on it and try to fix.

Mike Petrichenko:
Hi,

Tested and fixed (and now OnDisconnect fires for serial ports as well).

If you have the sources I can give you a changes, otherwise you have to wait when I publish next release.

Navigation

[0] Message Index

[#] Next page

Sitemap 1 2 3 4 5 6 7 
Go to full version