Ejemplo n.º 1
0
 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])
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
 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)
Ejemplo n.º 5
0
# 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: