Page 1 of 1

How about a CPython library that interacts with REPL?

Posted: Mon Aug 15, 2022 7:36 pm
by spierepf
I'm thinking something like:

Code: Select all

import repl_client

client = repl_client.serial("/dev/ttyUSB0", 115200)
assert 3 == client.eval("1 + 2")
or

Code: Select all

import repl_client

client = repl_client.websocket("ws://micropython.local:8266/", "secret")
assert 3 == client.eval("1 + 2")

Re: How about a CPython library that interacts with REPL?

Posted: Mon Aug 15, 2022 8:35 pm
by cgglzpy
You may want to try upydevice which is the backend for upydev, so you should already have it installed.

Code: Select all


>>> from upydevice import Device
>>> client = Device("/dev/tty.usbmodem3370377430372", init=True)
>>> assert 3 == client.wr_cmd("1+2", rtn_resp = True)
3
>>>

Re: How about a CPython library that interacts with REPL?

Posted: Tue Aug 16, 2022 1:36 am
by jameswise
I think that's a great idea! There are already a few CPython libraries that interact with MicroPython REPLs, but it would be great to have one that is more widely used and supported.

Re: How about a CPython library that interacts with REPL?

Posted: Wed Aug 17, 2022 1:55 am
by mattyt
The MicroPytrhon-supported pyboard.py can do this (mpremote is built on top of it).