Callback to receive terminal (REPL) data
micropython.onTerminalData = (data) => process.stdout.write(data)
Callback that is triggered when the connection is lost or closed.
micropython.onclose = () => console.log('connection closed')
Connect to a device over the network (requires enabled WebREPL)
IP address or hostname
webrepl password
Connection timeout (default: 5 sec). To disable, set to 0
Connect to a device over the serial interface
Serial interface (eg. /dev/ttyUSB0
, /dev/tty.SLAB_USBtoUART
, ...)
Get information about the board.
const boardInfo = await micropython.getBoardInfo()
console.log(boardInfo)
{
sysname: 'esp32',
nodename: 'esp32',
release: '1.13.0',
version: 'v1.13 on 2020-09-02',
machine: 'ESP32 module with ESP32',
uniqueId: 'c44f3312f529',
memFree: 108736,
fsBlockSize: 4096,
fsBlocksTotal: 512,
fsBlocksFree: 438
}
Get the contents of a file.
const data = await micropython.getFile('boot.py')
filename of file to download
contents of the file in a Buffer
Get SHA256 hash of a file contents.
const data = await micropython.getFileHash('boot.py')
filename of target file
sha256 hash, hexlified
Get the state object. Mostly used for debugging purposes.
GET_VER webrepl command. Returns the micropython version. Only works with network connections, not with serial.
Whether currently connected to a device.
Check whether a file is the same as provided, within a single runScript
execution.
Does not work in browser.
This is a helper for bulk uploading directories, but only if they have changed.
Uploading data to the device, saving as a file.
We break the buffer into multiple chunks, and execute a raw repl command for each of them in order to not fill up the device RAM.
See also:
Remove a file or directory. Optional recursively
default: false
Rename a file or directory (uos.rename)
Reset a device.
Execute a Python script on the device, wait and return the output.
the python code
The internal webserver is used to proxy runScript commands over an existing connection
Generated using TypeDoc
Main class for a MicroPython device connection.
See also https://github.com/metachris/micropython-ctl