receiver: add option to not wait for a reply when requesting to device
This commit is contained in:
parent
c9c472e391
commit
c6506b3508
|
@ -312,16 +312,14 @@ del namedtuple
|
|||
#
|
||||
|
||||
|
||||
def request(handle, devnumber, request_id, *params):
|
||||
# a very few requests (e.g., host switching) do not expect a reply, but use no_reply=True with extreme caution
|
||||
def request(handle, devnumber, request_id, *params, no_reply=False):
|
||||
"""Makes a feature call to a device and waits for a matching reply.
|
||||
|
||||
This function will wait for a matching reply indefinitely.
|
||||
|
||||
:param handle: an open UR handle.
|
||||
:param devnumber: attached device number.
|
||||
:param request_id: a 16-bit integer.
|
||||
:param params: parameters for the feature call, 3 to 16 bytes.
|
||||
:returns: the reply data, or ``None`` if some error occurred.
|
||||
:returns: the reply data, or ``None`` if some error occurred. or no reply expected
|
||||
"""
|
||||
|
||||
# import inspect as _inspect
|
||||
|
@ -354,6 +352,9 @@ def request(handle, devnumber, request_id, *params):
|
|||
_skip_incoming(handle, ihandle, notifications_hook)
|
||||
write(ihandle, devnumber, request_data)
|
||||
|
||||
if no_reply:
|
||||
return None
|
||||
|
||||
# we consider timeout from this point
|
||||
request_started = _timestamp()
|
||||
delta = 0
|
||||
|
|
|
@ -435,11 +435,11 @@ class KeysArray(object):
|
|||
#
|
||||
|
||||
|
||||
def feature_request(device, feature, function=0x00, *params):
|
||||
def feature_request(device, feature, function=0x00, *params, no_reply=False):
|
||||
if device.online and device.features:
|
||||
if feature in device.features:
|
||||
feature_index = device.features.index(int(feature))
|
||||
return device.request((feature_index << 8) + (function & 0xFF), *params)
|
||||
return device.request((feature_index << 8) + (function & 0xFF), *params, no_reply=no_reply)
|
||||
|
||||
|
||||
def get_firmware(device):
|
||||
|
|
|
@ -284,15 +284,15 @@ class PairedDevice(object):
|
|||
_log.info('%s: device notifications %s %s', self, 'enabled' if enable else 'disabled', flag_names)
|
||||
return flag_bits if ok else None
|
||||
|
||||
def request(self, request_id, *params):
|
||||
return _base.request(self.receiver.handle, self.number, request_id, *params)
|
||||
def request(self, request_id, *params, no_reply=False):
|
||||
return _base.request(self.receiver.handle, self.number, request_id, *params, no_reply=no_reply)
|
||||
|
||||
read_register = _hidpp10.read_register
|
||||
write_register = _hidpp10.write_register
|
||||
|
||||
def feature_request(self, feature, function=0x00, *params):
|
||||
def feature_request(self, feature, function=0x00, *params, no_reply=False):
|
||||
if self.protocol >= 2.0:
|
||||
return _hidpp20.feature_request(self, feature, function, *params)
|
||||
return _hidpp20.feature_request(self, feature, function, *params, no_reply=no_reply)
|
||||
|
||||
def ping(self):
|
||||
"""Checks if the device is online, returns True of False"""
|
||||
|
|
Loading…
Reference in New Issue