Wireless Communication Library Support Forum
Frameworks => Serial Framework => Topic started by: gomsun2 on April 05, 2012, 10:43:43 AM
-
hi. i'm testing wcl component.
6.10.2.0 / vcl / windows 7 64bit. / trial version / device chipset - silabs CP210x
The scenario that goes like this:
1. Run VCL\demo\Delphi\SerialConnection\SerialClientDemoXE2.exe
2. Enum Click
3. Seldect Device
4. Connect Click -> Connect success
5. Unplugging usb device
6. BluetoothClientDemoXE2.exe application is lock & no response
i try like this. But dose't work. what should I do?
procedure TfmMain.FormCreate(Sender: TObject);
begin
wclAPI.Load;
wclSerialDiscovery.StartMonitoring;
end;
procedure TfmMain.wclSerialDiscoveryDeviceLost(Sender: TObject;
Device: TwclSerialDevice);
begin
if Device.Port = MY_PORT then
wclClient.Disconnect;
end;
-
Hi,
WCL uses timeout to detects when serial device disconnects. So you do not need to monitor serial ports to detect disconnection. However, with some USB->COM adatpters we faced such issue and are working on this matter. Hopefully we will have solution soon. The problem is that some USB->COM (or its drivers) don't notify high level apps about device disconnection (when it is used).
Any way, try to not use monitoring and wait for OnDisconnect event from wclClient.
-
thank you for reply.
i setting "wclClinet.TimeOut := 100;" but OnDisconnect event does not execute
Is there another way to solve the problem?
-
We will check it out and back to you with solution.
-
Thank you.
Looking forward to your solution. :)
-
Hi,
The issues has been fixed (fixed version is attached).
The problem was in lib code. When ReadFile returns error (device has been unplugged/port removed) the reading thread sends disconnect notification but doesn't set terminatrion flag. As soon as thread termintaion event processes only when ReadFile success (in WaitFor function together with waiting for overlapped result event) the issue causes permanent thread looping. When WCL receives disconnection event it sets thread termination event and waits for thread. As soon as thread is in permanent loop (by reason described above) it locks whole the app on dead-lock.
Now it is fixed.
[attachment deleted by admin]
-
I've confirmed that the issue has been fixed.
Thank you for quick response. : )