Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows 10 #12

Open
tewilove opened this issue Oct 10, 2015 · 3 comments
Open

Windows 10 #12

tewilove opened this issue Oct 10, 2015 · 3 comments

Comments

@tewilove
Copy link

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;
@tewilove
Copy link
Author

parallels

@martinling
Copy link
Owner

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.

@parnham
Copy link

parnham commented Oct 31, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants