From ae7195e94318ab711147173b081df2dd2e59fd12 Mon Sep 17 00:00:00 2001 From: Francois Cartegnie Date: Tue, 2 Jan 2024 19:27:10 +0100 Subject: [PATCH] try alternate endpoint on failure just switching endpoint on exception simple user friendly fix --- lednamebadge.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lednamebadge.py b/lednamebadge.py index a598f9f..0b9aa6d 100755 --- a/lednamebadge.py +++ b/lednamebadge.py @@ -573,10 +573,17 @@ or pass dev.set_configuration() print("using [%s %s] bus=%d dev=%d" % (dev.manufacturer, dev.product, dev.bus, dev.address)) - for i in range(int(len(buf) / 64)): + endpoint = 1 + i = 0 + while i < int(len(buf) / 64): time.sleep(0.1) - dev.write(1, buf[i * 64:i * 64 + 64]) - + try: + dev.write(endpoint, buf[i * 64:i * 64 + 64]) + i += 1 + except ValueError: + if endpoint == 1: + endpoint = 2 + i = 0 def split_to_ints(list_str): return [int(x) for x in re.split(r'[\s,]+', list_str)]