Skip to content

Commit ebb4e7e

Browse files
dccoteclaude
andcommitted
Drop the USBPort claim workaround in PwrUSBDevice init
Problem: doInitializeDevice reached past the CommunicationPort abstraction to call usb.util.claim_interface on the USBPort's pyusb device, purely to make a macOS-claimed HID interface fail fast. With transport defaulting to "auto" (HID when hidapi is present), the USBPort path is only taken when explicitly requested on Linux, where the claim succeeds anyway, so the workaround is dead weight that also broke the port abstraction. Solution: Remove the isinstance/claim_interface block; open the selected port uniformly. A missing device still surfaces as OSError/USBError from the port and is skipped by the hardware tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 58f25f1 commit ebb4e7e

1 file changed

Lines changed: 1 addition & 9 deletions

File tree

hardwarelibrary/powerstrips/pwrusb.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,9 @@ def doInitializeDevice(self):
8383
try:
8484
if self.portPath == "debug":
8585
self.port = DebugPwrUSBPort()
86-
self.port.open()
8786
else:
8887
self.port = self._makePort()
89-
self.port.open()
90-
if isinstance(self.port, USBPort):
91-
# USBPort.open() swallows I/O errors during its flush, so a
92-
# HID interface the OS will not release (e.g. macOS
93-
# IOHIDFamily) is only discovered on the first real transfer.
94-
# Claim it here so such a device fails to initialize cleanly
95-
# instead of later.
96-
usb.util.claim_interface(self.port.device, 0)
88+
self.port.open()
9789

9890
self._outletStateCache = [False] * self.switchableOutletCount
9991
except Exception:

0 commit comments

Comments
 (0)