Skip to content

Commit e8a6d38

Browse files
committed
fix idVendor and idProduct error check
Previously these weren't checking to see if TinyUSB reported a failure. Now they check.
1 parent 7d26fe9 commit e8a6d38

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

shared-module/usb/core/Device.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// This file is part of the CircuitPython project: https://circuitpython.org
22
//
33
// SPDX-FileCopyrightText: Copyright (c) 2022 Scott Shawcroft for Adafruit Industries
4+
// SPDX-FileCopyrightText: Copyright (c) 2025 Sam Blenny
45
//
56
// SPDX-License-Identifier: MIT
67

@@ -70,14 +71,18 @@ void common_hal_usb_core_device_deinit(usb_core_device_obj_t *self) {
7071
uint16_t common_hal_usb_core_device_get_idVendor(usb_core_device_obj_t *self) {
7172
uint16_t vid;
7273
uint16_t pid;
73-
tuh_vid_pid_get(self->device_address, &vid, &pid);
74+
if (!tuh_vid_pid_get(self->device_address, &vid, &pid)) {
75+
mp_raise_usb_core_USBError(NULL);
76+
}
7477
return vid;
7578
}
7679

7780
uint16_t common_hal_usb_core_device_get_idProduct(usb_core_device_obj_t *self) {
7881
uint16_t vid;
7982
uint16_t pid;
80-
tuh_vid_pid_get(self->device_address, &vid, &pid);
83+
if (!tuh_vid_pid_get(self->device_address, &vid, &pid)) {
84+
mp_raise_usb_core_USBError(NULL);
85+
}
8186
return pid;
8287
}
8388

0 commit comments

Comments
 (0)