Is it possible to read from file using
fp=open(‘file.txt’,‘r’)
q=fp.readline()
I have tried it within a program main.py, but it doesn’t work like this.
ciruitpython restricts this feature to prevent file system errors, which means you can’t have files in main.py.
I have my xiao connected via usb to an rpi. With ‘print’ you can write to a file on the rpi via the usb. Is there a way to read files on the rpi into the program main.py via usb then?
You should be able to read files the rpi is writing to from CircuitPython. Just beware that Linux may buffer writes so they won’t be immediately available. CircuitPython only limits writing from both places.
If you want to commands from the rpi to CircuitPython, then you can do input()
in main.py
to get serial input from the Pi.