device: better warnings for feature call errors with reprogrammable key and gesture settings
This commit is contained in:
parent
1449a47263
commit
4c54261f91
|
@ -444,10 +444,12 @@ class ReprogrammableKeyV4(ReprogrammableKey):
|
||||||
self._mapping_flags = mapping_flags_1 | (mapping_flags_2 << 8)
|
self._mapping_flags = mapping_flags_1 | (mapping_flags_2 << 8)
|
||||||
else:
|
else:
|
||||||
raise FeatureCallError(msg='No reply from device.')
|
raise FeatureCallError(msg='No reply from device.')
|
||||||
except Exception:
|
except FeatureCallError: # if the key hasn't ever been configured then the read may fail so only produce a warning
|
||||||
if _log.isEnabledFor(_ERROR):
|
if _log.isEnabledFor(_WARNING):
|
||||||
_log.error(f'Exception in _getCidReporting on device {self._device}: ', exc_info=1)
|
_log.warn(
|
||||||
# Clear flags and set mapping target to self as fallback
|
f'Feature Call Error in _getCidReporting on device {self._device} for cid {self._cid} - use defaults'
|
||||||
|
)
|
||||||
|
# Clear flags and set mapping target to self
|
||||||
self._mapping_flags = 0
|
self._mapping_flags = 0
|
||||||
self._mapped_to = self._cid
|
self._mapped_to = self._cid
|
||||||
|
|
||||||
|
@ -1016,9 +1018,9 @@ class Spec:
|
||||||
def read(self):
|
def read(self):
|
||||||
try:
|
try:
|
||||||
value = feature_request(self._device, FEATURE.GESTURE_2, 0x50, self.id, 0xFF)
|
value = feature_request(self._device, FEATURE.GESTURE_2, 0x50, self.id, 0xFF)
|
||||||
except FeatureCallError:
|
except FeatureCallError: # some calls produce an error (notably spec 5 multiplier on K400Plus)
|
||||||
# I don't know if this should happen, but I get an error
|
if _log.isEnabledFor(_WARNING):
|
||||||
# with spec 5
|
_log.warn(f'Feature Call Error reading Gesture Spec on device {self._device} for spec {self.id} - use None')
|
||||||
return None
|
return None
|
||||||
return _bytes2int(value[:self.byte_count])
|
return _bytes2int(value[:self.byte_count])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue