Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pyusbmux.py to handle devices > 30 #11

Merged
merged 2 commits into from
Sep 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 24 additions & 10 deletions wdapy/usbmux/pyusbmux.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,15 +369,29 @@ def get_pair_record(self, serial: str) -> Mapping:
def get_device_list(self, timeout: float = None) -> None:
""" get device list synchronously without waiting the timeout """
self.devices = []
self._send({'MessageType': 'ListDevices'})
for response in self._receive(self._tag - 1)['DeviceList']:
if response['MessageType'] == 'Attached':
super()._add_device(MuxDevice(response['DeviceID'], response['Properties']['SerialNumber'],
response['Properties']['ConnectionType']))
elif response['MessageType'] == 'Detached':
super()._remove_device(response['DeviceID'])
else:
raise MuxError(f'Invalid packet type received: {response}')
self._send_receive({'MessageType': 'Listen'})
end = time.time() + timeout
self._sock.settimeout(timeout)
while time.time() < end:
try:
response = self._receive()
if response['MessageType'] == 'Attached':
super()._add_device(MuxDevice(response['DeviceID'], response['Properties']['SerialNumber'],
response['Properties']['ConnectionType']))
elif response['MessageType'] == 'Detached':
super()._remove_device(response['DeviceID'])
else:
raise MuxError(f'Invalid packet type received: {response}')
except (BlockingIOError, StreamError):
continue
except IOError:
try:
self._sock.setblocking(True)
self.close()
except OSError:
pass
raise MuxError('Exception in listener socket')


def get_buid(self) -> str:
""" get SystemBUID """
Expand Down Expand Up @@ -482,4 +496,4 @@ def __enter__(self) -> HTTPConnection:
return self

def __exit__(self, exc_type, exc_value, traceback):
self.close()
self.close()
Loading