> Ruben J=F6nsson ha scritto: > > For example: The PC software is talking to a virtual serial port that is > > connected to a USB device. When the PC software has opened the port it = never > > expects the port to go away, which is reasonable considering that a sta= ndard > > serial port can't be unplugged. However, when the USB device is unplugg= ed > > (perhaps by accident) really weird things can happen with the PC softwa= re. I > > have not been able to reliably catch any exceptions caused by this and = most of > > the time the PC software just hangs. Sometimes I even have had to resta= rt the > > computer (XP) before I can get the communication up and running again. > = > = > In theory, a WM_DEVICECHANGE message (in Windows) should alert you of = > what is going on. I say in theory since I'm more or less aware of the = > subtle details in that :) I think I have tried that too but when the WM_DEVICECHANGE is raised it is = already too late. And when you have to deal with these things anyway I thin= k it = is best to skip the virtual serial port and speak straight to the USB devic= e = instead. > = > I used mostly HID Generic devices: in them, the Handles usually become = > no longer valid, both Reads and Writes usually Fails, and so do = > semaphores and Waits... so you can more or less recover. > = Yes, that is my point. Talk to the device via the USB classes since they ca= n = handle a disconnected device. Avoid the virtual serial port since the drive= rs = for these can't (at least not what I have seen so far). Merry Christmas /Ruben =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D Ruben J=F6nsson AB Liros Electronic Box 9124, 200 39 Malm=F6, Sweden TEL INT +46 40142078 FAX INT +46 40947388 ruben@pp.sbbs.se =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D -- = http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist