Python library to interface with wireless/serial Micropython devices
Project description
uPydevice
Python library to interface with Micropython devices through WebREPL protocol or through Serial connection.
Requirements
upydev and pyserial will be automatically installed with pip
to install picocom do: brew install picocom
Install
pip install upydevice
Example usage:
WIRELESS DEVICE (WebREPL Protocol)
>>> from upydevice import W_UPYDEVICE
# Setup and configurate a device :
>>> esp32 = W_UPYDEVICE('192.168.1.56', 'mypass') # (target_ip, password)
# Send command:
>>> esp32.cmd('led.on()')
>>> esp32.cmd("uos.listdir('/')")
['boot.py', 'webrepl_cfg.py', 'main.py'] # this output is stored in [upydevice].output
>>> esp32.output
['boot.py', 'webrepl_cfg.py', 'main.py']
>>> esp32.cmd('foo()')
>>> esp32.cmd('x = [1,2,3];my_var = len(x);print(my_var)')
3
# Soft Reset:
>>> esp32.reset()
Rebooting device...
### closed ###
Done!
SERIAL DEVICE (Picocom, Pyserial)
>>> from upydevice import S_UPYDEVICE
# Setup and configurate a device :
>>> esp32 = S_UPYDEVICE('/dev/tty.SLAB_USBtoUART', 1000, 115200) # defaults (serial_port, timeout=1000, baudrate=9600)
# Send command:
>>> esp32.cmd('led.on()')
>>> esp32.cmd("uos.listdir('/')")
['boot.py', 'webrepl_cfg.py', 'main.py'] # this output is stored in [upydevice].output
>>> esp32.output
['boot.py', 'webrepl_cfg.py', 'main.py']
>>> esp32.cmd('foo()')
>>> esp32.cmd('x = [1,2,3];my_var = len(x);print(my_var)')
3
# Soft Reset:
>>> esp32.reset()
Rebooting device...
Done!
PYBOARD (Picocom, Pyserial)
>>> from upydevice import PYBOARD
# Setup and configurate a device :
pyboard = PYBOARD('/dev/tty.usbmodem3370377430372') # defaults (serial_port, timeout=1000, baudrate=9600)
# Send command:
>>> pyboard.cmd('pyb.LED(1).toggle()',100)
>>> pyboard.cmd("import uos;uos.listdir('/flash')")
['main.py', 'pybcdc.inf', 'README.txt', 'boot.py', '.fseventsd', '.Trashes'] # this output is stored in [upydevice].output
>>> pyboard.output
['main.py', 'pybcdc.inf', 'README.txt', 'boot.py', '.fseventsd', '.Trashes']
>>> pyboard.cmd('foo()')
>>> pyboard.cmd('x = [1,2,3];my_var = len(x);print(my_var)')
3
# Soft Reset:
>>> pyboard.reset()
Rebooting pyboard...
Done!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file upydevice-0.0.4.tar.gz.
File metadata
- Download URL: upydevice-0.0.4.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7724e15a4568a5a4bb2f9e7057c62c5aed4a7413542a8e2629fa6389eed2be1
|
|
| MD5 |
d92944c793f44685da61af78a18801cf
|
|
| BLAKE2b-256 |
028310e05af84ed4427bdf8d48b56facd2bc9f118c3e238bd942ef8954ec9f52
|
File details
Details for the file upydevice-0.0.4-py3-none-any.whl.
File metadata
- Download URL: upydevice-0.0.4-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7d5070b526e03cd794a183a2a379062b944eb0a3ec36df56ba4c5a767689c98
|
|
| MD5 |
7c05a2cd760802b34175b3afcfd23b54
|
|
| BLAKE2b-256 |
98581aa6713c09c5c85dcb49afbca42042aba6730aada18b6fd7602a561a8365
|