Sending a list with the Pyboard library #9495
Replies: 5 comments 2 replies
-
A related problem for other uses, I'd like to log the output with the |
Beta Was this translation helpful? Give feedback.
-
Instead of pyb.serial you can use the machine.UART class, which supports readline. machine.UART is portable across all ports. The pyb.xx classes are specific to PyBoard and kept for legacy, but new code should used the machine classes. Edit: pyb.UART supports readline as well, so I'm wondering which board and firmware you use? |
Beta Was this translation helpful? Give feedback.
-
If you trust both sides of this, then If you Even simpler:
|
Beta Was this translation helpful? Give feedback.
-
Another great option for this use case is https://github.com/BrianPugh/belay |
Beta Was this translation helpful? Give feedback.
-
So I tried the suggestions from this discussion and: from mpremote import pyboard
from serial.tools import list_ports
# Initialize PyBoard and connect in REPL mode
port = list(list_ports.comports())
pyb = pyboard.Pyboard(port[0].device, 115200)
mypath="."
files = eval(pyb.eval(f"import os; os.listdir('{mypath}')"))
print([f for f in files]) doesn't print anything. It just hangs indefinitely. Any ideas what I'm doing wrong? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
This is actually a continuation of an issue on the MicroPython forum: https://forum.micropython.org/viewtopic.php?f=2&t=12663. @dhylands perhaps you can be of help here again?
Normally I would just use
serial.readline()
, however I'm using Pyboard from Python and that doesn't seem to work (I don't think it's supported?). I can easily send individual bytes, however I can't find a way to send whole lines? My current issue is that I want to create an object on the computer that contains the files on the board. I can useos.listdir()
and also print it well formatted - but I have not been able to find a way to re-create the list.The list consists of 2 files:
test.py
andtalk.py
.On my Pico I have
talk.py
:And locally I run:
And I get this relatively neat printed output:
How do I get this as a list I can work with?
Beta Was this translation helpful? Give feedback.
All reactions