Skip to content

Commit d24994c

Browse files
committed
[WIN] handle composite ports in a saner way
1 parent f6e3136 commit d24994c

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

libserialport_internal.h

+1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ struct sp_port {
116116
BYTE pending_byte;
117117
BOOL writing;
118118
BOOL wait_running;
119+
BOOL composite;
119120
#else
120121
int fd;
121122
#endif

windows.c

+11-3
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,13 @@ static void enumerate_host_controller(struct sp_port *port,
281281
{
282282
char *root_hub_name;
283283

284+
if (port->composite) {
285+
//remove last part of the path
286+
char * pch;
287+
pch=strrchr(port->usb_path,'.');
288+
port->usb_path[pch-port->usb_path] = '\0';
289+
}
290+
284291
if ((root_hub_name = get_root_hub_name(host_controller_device))) {
285292
enumerate_hub(port, root_hub_name, "", dev_inst, fetchDescriptors);
286293
free(root_hub_name);
@@ -369,6 +376,7 @@ SP_PRIV enum sp_return get_port_details(struct sp_port *port, bool fetchDescript
369376
char value[8], class[16];
370377
DWORD size, type;
371378
CONFIGRET cr;
379+
port->composite = FALSE;
372380

373381
/* Check if this is the device we are looking for. */
374382
device_key = SetupDiOpenDevRegKey(device_info, &device_info_data,
@@ -430,12 +438,12 @@ SP_PRIV enum sp_return get_port_details(struct sp_port *port, bool fetchDescript
430438
&compat_ids,
431439
&size, 0) == CR_SUCCESS) {
432440
while (*p) {
433-
if (!strncmp(p, "USB\\COMPOSITE", 13))
441+
if (!strncmp(p, "USB\\COMPOSITE", 13)) {
442+
port->composite = TRUE;
434443
break;
444+
}
435445
p += strlen(p) + 1;
436446
}
437-
if (*p)
438-
continue;
439447
}
440448

441449
/* Stop the recursion when reaching the USB root. */

0 commit comments

Comments
 (0)