mpflash 0.8.5__py3-none-any.whl → 0.8.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mpflash/add_firmware.py +98 -98
- mpflash/ask_input.py +236 -236
- mpflash/bootloader/__init__.py +37 -36
- mpflash/bootloader/manual.py +102 -102
- mpflash/bootloader/micropython.py +10 -10
- mpflash/bootloader/touch1200.py +45 -45
- mpflash/cli_download.py +129 -129
- mpflash/cli_flash.py +219 -219
- mpflash/cli_group.py +98 -98
- mpflash/cli_list.py +81 -81
- mpflash/cli_main.py +41 -41
- mpflash/common.py +164 -164
- mpflash/config.py +47 -47
- mpflash/connected.py +74 -74
- mpflash/download.py +360 -360
- mpflash/downloaded.py +129 -129
- mpflash/errors.py +9 -9
- mpflash/flash.py +52 -52
- mpflash/flash_esp.py +59 -59
- mpflash/flash_stm32.py +24 -24
- mpflash/flash_stm32_cube.py +111 -111
- mpflash/flash_stm32_dfu.py +101 -101
- mpflash/flash_uf2.py +67 -67
- mpflash/flash_uf2_boardid.py +15 -15
- mpflash/flash_uf2_linux.py +123 -123
- mpflash/flash_uf2_macos.py +34 -34
- mpflash/flash_uf2_windows.py +34 -34
- mpflash/list.py +89 -89
- mpflash/logger.py +41 -41
- mpflash/mpboard_id/__init__.py +93 -93
- mpflash/mpboard_id/add_boards.py +255 -255
- mpflash/mpboard_id/board.py +37 -37
- mpflash/mpboard_id/board_id.py +86 -86
- mpflash/mpboard_id/store.py +43 -43
- mpflash/mpremoteboard/__init__.py +221 -221
- mpflash/mpremoteboard/mpy_fw_info.py +141 -141
- mpflash/mpremoteboard/runner.py +140 -140
- mpflash/uf2disk.py +12 -12
- mpflash/vendor/basicgit.py +288 -288
- mpflash/vendor/click_aliases.py +91 -91
- mpflash/vendor/dfu.py +165 -165
- mpflash/vendor/pydfu.py +605 -605
- mpflash/vendor/readme.md +2 -2
- mpflash/vendor/versions.py +119 -117
- mpflash/worklist.py +170 -170
- {mpflash-0.8.5.dist-info → mpflash-0.8.7.dist-info}/LICENSE +20 -20
- {mpflash-0.8.5.dist-info → mpflash-0.8.7.dist-info}/METADATA +1 -1
- mpflash-0.8.7.dist-info/RECORD +52 -0
- mpflash-0.8.5.dist-info/RECORD +0 -52
- {mpflash-0.8.5.dist-info → mpflash-0.8.7.dist-info}/WHEEL +0 -0
- {mpflash-0.8.5.dist-info → mpflash-0.8.7.dist-info}/entry_points.txt +0 -0
mpflash/connected.py
CHANGED
@@ -1,74 +1,74 @@
|
|
1
|
-
from typing import List, Tuple
|
2
|
-
|
3
|
-
from rich import print
|
4
|
-
from rich.progress import BarColumn, Progress, SpinnerColumn, TextColumn, TimeElapsedColumn
|
5
|
-
from rich.table import Column
|
6
|
-
|
7
|
-
from mpflash.mpremoteboard import MPRemoteBoard
|
8
|
-
|
9
|
-
from .common import filtered_comports
|
10
|
-
|
11
|
-
|
12
|
-
def connected_ports_boards(
|
13
|
-
*, include: List[str], ignore: List[str]
|
14
|
-
) -> Tuple[List[str], List[str], List[MPRemoteBoard]]:
|
15
|
-
"""
|
16
|
-
Returns a tuple containing lists of unique ports and boards from the connected MCUs.
|
17
|
-
Boards that are physically connected, but give no tangible response are ignored.
|
18
|
-
|
19
|
-
Returns:
|
20
|
-
A tuple containing three lists:
|
21
|
-
- A list of unique ports where MCUs are connected.
|
22
|
-
- A list of unique board names of the connected MCUs.
|
23
|
-
- A list of MPRemoteBoard instances of the connected MCUs.
|
24
|
-
"""
|
25
|
-
mpr_boards = [b for b in list_mcus(include=include, ignore=ignore) if b.connected]
|
26
|
-
ports = list({b.port for b in mpr_boards})
|
27
|
-
boards = list({b.board for b in mpr_boards})
|
28
|
-
return (ports, boards, mpr_boards)
|
29
|
-
|
30
|
-
|
31
|
-
# #########################################################################################################
|
32
|
-
rp_spinner = SpinnerColumn(finished_text="✅")
|
33
|
-
rp_text = TextColumn("{task.description} {task.fields[device]}", table_column=Column())
|
34
|
-
rp_bar = BarColumn(bar_width=None, table_column=Column())
|
35
|
-
|
36
|
-
|
37
|
-
def list_mcus(*, ignore: List[str], include: List[str], bluetooth: bool = False):
|
38
|
-
"""
|
39
|
-
Retrieves information about connected microcontroller boards.
|
40
|
-
|
41
|
-
Returns:
|
42
|
-
List[MPRemoteBoard]: A list of MPRemoteBoard instances with board information.
|
43
|
-
Raises:
|
44
|
-
ConnectionError: If there is an error connecting to a board.
|
45
|
-
"""
|
46
|
-
# conn_mcus = [MPRemoteBoard(sp) for sp in MPRemoteBoard.connected_boards(bluetooth) if sp not in config.ignore_ports]
|
47
|
-
|
48
|
-
comports = filtered_comports(
|
49
|
-
ignore=ignore,
|
50
|
-
include=include,
|
51
|
-
bluetooth=bluetooth,
|
52
|
-
)
|
53
|
-
conn_mcus = [MPRemoteBoard(c.device) for c in comports]
|
54
|
-
|
55
|
-
# a lot of boilerplate to show a progress bar with the comport currently scanned
|
56
|
-
# low update rate to facilitate screen readers/narration
|
57
|
-
with Progress(rp_spinner, rp_text, rp_bar, TimeElapsedColumn(), refresh_per_second=2) as progress:
|
58
|
-
tsk_scan = progress.add_task("[green]Scanning", visible=False, total=None)
|
59
|
-
progress.tasks[tsk_scan].fields["device"] = "..."
|
60
|
-
progress.tasks[tsk_scan].visible = True
|
61
|
-
progress.start_task(tsk_scan)
|
62
|
-
try:
|
63
|
-
for mcu in conn_mcus:
|
64
|
-
progress.update(tsk_scan, device=mcu.serialport.replace("/dev/", ""))
|
65
|
-
try:
|
66
|
-
mcu.get_mcu_info()
|
67
|
-
except ConnectionError as e:
|
68
|
-
print(f"Error: {e}")
|
69
|
-
continue
|
70
|
-
finally:
|
71
|
-
# transient
|
72
|
-
progress.stop_task(tsk_scan)
|
73
|
-
progress.tasks[tsk_scan].visible = False
|
74
|
-
return conn_mcus
|
1
|
+
from typing import List, Tuple
|
2
|
+
|
3
|
+
from rich import print
|
4
|
+
from rich.progress import BarColumn, Progress, SpinnerColumn, TextColumn, TimeElapsedColumn
|
5
|
+
from rich.table import Column
|
6
|
+
|
7
|
+
from mpflash.mpremoteboard import MPRemoteBoard
|
8
|
+
|
9
|
+
from .common import filtered_comports
|
10
|
+
|
11
|
+
|
12
|
+
def connected_ports_boards(
|
13
|
+
*, include: List[str], ignore: List[str]
|
14
|
+
) -> Tuple[List[str], List[str], List[MPRemoteBoard]]:
|
15
|
+
"""
|
16
|
+
Returns a tuple containing lists of unique ports and boards from the connected MCUs.
|
17
|
+
Boards that are physically connected, but give no tangible response are ignored.
|
18
|
+
|
19
|
+
Returns:
|
20
|
+
A tuple containing three lists:
|
21
|
+
- A list of unique ports where MCUs are connected.
|
22
|
+
- A list of unique board names of the connected MCUs.
|
23
|
+
- A list of MPRemoteBoard instances of the connected MCUs.
|
24
|
+
"""
|
25
|
+
mpr_boards = [b for b in list_mcus(include=include, ignore=ignore) if b.connected]
|
26
|
+
ports = list({b.port for b in mpr_boards})
|
27
|
+
boards = list({b.board for b in mpr_boards})
|
28
|
+
return (ports, boards, mpr_boards)
|
29
|
+
|
30
|
+
|
31
|
+
# #########################################################################################################
|
32
|
+
rp_spinner = SpinnerColumn(finished_text="✅")
|
33
|
+
rp_text = TextColumn("{task.description} {task.fields[device]}", table_column=Column())
|
34
|
+
rp_bar = BarColumn(bar_width=None, table_column=Column())
|
35
|
+
|
36
|
+
|
37
|
+
def list_mcus(*, ignore: List[str], include: List[str], bluetooth: bool = False):
|
38
|
+
"""
|
39
|
+
Retrieves information about connected microcontroller boards.
|
40
|
+
|
41
|
+
Returns:
|
42
|
+
List[MPRemoteBoard]: A list of MPRemoteBoard instances with board information.
|
43
|
+
Raises:
|
44
|
+
ConnectionError: If there is an error connecting to a board.
|
45
|
+
"""
|
46
|
+
# conn_mcus = [MPRemoteBoard(sp) for sp in MPRemoteBoard.connected_boards(bluetooth) if sp not in config.ignore_ports]
|
47
|
+
|
48
|
+
comports = filtered_comports(
|
49
|
+
ignore=ignore,
|
50
|
+
include=include,
|
51
|
+
bluetooth=bluetooth,
|
52
|
+
)
|
53
|
+
conn_mcus = [MPRemoteBoard(c.device) for c in comports]
|
54
|
+
|
55
|
+
# a lot of boilerplate to show a progress bar with the comport currently scanned
|
56
|
+
# low update rate to facilitate screen readers/narration
|
57
|
+
with Progress(rp_spinner, rp_text, rp_bar, TimeElapsedColumn(), refresh_per_second=2) as progress:
|
58
|
+
tsk_scan = progress.add_task("[green]Scanning", visible=False, total=None)
|
59
|
+
progress.tasks[tsk_scan].fields["device"] = "..."
|
60
|
+
progress.tasks[tsk_scan].visible = True
|
61
|
+
progress.start_task(tsk_scan)
|
62
|
+
try:
|
63
|
+
for mcu in conn_mcus:
|
64
|
+
progress.update(tsk_scan, device=mcu.serialport.replace("/dev/", ""))
|
65
|
+
try:
|
66
|
+
mcu.get_mcu_info()
|
67
|
+
except ConnectionError as e:
|
68
|
+
print(f"Error: {e}")
|
69
|
+
continue
|
70
|
+
finally:
|
71
|
+
# transient
|
72
|
+
progress.stop_task(tsk_scan)
|
73
|
+
progress.tasks[tsk_scan].visible = False
|
74
|
+
return conn_mcus
|