Closed accaldwell closed 4 years ago
Hi,
Yes, 1.1.3 reads the registry key HKLM\HARDWARE\DEVICEMAP\SERIALCOMM
to get serial devices. Do you know if it always lists the same limited amount of devices or does it change? If it’s the same, do you know which device(s) are missing?
My machine also has an onboard 232 port and I also have an FTDI based USB to serial (2 actually - 232 and 485) and they both show up. The only port I’m missing is the intel AMT based one.
Here's a bunch of tests. All of the ports are detected in at least one case, but in no cases are all ports detected when they are all enabled.
Test 1 Restarted. All ports enabled in Device Manager. In registry:
\Device\Serial0 COM3 (Intel AMT port) \Device\Serial1 COM1 (Intel chipset RS232) \Device\VCP0 COM4 (FTDI USB-to-RS232)
Code only detects COM1 no matter how many times its run. COM3 and COM4 are not detected.
Test 2 Disable Intel AMT (COM3) via device manager. In registry:
\Device\Serial1 COM1 (Intel chipset RS232) \Device\VCP0 COM4 (FTDI USB-to-RS232)
Code detects COM1 & COM4 no matter how many times its run. This is correct.
Test 3 Re-enable Intel AMT (COM3) via device manager. In registry:
\Device\Serial1 COM1 (Intel chipset RS232) \Device\Serial2 COM3 (Intel AMT port) \Device\VCP0 COM4 (FTDI USB-to-RS232)
Code detects COM1 & COM4 no matter how many times its run. COM3 is not detected.
Test 4 Disable COM1 via device manager. In registry:
\Device\Serial2 COM3 (Intel AMT port) \Device\VCP0 COM4 (FTDI USB-to-RS232)
Code detects COM4 no matter how many times its run. COM3 is not detected.
Test 5 Re-enable COM3 via device manager. In registry:
\Device\Serial4 COM1 (Intel chipset RS232) \Device\Serial2 COM3 (Intel AMT port) \Device\VCP0 COM4 (FTDI USB-to-RS232)
Code detects COM4 no matter how many times its run. COM1 and COM3 are not detected.
Test 6 Disable COM1 and COM4 in device manager. In registry:
\Device\Serial2 COM3 (Intel AMT port)
Code detects COM3 no matter how many times its run. This is correct.
I have a fix for this coming.
Can someone review the modified windows_registry.nim code linked here? It changes enumKeyValues to move the initialization of regNameSize and regName inside the for loop.
I cant say I thoroughly understand the underlying code and why this fixes it, but it works for me.
I can probably figure out how to make a pull request if its agreed this is the correct change and wont break anything else.
https://gist.github.com/accaldwell/9d0b4dfb6407468740cfcf866f3e9dd2
Thanks for troubleshooting this, I'll review and merge the PR this morning.
The library doesn't seem to be able to reliably detect all the serial ports on my Windows 10 (build 18363.657) machine.
I have three ports: an integrated serial port (via Intel chipset), a FTDI USB-serial adapter, and an Intel AMT COM port. They all show up correctly in the registry, which I understand is how they are currently being detected.
If I fuss around with enabling and disabling the ports via Device Manager, I can get one or two of them to be detected from my nim code:
But, I've never seemed to get it to detect all three at the same time when they are all enabled, so something isn't working.
I'm using nim 1.0.6 and serial 1.1.3. Let me know if there is something I can test to help debug this, or if there is an alternate method of detecting ports on Windows (I've never had issues with the above code in Linux on the same system).