stubber.tools.pyboard
¶
pyboard interface
This module provides the Pyboard class, used to communicate with and control a MicroPython device over a communication channel. Both real boards and emulated devices (e.g. running in QEMU) are supported. Various communication channels are supported, including a serial connection, telnet-style network connection, external process connection.
Example usage:
import pyboard pyb = pyboard.Pyboard(‘/dev/ttyACM0’)
Or:
pyb = pyboard.Pyboard(‘192.168.1.1’)
Then:
pyb.enter_raw_repl() pyb.exec(‘import pyb’) pyb.exec(‘pyb.LED(1).on()’) pyb.exit_raw_repl()
Note: if using Python2 then pyb.exec must be written as pyb.exec_. To run a script from the local machine on the board and print out the results:
import pyboard pyboard.execfile(‘test.py’, device=’/dev/ttyACM0’)
This script can also be run directly. To execute a local script, use:
./pyboard.py test.py
Or:
python pyboard.py test.py
Module Contents¶
Classes¶
Execute a process and emulate serial connection using its stdin/stdout. |
|
Execute a process which creates a PTY and prints slave PTY as |
|
Functions¶
|
|
|
|
|
Attributes¶
- stubber.tools.pyboard.stdout¶
- stubber.tools.pyboard.stdout_write_bytes(b)¶
- exception stubber.tools.pyboard.PyboardError¶
Bases:
Exception
Common base class for all non-exit exceptions.
- class stubber.tools.pyboard.TelnetToSerial(ip, user, password, read_timeout=None)¶
- __del__()¶
- close()¶
- read(size=1)¶
- write(data)¶
- inWaiting()¶
- class stubber.tools.pyboard.ProcessToSerial(cmd)¶
Execute a process and emulate serial connection using its stdin/stdout.
- close()¶
- read(size=1)¶
- write(data)¶
- inWaiting()¶
- class stubber.tools.pyboard.ProcessPtyToTerminal(cmd)¶
Execute a process which creates a PTY and prints slave PTY as first line of its output, and emulate serial connection using this PTY.
- close()¶
- read(size=1)¶
- write(data)¶
- inWaiting()¶
- class stubber.tools.pyboard.Pyboard(device, baudrate=115200, user='micro', password='python', wait=0, exclusive=True)¶
- close()¶
- read_until(min_num_bytes, ending, timeout=10, data_consumer=None)¶
- enter_raw_repl(soft_reset=True)¶
- exit_raw_repl()¶
- follow(timeout, data_consumer=None)¶
- raw_paste_write(command_bytes)¶
- exec_raw_no_follow(command)¶
- exec_raw(command, timeout=10, data_consumer=None)¶
- eval(expression)¶
- exec_(command, data_consumer=None)¶
- execfile(filename)¶
- get_time()¶
- fs_ls(src)¶
- fs_cat(src, chunk_size=256)¶
- fs_get(src, dest, chunk_size=256)¶
- fs_put(src, dest, chunk_size=256)¶
- fs_mkdir(dir)¶
- fs_rmdir(dir)¶
- fs_rm(src)¶
- stubber.tools.pyboard.execfile(filename, device='/dev/ttyACM0', baudrate=115200, user='micro', password='python')¶
- stubber.tools.pyboard.filesystem_command(pyb, args)¶
- stubber.tools.pyboard._injected_import_hook_code = Multiline-String¶
Show Value
1import uos, uio 2class _FS: 3 class File(uio.IOBase): 4 def __init__(self): 5 self.off = 0 6 def ioctl(self, request, arg): 7 return 0 8 def readinto(self, buf): 9 buf[:] = memoryview(_injected_buf)[self.off:self.off + len(buf)] 10 self.off += len(buf) 11 return len(buf) 12 mount = umount = chdir = lambda *args: None 13 def stat(self, path): 14 if path == '_injected.mpy': 15 return tuple(0 for _ in range(10)) 16 else: 17 raise OSError(-2) # ENOENT 18 def open(self, path, mode): 19 return self.File() 20uos.mount(_FS(), '/_') 21uos.chdir('/_') 22from _injected import * 23uos.umount('/_') 24del _injected_buf, _FS
- stubber.tools.pyboard.main()¶