The only tricky bit was figuring out I needed to append '\r' to all commands sent, but not to the user/pwd.
This could be _much_ prettier, but it should give the idea. I save a file, run this script on my box and it sends it over and runs the tests remotely putting the REPL output back into my console :-
Code: Select all
gedge:ulcd dgs$ cat test.py
#!/usr/bin/env python
import pexpect,sys
pexpect.run('sitecopy -u wipy')
a=pexpect.spawn('telnet 192.168.1.1')
a.logfile=sys.stdout
a.expect('Login as:')
a.sendline('micro')
a.expect('assword:')
a.sendline('python')
a.expect('>>>')
a.sendcontrol('d')
a.expect('>>>')
a.sendline('import ulcd\r')
a.expect('>>>')
a.sendline('ulcd.lcd(debugLCD=True).test()\r')
a.expect('>>>')
gedge:ulcd dgs$ ./test.py
Trying 192.168.1.1...
Connected to 192.168.1.1.
Escape character is '^]'.
MicroPython v1.5-94-gae58035 on 2015-11-07; WiPy with CC3200
Login as: micro
micro
Password: python
Login succeeded!
Type "help()" for more information.
>>>
PYB: soft reboot
MicroPython v1.5-94-gae58035 on 2015-11-07; WiPy with CC3200
Type "help()" for more information.
>>> import ulcd
import ulcd
>>> ulcd.lcd(debugLCD=True).test()
ulcd.lcd(debugLCD=True).test()
begin(2,16)
display
clear
backlight
setBacklight(255)
backlightPin(3,0)
setBacklight(1)
home
write(Hello World!)
>>> gedge:ulcd dgs$
Regards,
David