0

My question is quite simple: I operate 20 CP210x (Silicon Lab) devices over an industrial 20 Port USB Hub.

In one of about 1000 trials to open the port I get a problem: The call to

CreateFile(portName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);

is blocking and doesn't return. In this case it doesn't help to repeat or to restart my software. Only plugging out/in the device helps. Of course the port name is including backslashes, as required for higher COM Port numbers. The port is closed without getting an error after each communication by

CloseHandle(comport_p);

I could give more details on my source, but think, that the relevant parts are the mentioned lines. Is there something else I have to consider in my software or could there be a driver problem?

MichaelW
  • 1,328
  • 1
  • 15
  • 32
  • 2
    It could be a driver issue, or an operating system issue, or a USB hub controller hardware/firmware issue, or a cable quality issue, or an electrical interference issue, or (of course) a USB device firmware/hardware issue. Debugging these things is not easy, and very hard to do remotely. At the very least get in there with a USB protocol analyzer, and make sure you use USB certified cables. – unwind Apr 06 '18 at 09:20
  • 1
    to me, given the extremely poor amount of documentation, That there is a 'race' condition, perhaps where the peripheral is not yet finished closing a port before the next open of the same port arrives. Suggest using `sync; sync;` after the 'close' as a method to have the peripheral cleaned up and available before the next 'open' occurs – user3629249 Apr 06 '18 at 13:50

0 Answers0