def __init__(self, port = None, baudrate = 115200, read_timeout = 1.0, write_timeout = 0.1): """ Provides a serial-port back-end for the protocol. Timeouts are in seconds. """ BackEnd.__init__(self) self.name = "Serial" # Start the emulator as a child-process self.serial = Serial(port, baudrate = baudrate, timeout = read_timeout, writeTimeout = write_timeout)
def __init__(self, args): """ Starts the emulator specified in args as a sub-process. Args should be a valid shell command string. """ BackEnd.__init__(self) self.name = "Emulator" # Start the emulator as a child-process self.emulator = Popen(args, bufsize = -1, # Produce a fully-buffered set of pipes stdin = PIPE, # Source stdin from the protocol stdout = PIPE, # Supply stdout to the protocol stderr = None, # Stderr should not be redirected shell = True) # Execute in a shell