|
-
February 26th, 2014, 12:01 PM
#1
Createfile can hang opening a serial port. Looking for alternative
this really has nothing to do with a C++ problem, but I see it as a bug in the API, and I'm looking for an alliterative. I need to deal with serial ports a LOT, and of course the first step in working with a serial port is to open it, with Createfile(). Well I have a laptop her, an old DELL Latitude running Win-XP SR3, which at one time apparently was used with a PCI card driver that mimicked a few serial ports, which has since been uninstalled. However, if my application attempts a CreateFile(), such as...
Code:
HANDLE hTmp = CreateFile("\\\\.\\COM2", GENERIC_READ | GENERIC WRITE, 0,0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE ATTRIBUTE_OVERLAPPED, 0);
I would normally expect the returned handle to be either a valid handle, or == INVALID_HANDLE#_VALUE. But on this machine, opening some ports just cau7ses a HANG, and then there is no shutting the application down, without resorting to the power button!
Now its not just my app... even HYPERTERM will hang on this machine if I try to open certain serial ports. So what I'm looking for is an alternate way to TEST the ports that are actually available, perhaps by reading the device list (in the hardware manager)?
I'm reasonably sure the problem is some trace of the uninstalled PCI card device driver that is opening the serial port, because opening already open files can cause a hang too. But like I said, I'm looking for an alternate method. The device manager in this laptop correctly reports all teh good serial ports, so Windows must have some way of "knowing" without freezing itself during startup.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|