def open(self): self.fd = os.open(self.port, os.O_RDWR | os.O_NOCTTY) termios.setraw(self.fd) iflag, oflag, cflag, lflag, ispeed, ospeed, cc = termios.tcgetattr(self.fd) #print("tcgetattr result:", iflag, oflag, cflag, lflag, ispeed, ospeed, cc) baudrate = self.BAUD_MAP[self.baudrate] termios.tcsetattr(self.fd, termios.TCSANOW, [iflag, oflag, cflag, lflag, baudrate, baudrate, cc])
def open(self): self.fd = os.open(self.port, os.O_RDWR | os.O_NOCTTY) termios.setraw(self.fd) iflag, oflag, cflag, lflag, ispeed, ospeed, cc = termios.tcgetattr(self.fd) #print("tcgetattr result:", iflag, oflag, cflag, lflag, ispeed, ospeed, cc) baudrate = self.BAUD_MAP[self.baudrate] termios.tcsetattr(self.fd, termios.TCSANOW, [iflag, oflag, cflag, lflag, baudrate, baudrate, cc]) self.poller = uselect.poll() self.poller.register(self.fd, uselect.POLLIN | uselect.POLLHUP)
def open(self): self.fd = os.open(self.port, os.O_RDWR | os.O_NOCTTY) termios.setraw(self.fd) iflag, oflag, cflag, lflag, ispeed, ospeed, cc = termios.tcgetattr( self.fd) baudrate = self.BAUD_MAP[self.baudrate] termios.tcsetattr(self.fd, termios.TCSANOW, [iflag, oflag, cflag, lflag, baudrate, baudrate, cc]) self.poller = uselect.poll() self.poller.register(self.fd, uselect.POLLIN | uselect.POLLHUP)
def begin(self): self.tattr = termios.tcgetattr(sys.stdin.fileno()) if IS_UPY: termios.setraw(sys.stdin.fileno()) else: tty.setcbreak(sys.stdin.fileno(), termios.TCSANOW)
# up to some version lacked it. #grantpt = libc.func("i", "grantpt", "i") unlockpt = libc.func("i", "unlockpt", "i") ptsname = libc.func("s", "ptsname", "i") fd_m = getpt() #assert grantpt(fd_m) == 0 assert unlockpt(fd_m) == 0 slave_tty = ptsname(fd_m) print("Connecting using pty:", slave_tty) pid = os.fork() if pid: term_state = termios.tcgetattr(0) termios.setraw(0) poll = select.poll() poll.register(0, select.POLLIN) poll.register(fd_m, select.POLLIN) quit = False try: while not quit: res = poll.poll() #print(res) for fd, event in res: if fd == 0: data = os.read(0, 64) os.write(fd_m, data) else: