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)]