2020import platform
2121import threading
2222import queue
23- import struct
24- import array
2523from typing import Optional , Tuple
2624
2725from .interface import Interface
@@ -177,13 +175,11 @@ def set_packet_count(self, count):
177175 self .packet_count = count
178176
179177 def open (self ):
180- probe_id = self .serial_number or f"VID={ self .vid :#06x} :PID={ self .pid :#06x} "
181-
182178 self .report_in_size , self .report_out_size = self ._get_hid_report_sizes ()
183179
184180 if self .report_in_size is None :
185181 # Fallback: set report size to 64 bytes
186- LOG .warning ("Could not determine IN report size for probe %s, defaulting to 64 bytes" , probe_id )
182+ LOG .warning ("Could not determine IN report size for probe %s, defaulting to 64 bytes" , to_str_safe ( self . serial_number ) )
187183 self .report_in_size = 64
188184
189185 if self .report_out_size is None :
@@ -242,8 +238,9 @@ def _get_hid_report_sizes_windows(self) -> Tuple[Optional[int], Optional[int]]:
242238 HIDP_STATUS_SUCCESS = 0x00110000
243239 if hid_dll .HidP_GetCaps (preparsed_data , ctypes .byref (caps )) == HIDP_STATUS_SUCCESS :
244240 # The lengths include the report ID byte, which we don't use in the packet size.
245- # However, the packet size should match the report size.
246- return caps .InputReportByteLength , caps .OutputReportByteLength
241+ InReportSz = caps .InputReportByteLength - 1 if caps .InputReportByteLength > 0 else None
242+ OutReportSz = caps .OutputReportByteLength - 1 if caps .OutputReportByteLength > 0 else None
243+ return InReportSz , OutReportSz
247244 else :
248245 LOG .debug ("HidP_GetCaps failed." )
249246 return None , None
@@ -254,8 +251,6 @@ def _get_hid_report_sizes_windows(self) -> Tuple[Optional[int], Optional[int]]:
254251 return None , None
255252
256253 def _get_hid_report_sizes_macos (self ) -> Tuple [Optional [int ], Optional [int ]]:
257- # The hid.device object from hidapi is what we need.
258- # The underlying object is an IOHIDDeviceRef, which is a void*
259254 hid_device_ref = ctypes .c_void_p (self .device .dev )
260255 input_size = None
261256 output_size = None
0 commit comments