Skip to content

Commit

Permalink
Document passing arguments to main() (espressif#408)
Browse files Browse the repository at this point in the history
* Document passing arguments to main()

Addresses espressif#406]
  • Loading branch information
marcelstoer authored and projectgus committed Apr 18, 2019
1 parent fd1788c commit 6135095
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,20 @@ Note that not every serial program supports the unusual ESP8266 74880bps "boot l

Running `esptool.py --trace` will dump all serial interactions to the standard output (this is *a lot* of output). This can be helpful when debugging issues with the serial connection, or when providing information for bug reports.

## Using esptool.py from Python

esptool.py can easily be integrated into Python applications or called from other Python scripts.

While it currently does have a poor Python API, something which [#208](https://github.com/espressif/esptool/issues/208) will address, it allows for passing CLI
arguments to `esptool.main()`. This workaround makes integration very straightforward as you can pass exactly the
same arguments as you would on the CLI.

```python
command = ['--baud', '460800', 'read_flash', '0', '0x200000', 'flash_contents.bin']
print('Using command %s' % ' '.join(command))
esptool.main(command)
```

## Internal Technical Documentation

The [repository wiki](https://github.com/espressif/esptool/wiki) contains some technical documentation regarding the serial protocol and file format used by the ROM bootloader. This may be useful if you're developing esptool.py or hacking system internals:
Expand Down
3 changes: 2 additions & 1 deletion esptool.py
Original file line number Diff line number Diff line change
Expand Up @@ -2548,7 +2548,8 @@ def main(custom_commandline=None):
Main function for esptool
custom_commandline - Optional override for default arguments parsing (that uses sys.argv), can be a list of custom arguments
as strings.
as strings. Arguments and their values need to be added as individual items to the list e.g. "-b 115200" thus
becomes ['-b', '115200'].
"""
parser = argparse.ArgumentParser(description='esptool.py v%s - ESP8266 ROM Bootloader Utility' % __version__, prog='esptool')

Expand Down

0 comments on commit 6135095

Please sign in to comment.