Initially this is just going to do some trivial stuff (e.g. execute some python), but once I get the basics sorted I'd like to make a tool that automates deploying and testing of code to the pyboard.
I was able to write a few bytes to the board (visible when I manually connect to the repl), but I was not able to actually execute a statement.
Can anybody see an error in my code?
Code: Select all
import logging
import serial
from contextlib import contextmanager
from fdpexpect import fdspawn
@contextmanager
def connect(port=r'/dev/ttyACM0'):
ser = serial.Serial(port, timeout=1)
yield fdspawn(ser)
ser.close()
log = logging.getLogger(__name__)
def main():
text = ["import pyb", "pyb.LED(1).on()"]
with connect() as ser:
for line in text:
ser.expect_exact('>>>', timeout=1)
ser.send("%s\n" % line)
if __name__ == '__main__':
logging.basicConfig()
main()