Example #1
0
	def startIO(self):
		fdin = sys.stdin.fileno()
		fdout = sys.stdout.fileno()
		termios.tcflow(fdin, termios.TCION)
		termios.tcflush(fdin, termios.TCIFLUSH)
		termios.tcflush(fdout, termios.TCOFLUSH)
		termios.tcflow(fdout, termios.TCOON)
 def flowControl(self, enable):
     """manually control flow - when hardware or software flow control is
     enabled"""
     if enable:
         termios.tcflow(self.fd, TERMIOS.TCION)
     else:
         termios.tcflow(self.fd, TERMIOS.TCIOFF)
Example #3
0
 def flowControl(self, enable):
     """manually control flow - when hardware or software flow control is
     enabled"""
     if enable:
         termios.tcflow(self.fd, TERMIOS.TCION)
     else:
         termios.tcflow(self.fd, TERMIOS.TCIOFF)
Example #4
0
def set_term_input(enabled):
    if enabled:
        set_term_echo(sys.stdin, True)                   # Turn echo on
        termios.tcflow(sys.stdin, termios.TCION)         # Resume input
        termios.tcflush(sys.stdin, termios.TCIOFLUSH)    # Flush queued data
    else:
        set_term_echo(sys.stdin, False)                  # Turn echo off
        termios.tcflow(sys.stdin, termios.TCIOFF)        # Suspend input
 def flowControl(self, enable):
     """manually control flow - when hardware or software flow control is
     enabled"""
     if not self._isOpen: raise portNotOpenError
     if enable:
         termios.tcflow(self.fd, TERMIOS.TCION)
     else:
         termios.tcflow(self.fd, TERMIOS.TCIOFF)
Example #6
0
def set_term_input(enabled):
    if enabled:
        set_term_echo(sys.stdin, True)  # Turn echo on
        termios.tcflow(sys.stdin, termios.TCION)  # Resume input
        termios.tcflush(sys.stdin, termios.TCIOFLUSH)  # Flush queued data
    else:
        set_term_echo(sys.stdin, False)  # Turn echo off
        termios.tcflow(sys.stdin, termios.TCIOFF)  # Suspend input
 def flowControl(self, enable):
     """manually control flow - when hardware or software flow control is
     enabled"""
     if not self._isOpen: raise portNotOpenError
     if enable:
         termios.tcflow(self.fd, TERMIOS.TCION)
     else:
         termios.tcflow(self.fd, TERMIOS.TCIOFF)
Example #8
0
 def on(self):
     if self.fd:
         try:
             termios.tcflow(self.fd, termios.TCOON)
         except:
             pass
         try:
             termios.tcflow(self.fd, termios.TCION)
         except:
             pass
         self.is_on = True
 def flowControlOut(self, enable):
     """\
     Manually control flow of outgoing data - when hardware or software flow
     control is enabled.
     WARNING: this function is not portable to different platforms!
     """
     if not self._isOpen: raise portNotOpenError
     if enable:
         termios.tcflow(self.fd, TERMIOS.TCOON)
     else:
         termios.tcflow(self.fd, TERMIOS.TCOOFF)
Example #10
0
 def on(self):
     if self.fd:
         try:
             termios.tcflow(self.fd, termios.TCOON)
         except:
             pass
         try:
             termios.tcflow(self.fd, termios.TCION)
         except:
             pass
         self.is_on = True
 def setXON(self, level=True):
     """\
     Manually control flow - when software flow control is enabled.
     This will send XON (true) and XOFF (false) to the other device.
     WARNING: this function is not portable to different platforms!
     """
     if not self.hComPort: raise portNotOpenError
     if enable:
         termios.tcflow(self.fd, TERMIOS.TCION)
     else:
         termios.tcflow(self.fd, TERMIOS.TCIOFF)
Example #12
0
 def off(self):
     if self.fd:
         try:
             termios.tcflow(self.fd, termios.TCOOFF)
         except:
             pass
         try:
             termios.tcflow(self.fd, termios.TCIOFF)
         except:
             pass
         self.is_on = False
Example #13
0
 def off(self):
     if self.fd:
         try:
             termios.tcflow(self.fd, termios.TCOOFF)
         except:
             pass
         try:
             termios.tcflow(self.fd, termios.TCIOFF)
         except:
             pass
         self.is_on = False
Example #14
0
 def set_output_flow_control(self, enable=True):
     """\
     Manually control flow of outgoing data - when hardware or software flow
     control is enabled.
     WARNING: this function is not portable to different platforms!
     """
     if not self.is_open:
         raise portNotOpenError
     if enable:
         termios.tcflow(self.fd, termios.TCOON)
     else:
         termios.tcflow(self.fd, termios.TCOOFF)
Example #15
0
 def set_input_flow_control(self, enable=True):
     """\
     Manually control flow - when software flow control is enabled.
     This will send XON (true) or XOFF (false) to the other device.
     WARNING: this function is not portable to different platforms!
     """
     if not self.is_open:
         raise portNotOpenError
     if enable:
         termios.tcflow(self.fd, termios.TCION)
     else:
         termios.tcflow(self.fd, termios.TCIOFF)
Example #16
0
 def set_output_flow_control(self, enable=True):
     """\
     Manually control flow of outgoing data - when hardware or software flow
     control is enabled.
     WARNING: this function is not portable to different platforms!
     """
     if not self.is_open:
         raise portNotOpenError
     if enable:
         termios.tcflow(self.fd, termios.TCOON)
     else:
         termios.tcflow(self.fd, termios.TCOOFF)
Example #17
0
 def set_input_flow_control(self, enable=True):
     """\
     Manually control flow - when software flow control is enabled.
     This will send XON (true) or XOFF (false) to the other device.
     WARNING: this function is not portable to different platforms!
     """
     if not self.is_open:
         raise portNotOpenError
     if enable:
         termios.tcflow(self.fd, termios.TCION)
     else:
         termios.tcflow(self.fd, termios.TCIOFF)
Example #18
0
 def runs_tcall():
     termios.tcsendbreak(2, 0)
     termios.tcdrain(2)
     termios.tcflush(2, termios.TCIOFLUSH)
     termios.tcflow(2, termios.TCOON)
Example #19
0
 def xon(self, argv):
     #fcntl.ioctl(self.master, termios.TIOCSTART, 0)
     termios.tcflow(self.master, termios.TCOON)
Example #20
0
 def accept(self):
     '''accept new chars'''
     termios.tcflush(self.fd, termios.TCIFLUSH)
     termios.tcflow(self.fd, termios.TCION)
Example #21
0
 def accept(self):
   '''accept new chars'''
   termios.tcflush(self.fd, termios.TCIFLUSH)
   termios.tcflow(self.fd,termios.TCION)
Example #22
0
def tcflow(space, w_fd, action):
    fd = space.c_filedescriptor_w(w_fd)
    try:
        termios.tcflow(fd, action)
    except OSError, e:
        raise convert_error(space, e)
Example #23
0
def tcflow(space, fd, action):
    try:
        termios.tcflow(fd, action)
    except termios.error, e:
        e.errno = e.args[0]
        raise convert_error(space, e)
Example #24
0
File: tff.py Project: lurdan/tff
 def xoff(self):
     #fcntl.ioctl(self._master, termios.TIOCSTOP, 0)
     termios.tcflow(self._master, termios.TCOOFF)
Example #25
0
 def TerminalReadLine(prompt=''):
     old = termios.tcgetattr(0)
     new = list(old)
     new[6] = list(new[6])  # Copy sublist.
     #print 'READLINE', prompt
     new[3] &= ~termios.ECHO  # [2] is c_lflag
     new[3] &= ~termios.ICANON  # [3] is c_lflag
     #new[6][termios.VMIN] = '\0'  # !! VMIN -- no effect below, affects only blocking / nonblocking reads
     termios.tcsetattr(0, termios.TCSANOW, new)
     BlockingWriteAll(out_fd, prompt)
     global just_after_prompt
     just_after_prompt = (out_fd, prompt)
     try:
         while not xin.wait_for_readable():
             pass
     finally:
         just_after_prompt = False
     # Is this the correct way to disable new input while we're examining the
     # existing input?
     termios.tcflow(in_fd, termios.TCIOFF)
     nread = struct.unpack('i',
                           fcntl.ioctl(in_fd, termios.FIONREAD,
                                       packed_i))[0]
     # We read more than 1 character here so that we can push all characters in
     # an escape sequence back.
     got = xin.read_at_most(nread)
     if got in ('\r', '\n'):  # Helps GNU libreadline a bit.
         BlockingWriteAll(out_fd, '\n')
         return ''
     if '\x04' in got:  # Got EOF (isn't handled well here by readline).
         new[3] |= termios.ECHO  # [2] is c_lflag; this is needed by readline.so
         new[3] |= termios.ICANON  # [2] is c_lflag; superfluous
         termios.tcsetattr(0, termios.TCSANOW, new)
         for c in got:
             fcntl.ioctl(in_fd, termios.TIOCSTI, c)
         termios.tcflow(in_fd, termios.TCION)
         raise EOFError
     prompt_width = GetPromptWidth(prompt)
     if 'readline' in sys.modules:  # raw_input() is GNU libreadline.
         WritePromptToNextLine(out_fd, '', prompt_width)
         new[3] |= termios.ICANON  # [2] is c_lflag; superfluous
         termios.tcsetattr(0, termios.TCSANOW, new)
         for c in got:
             fcntl.ioctl(in_fd, termios.TIOCSTI, c)
         new[3] |= termios.ECHO  # [2] is c_lflag; this is needed by readline.so
         termios.tcsetattr(0, termios.TCSANOW, new)
         termios.tcflow(in_fd, termios.TCION)
         # The disadvantage of the GNU libreadline implementation of
         # raw_input() here is that coroutines are not scheduled while readline
         # is reading the prompt (the non-first character).
         try:
             return raw_input(prompt)
         finally:
             termios.tcsetattr(in_fd, termios.TCSANOW, old)
     else:
         WritePromptToNextLine(out_fd, prompt, prompt_width)
         new[3] |= termios.ECHO  # [2] is c_lflag; this is needed by readline.so
         new[3] |= termios.ICANON  # [2] is c_lflag; superfluous
         termios.tcsetattr(0, termios.TCSANOW, new)
         for c in got:
             fcntl.ioctl(in_fd, termios.TIOCSTI, c)
         termios.tcflow(in_fd, termios.TCION)
         if False:
             # Coroutines are scheduled in xin.readline(), so this would be
             # incompatible with raw_input() above.
             try:
                 line = xin.readline()
             finally:
                 termios.tcsetattr(in_fd, termios.TCSANOW, old)
             if line:
                 return line.rstrip('\n')
             raise EOFError
         line = array.array('c')  # TODO(pts): Use a byte arra
         while True:
             # Do a blocking read on purpose, so other tasklets are suspended until
             # the user finishes typing the command.
             try:
                 c = os.read(in_fd, 1)  # Don't read past the first '\n'.
             except OSError, e:
                 if e.errno != errno.EAGAIN:
                     raise
                 select.select([in_fd], (), ())
                 continue
             if not c:
                 if line:
                     return line.tostring()  # Without the terminating '\n'.
                 else:
                     raise EOFError
             if c in ('\r', '\n'):
                 return line.tostring()
             line.append(c)
Example #26
0
File: tff.py Project: lurdan/tff
 def xon(self):
     #fcntl.ioctl(self._master, termios.TIOCSTART, 0)
     termios.tcflow(self._master, termios.TCOON)
Example #27
0
	def stopIO(self):
		fdin = sys.stdin.fileno()
		fdout = sys.stdout.fileno()
		termios.tcflow(fdout, termios.TCOOFF)
		termios.tcflow(fdin, termios.TCIOFF)
Example #28
0
 def wait(self):
   '''do not accept new characters'''
   termios.tcflow(self.fd,termios.TCIOFF)
Example #29
0
 def xoff(self, argv):
     #fcntl.ioctl(self.master, termios.TIOCSTOP, 0)
     termios.tcflow(self.master, termios.TCOOFF)
Example #30
0
 def wait(self):
     '''do not accept new characters'''
     termios.tcflow(self.fd, termios.TCIOFF)
Example #31
0
def tcflow(space, fd, action):
    try:
        termios.tcflow(fd, action)
    except OSError, e:
        raise convert_error(space, e)
Example #32
0
 def runs_tcall():
     termios.tcsendbreak(2, 0)
     termios.tcdrain(2)
     termios.tcflush(2, termios.TCIOFLUSH)
     termios.tcflow(2, termios.TCOON)
Example #33
0
def tcflow(space, w_fd, action):
    fd = space.c_filedescriptor_w(w_fd)
    try:
        termios.tcflow(fd, action)
    except OSError, e:
        raise convert_error(space, e)
Example #34
0
 def TerminalReadLine(prompt=''):
   old = termios.tcgetattr(0)
   new = list(old)
   new[6] = list(new[6])  # Copy sublist.
   #print 'READLINE', prompt
   new[3] &= ~termios.ECHO  # [2] is c_lflag
   new[3] &= ~termios.ICANON  # [3] is c_lflag
   #new[6][termios.VMIN] = '\0'  # !! VMIN -- no effect below, affects only blocking / nonblocking reads
   termios.tcsetattr(0, termios.TCSANOW, new)
   BlockingWriteAll(out_fd, prompt)
   global just_after_prompt
   just_after_prompt = (out_fd, prompt)
   try:
     while not xin.wait_for_readable():
       pass
   finally:
     just_after_prompt = False
   # Is this the correct way to disable new input while we're examining the
   # existing input?
   termios.tcflow(in_fd, termios.TCIOFF)
   nread = struct.unpack('i', fcntl.ioctl(
       in_fd, termios.FIONREAD, packed_i))[0]
   # We read more than 1 character here so that we can push all characters in
   # an escape sequence back.
   got = xin.read_at_most(nread)
   if got in ('\r', '\n'):  # Helps GNU libreadline a bit.
     BlockingWriteAll(out_fd, '\n')
     return ''
   if '\x04' in got:  # Got EOF (isn't handled well here by readline).
     new[3] |= termios.ECHO  # [2] is c_lflag; this is needed by readline.so
     new[3] |= termios.ICANON  # [2] is c_lflag; superfluous
     termios.tcsetattr(0, termios.TCSANOW, new)
     for c in got:
       fcntl.ioctl(in_fd, termios.TIOCSTI, c)
     termios.tcflow(in_fd, termios.TCION)
     raise EOFError
   prompt_width = GetPromptWidth(prompt)
   if 'readline' in sys.modules:  # raw_input() is GNU libreadline.
     WritePromptToNextLine(out_fd, '', prompt_width)
     new[3] |= termios.ICANON  # [2] is c_lflag; superfluous
     termios.tcsetattr(0, termios.TCSANOW, new)
     for c in got:
       fcntl.ioctl(in_fd, termios.TIOCSTI, c)
     new[3] |= termios.ECHO  # [2] is c_lflag; this is needed by readline.so
     termios.tcsetattr(0, termios.TCSANOW, new)
     termios.tcflow(in_fd, termios.TCION)
     # The disadvantage of the GNU libreadline implementation of
     # raw_input() here is that coroutines are not scheduled while readline
     # is reading the prompt (the non-first character).
     try:
       return raw_input(prompt)
     finally:
       termios.tcsetattr(in_fd, termios.TCSANOW, old)
   else:
     WritePromptToNextLine(out_fd, prompt, prompt_width)
     new[3] |= termios.ECHO  # [2] is c_lflag; this is needed by readline.so
     new[3] |= termios.ICANON  # [2] is c_lflag; superfluous
     termios.tcsetattr(0, termios.TCSANOW, new)
     for c in got:
       fcntl.ioctl(in_fd, termios.TIOCSTI, c)
     termios.tcflow(in_fd, termios.TCION)
     if False:
       # Coroutines are scheduled in xin.readline(), so this would be
       # incompatible with raw_input() above.
       try:
         line = xin.readline()
       finally:
         termios.tcsetattr(in_fd, termios.TCSANOW, old)
       if line:
         return line.rstrip('\n')
       raise EOFError
     line = array.array('c')  # TODO(pts): Use a byte arra
     while True:
       # Do a blocking read on purpose, so other tasklets are suspended until
       # the user finishes typing the command.
       try:
         c = os.read(in_fd, 1)  # Don't read past the first '\n'.
       except OSError, e:
         if e.errno != errno.EAGAIN:
           raise
         select.select([in_fd], (), ())
         continue
       if not c:
         if line:
           return line.tostring()  # Without the terminating '\n'.
         else:
           raise EOFError
       if c in ('\r', '\n'):
         return line.tostring()
       line.append(c)
Example #35
0
def ttySuspendInput(ttyfile):
    termios.tcflow(ttyfile.fileno(), termios.TCIOFF)
    try:
        yield
    finally:
        termios.tcflow(ttyfile.fileno(), termios.TCION)