How about a CPython library that interacts with REPL?

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
spierepf
Posts: 22
Joined: Mon Jul 08, 2019 3:22 pm

How about a CPython library that interacts with REPL?

Post by spierepf » Mon Aug 15, 2022 7:36 pm

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")

cgglzpy
Posts: 47
Joined: Thu Jul 18, 2019 4:20 pm

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

Post by cgglzpy » Mon Aug 15, 2022 8:35 pm

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
>>>

jameswise
Posts: 5
Joined: Tue Aug 16, 2022 1:32 am

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

Post by jameswise » Tue Aug 16, 2022 1:36 am

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.

User avatar
mattyt
Posts: 410
Joined: Mon Jan 23, 2017 6:39 am

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

Post by mattyt » Wed Aug 17, 2022 1:55 am

The MicroPytrhon-supported pyboard.py can do this (mpremote is built on top of it).

Post Reply