fix: #531 #537. Better handling of EPIPE during hid write.

This commit is contained in:
Matthias Fulz 2019-07-26 12:27:48 +02:00 committed by Filipe Laíns
parent 6a1968beff
commit 155e2f8c40
2 changed files with 12 additions and 4 deletions

View File

@ -260,9 +260,17 @@ def write(device_handle, data):
assert device_handle
assert data
assert isinstance(data, bytes), (repr(data), type(data))
bytes_written = _os.write(device_handle, data)
if bytes_written != len(data):
raise IOError(_errno.EIO, 'written %d bytes out of expected %d' % (bytes_written, len(data)))
retrycount = 0
while(True and retrycount < 3):
try:
bytes_written = _os.write(device_handle, data)
if bytes_written != len(data):
raise IOError(_errno.EIO, 'written %d bytes out of expected %d' % (bytes_written, len(data)))
except IOError as e:
if e.errno != _errno.EPIPE:
raise e
retrycount += 1
continue
def read(device_handle, bytes_count, timeout_ms=-1):

View File

@ -345,7 +345,7 @@ class Receiver(object):
self.serial = 0
self.max_devices = 6
if self.product_id == 'c539' or slef.product_id == 'c53a':
if self.product_id == 'c539' or self.product_id == 'c53a':
self.name = 'Lightspeed Receiver'
elif self.max_devices == 6:
self.name = 'Unifying Receiver'