diff --git a/lib/logitech_receiver/device.py b/lib/logitech_receiver/device.py index 8c0fdde8..725a7259 100644 --- a/lib/logitech_receiver/device.py +++ b/lib/logitech_receiver/device.py @@ -706,6 +706,14 @@ class Device: long_message=long, protocol=self.protocol, ) + if logger.isEnabledFor(logging.WARN): + logger.warning( + "%s: request failure for device %s %s %s", + self, + self.handle, + self.receiver, + self.receiver._devices if self.receiver else None, + ) def feature_request(self, feature, function=0x00, *params, no_reply=False): if self.protocol >= 2.0: @@ -730,6 +738,8 @@ class Device: if sub_idx is not None: return self.centurion_bridge_request(sub_idx, function, *params, no_reply=no_reply) return hidpp20.feature_request(self, feature, function, *params, no_reply=no_reply) + if logger.isEnabledFor(logging.WARN): + logger.warning("%s: feature request failure for device with protocol %s", self, self.protocol) # Max sub-message bytes in the first bridge fragment (for 0x51): # 64 - 1 (report ID) - 1 (cpl_len) - 1 (flags) - 2 (bridge prefix) - 2 (bridge hdr) = 57; diff --git a/lib/logitech_receiver/hidpp20.py b/lib/logitech_receiver/hidpp20.py index d5b5dda9..def630a2 100644 --- a/lib/logitech_receiver/hidpp20.py +++ b/lib/logitech_receiver/hidpp20.py @@ -1756,6 +1756,10 @@ def feature_request(device, feature, function=0x00, *params, no_reply=False): if feature in device.features: feature_index = device.features[feature] return device.request((feature_index << 8) + (function & 0xFF), *params, no_reply=no_reply) + if logger.isEnabledFor(logging.WARN): + logger.warning( + "%s: feature request failure for device online %s and features %s", device, device.online, device.features + ) class Hidpp20: diff --git a/lib/logitech_receiver/listener.py b/lib/logitech_receiver/listener.py index 1ca4a778..16c866db 100644 --- a/lib/logitech_receiver/listener.py +++ b/lib/logitech_receiver/listener.py @@ -96,6 +96,8 @@ class _ThreadedHandle: def __str__(self): if self._local: return str(int(self)) + else: + return "None" def __repr__(self): return f"<_ThreadedHandle({self.path})>" diff --git a/lib/logitech_receiver/receiver.py b/lib/logitech_receiver/receiver.py index 42df1c08..e72a69c4 100644 --- a/lib/logitech_receiver/receiver.py +++ b/lib/logitech_receiver/receiver.py @@ -171,6 +171,8 @@ class Receiver: self.pairing = Pairing() self.initialize(product_info) hidpp10.set_configuration_pending_flags(self, 0xFF) + if logger.isEnabledFor(logging.INFO): + logger.info("%s: init receiver: handle %s, path %s, serial %s", self, self.handle, self.path, self.serial) def initialize(self, product_info: dict): # read the receiver information subregister, so we can find out max_devices @@ -185,6 +187,8 @@ class Receiver: self.max_devices = product_info.get("max_devices", 1) def close(self): + if logger.isEnabledFor(logging.INFO): + logger.info("%s: closing - handle %s %s", self, type(self.handle), self.handle) handle, self.handle = self.handle, None for _n, d in self._devices.items(): if d: @@ -599,9 +603,10 @@ receiver_class_mapping = { def create_receiver(low_level: LowLevelInterface, device_info, setting_callback=None) -> Optional[Receiver]: """Opens a Logitech Receiver found attached to the machine, by Linux device path.""" - try: handle = low_level.open_path(device_info.path) + if logger.isEnabledFor(logging.INFO): + logger.info("create receiver %s %s", handle, device_info) if handle: usb_id = device_info.product_id if isinstance(usb_id, str):