libserialport
libserialport copied to clipboard
Windows 10
See the attached image with debug log enabled. Retrieving VID & PID seems to be broken. On Windows XP SP3 it works well. BTW I'm running Windows 10 in Parallels. The device is bridged from the host machine. And the binary is generated by i686-mingw32-w64 cross compiler. Code is like:
ret = sp_list_ports(&ports);
if (ret != SP_OK)
return -1;
for (i = 0; ports[i]; i++) {
int n, vid, pid;
char sn[16];
int ubus, uadd;
ret = sp_get_port_usb_vid_pid(ports[i], &vid, &pid);
if (ret != SP_OK)
continue;
ret = sp_get_port_usb_bus_address(ports[i], &ubus, &uadd);
if (ret == SP_OK)
sprintf(sn, "%04x:%04x", ubus, uadd);
else
strcpy(sn, "<unknown>");
printf("vid=%04x&pid=%04x\n", vid, pid);
for (n = 0; n < sizeof(g_models) / sizeof(g_models[0]); n++) {
if (g_models[n].vid != vid ||
g_models[n].pid != pid)
continue;
printf("[%s][+] detected model: %s.\n", sn, g_models[n].name);
fflush(stdout);
ret = sp_open(ports[i], SP_MODE_READ_WRITE);
if (ret != SP_OK) {
printf("[%s][-] failed to open port.\n", sn);
fflush(stdout);
continue;
}
ret = sp_setup(ports[i]);
if (ret < 0) {
printf("[%s][-] failed to configurate port.\n", sn);
fflush(stdout);
goto bail;
}
sp_close(ports[i]);
}
}
sp_free_port_list(ports);
return 0;
I wonder if this was something to do with it being a composite device.
The Arduino branch of the library has some changes related to handling composite devices that might be relevant - Martino has said he'll be putting in a pull request with fixes to go upstream.
https://github.com/arduino/libserialport/commits/master
Arduino are using libserialport for enumeration now including VID/PID so I can only assume that it's working on Windows 10 for most if not all cases.
The arduino version does indeed seem to retrieve the VID/PID correctly for composite devices under Windows 10, however it no longer retrieves the USB string descriptors such as the serial number during enumeration. This is an issue if you have multiple composite USB devices of the same type, each with a serial port and you wish to find the serial port of a specific one.