mcu_stubber¶
This script creates stubs on and for a connected micropython MCU board.
Attributes¶
Classes¶
Variants to generate stubs on a MCU |
|
Optimization forms of scripts |
Functions¶
|
Reset the board |
|
Run a createstubs[variant] on the provided board. |
|
Build the import createstubs[_??] command to run on the board |
|
Create lib directory and add to sys.path for mip_install. |
|
Generate the firmware stubs (formerly MCU stubs) for this MCU board. |
Copies the board name to the board by writing it to the 'boardname.py' file. |
|
|
Copy the createstubs script(s) to the board. |
|
|
|
Set log level based on verbose level |
|
Copy the generated stubs to the stubs repo. |
|
Runs the stubber to generate stubs for connected MicroPython boards. |
|
|
|
Print a table of stub locations for generated stubs. |
Module Contents¶
- mcu_stubber.HERE¶
- mcu_stubber.reset_before = True¶
- mcu_stubber.TESTING = False¶
- class mcu_stubber.Variant¶
-
Variants to generate stubs on a MCU
- full = 'full'¶
- mem = 'mem'¶
- db = 'db'¶
- mcu_stubber.hard_reset(board: mpflash.mpremoteboard.MPRemoteBoard) bool¶
Reset the board
- Parameters:
board (mpflash.mpremoteboard.MPRemoteBoard)
- Return type:
- mcu_stubber.run_createstubs(dest: pathlib.Path, mcu: mpflash.mpremoteboard.MPRemoteBoard, variant: Variant = Variant.db, mount_vfs: bool = True)¶
Run a createstubs[variant] on the provided board. Retry running the command up to 10 times, with a 15 second timeout between retries. this should allow for the boards with little memory to complete even if they run out of memory.
- Parameters:
dest (pathlib.Path)
mcu (mpflash.mpremoteboard.MPRemoteBoard)
variant (Variant)
mount_vfs (bool)
- mcu_stubber.build_cmd(dest: pathlib.Path | None, variant: Variant = Variant.db) List[str]¶
Build the import createstubs[_??] command to run on the board
- Parameters:
dest (Union[pathlib.Path, None])
variant (Variant)
- Return type:
List[str]
- mcu_stubber.ensure_lib_directory(mcu: mpflash.mpremoteboard.MPRemoteBoard)¶
Create lib directory and add to sys.path for mip_install.
mpremote mip requires a lib path in sys.path but does not create the directory itself. This must be called before mip_install.
- Parameters:
mcu (mpflash.mpremoteboard.MPRemoteBoard)
- mcu_stubber.generate_board_stubs(dest: pathlib.Path, mcu: mpflash.mpremoteboard.MPRemoteBoard, variant: Variant = Variant.db, form: Form = Form.mpy, mount_vfs: bool = True, exclude: List[str] | None = None) Tuple[int, pathlib.Path | None]¶
Generate the firmware stubs (formerly MCU stubs) for this MCU board. :param dest: The destination folder for the stubs :type dest: Path :param port: The port the board is connected to :type port: str
- Parameters:
dest (pathlib.Path)
mcu (mpflash.mpremoteboard.MPRemoteBoard)
variant (Variant)
form (Form)
mount_vfs (bool)
exclude (Union[List[str], None])
- Return type:
Tuple[int, Optional[pathlib.Path]]
- mcu_stubber.copy_boardname_to_board(mcu: mpflash.mpremoteboard.MPRemoteBoard)¶
Copies the board name to the board by writing it to the ‘boardname.py’ file.
- Parameters:
mcu (mpflash.mpremoteboard.MPRemoteBoard) – The MCU object representing the microcontroller.
- Returns:
None
- mcu_stubber.install_scripts_to_board(mcu: mpflash.mpremoteboard.MPRemoteBoard, form: Form)¶
Copy the createstubs script(s) to the board. The scripts are sourced from the ‘board’ folder that is included
in the micropython-stubber package.
or in de repo during development
- mcu_stubber.set_loglevel(verbose: int) str¶
Set log level based on verbose level Get the level from the verbose setting (0=INFO, 1=DEBUG, 2=TRACE) Set the format string, based on the level. Add the handler to the logger, with the level and format string. Return the level
- mcu_stubber.copy_to_repo(source: pathlib.Path, fw: dict) pathlib.Path | None¶
Copy the generated stubs to the stubs repo. If the destination folder exists, it is first emptied when successful: returns the destination path - None otherwise
- Parameters:
source (pathlib.Path)
fw (dict)
- Return type:
Optional[pathlib.Path]
- mcu_stubber.stub_connected_mcus(variant: str, format: str, debug: bool, serial: List[str], ignore: List[str], bluetooth: bool, exclude: List[str] | None = None, mount_vfs: bool = True) int¶
Runs the stubber to generate stubs for connected MicroPython boards.
- Parameters:
- Returns:
None
- Return type: