tools, pydfu: Some fixes to support Python 3.
This commit is contained in:
parent
842210f53a
commit
5fc42a6c97
@ -239,7 +239,7 @@ def consume(fmt, data, names):
|
|||||||
|
|
||||||
def cstring(string):
|
def cstring(string):
|
||||||
"""Extracts a null-terminated string from a byte array."""
|
"""Extracts a null-terminated string from a byte array."""
|
||||||
return string.split('\0', 1)[0]
|
return string.split(b'\0', 1)[0]
|
||||||
|
|
||||||
|
|
||||||
def compute_crc(data):
|
def compute_crc(data):
|
||||||
@ -361,8 +361,8 @@ def get_dfu_devices(*args, **kwargs):
|
|||||||
refine the search.
|
refine the search.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return usb.core.find(*args, find_all=True,
|
return list(usb.core.find(*args, find_all=True,
|
||||||
custom_match=FilterDFU(), **kwargs)
|
custom_match=FilterDFU(), **kwargs))
|
||||||
|
|
||||||
|
|
||||||
def get_memory_layout(device):
|
def get_memory_layout(device):
|
||||||
@ -504,7 +504,11 @@ def main():
|
|||||||
list_dfu_devices(idVendor=__VID, idProduct=__PID)
|
list_dfu_devices(idVendor=__VID, idProduct=__PID)
|
||||||
return
|
return
|
||||||
|
|
||||||
init()
|
try:
|
||||||
|
init()
|
||||||
|
except ValueError as er:
|
||||||
|
print(str(er))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
if args.mass_erase:
|
if args.mass_erase:
|
||||||
print ("Mass erase...")
|
print ("Mass erase...")
|
||||||
|
Loading…
Reference in New Issue
Block a user