def __init__(self, devspec, logfile=None, **kwargs): fo = tty.SerialPort(devspec.port) fo.set_serial(devspec.serial) self._timeout = devspec.get("timeout", 30.0) self._exp = expect.Expect(fo, prompt=devspec.prompt, timeout=self._timeout, logfile=logfile) self.Initialize(devspec, **kwargs)
def test_tty_SerialPort(self): # just call some setup methods. This really needs some serial # loopback to fully test. sp = tty.SerialPort("/dev/ttyS0") sp.set_serial("9600 8N1") sp.stty("-parenb", "-parodd", "cs8", "hupcl", "-cstopb", "cread", "clocal", "-crtscts", "ignbrk", "-brkint", "ignpar", "-parmrk", "-inpck", "-istrip", "-inlcr", "-igncr", "-icrnl", "-ixon", "-ixoff", "-iuclc", "-ixany", "-imaxbel", "-opost", "-olcuc", "-ocrnl", "onlcr", "-onocr", "-onlret", "-ofill", "-ofdel", "nl0", "cr0", "tab0", "bs0", "vt0", "ff0", "-isig", "-icanon", "-iexten", "-echo", "echoe", "echok", "-echonl", "-noflsh", "-xcase", "-tostop", "-echoprt", "echoctl", "echoke")
def __init__(self, devspec, logfile=None, **kwargs): self._handlers = {} self._context = {} self._inq = [] self._calls = {1: (ONHOOK, 0, 0)} self.calltype = None self.localhangup = None self.calls = 0 self._timeout = devspec.get("timeout", 30.0) # TODO(dart) not used yet self._port = tty.SerialPort(devspec.port, setup=devspec.serial) # stock handlers self._hanguphook = aid.NULL self._answerhook = aid.NULL self._callhook = aid.NULL self._ringhook = aid.NULL self._alerthook = aid.NULL self.AddHandler("OK", self._OKHandler) self.AddHandler("ERROR", self._ErrorHandler) self.AddHandler("NO CARRIER", self._NoCarrierHandler) self.AddHandler("RINGING", self._RingingHandler) self.Initialize(devspec, **kwargs)