Skip to content

Commit 72e3501

Browse files
committed
pybricksdev._vendored: create new folder for vendored files
This will help keep code where we are not the original authors sorted and out of the way. We are planning on adding more, so start with the ones we have already.
1 parent d71a0b9 commit 72e3501

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed
File renamed without changes.
File renamed without changes.

pybricksdev/dfu.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414

1515
from usb.core import NoBackendError, USBError
1616

17-
from . import _dfu_upload, _dfu_create, resources
17+
from . import resources
18+
from ._vendored import dfu_upload, dfu_create
1819
from .ble.lwp3.bytecodes import HubKind
1920

2021
FIRMWARE_ADDRESS = 0x08008000
@@ -167,7 +168,7 @@ def flash_dfu(firmware_bin: bytes, metadata: dict) -> None:
167168
try:
168169
# Determine correct product ID
169170

170-
devices = _dfu_upload.get_dfu_devices(idVendor=LEGO_VID)
171+
devices = dfu_upload.get_dfu_devices(idVendor=LEGO_VID)
171172
if not devices:
172173
print(
173174
"No DFU devices found.",
@@ -187,22 +188,22 @@ def flash_dfu(firmware_bin: bytes, metadata: dict) -> None:
187188

188189
# Create dfu file
189190
device = "0x{0:04x}:0x{1:04x}".format(LEGO_VID, product_id)
190-
_dfu_create.build(outfile, [[target]], device)
191+
dfu_create.build(outfile, [[target]], device)
191192

192193
# Init dfu tool
193-
_dfu_upload.__VID = LEGO_VID
194-
_dfu_upload.__PID = product_id
195-
_dfu_upload.init()
196-
elements = _dfu_upload.read_dfu_file(outfile)
194+
dfu_upload.__VID = LEGO_VID
195+
dfu_upload.__PID = product_id
196+
dfu_upload.init()
197+
elements = dfu_upload.read_dfu_file(outfile)
197198

198199
# Erase flash
199200
print("Erasing flash...")
200-
_dfu_upload.mass_erase()
201+
dfu_upload.mass_erase()
201202

202203
# Upload dfu file
203204
print("Writing new firmware...")
204-
_dfu_upload.write_elements(elements, True, _dfu_upload.cli_progress)
205-
_dfu_upload.exit_dfu()
205+
dfu_upload.write_elements(elements, True, dfu_upload.cli_progress)
206+
dfu_upload.exit_dfu()
206207
print("Done.")
207208
except USBError as e:
208209
if e.errno != errno.EACCES or platform.system() != "Linux":
@@ -225,7 +226,7 @@ def flash_dfu(firmware_bin: bytes, metadata: dict) -> None:
225226

226227
dev_id = _get_vid_pid(dfu_util)
227228

228-
_dfu_create.build(outfile, [[target]], dev_id)
229+
dfu_create.build(outfile, [[target]], dev_id)
229230

230231
exit(
231232
call(

0 commit comments

Comments
 (0)