本文整理汇总了Python中termios.tcflow函数的典型用法代码示例。如果您正苦于以下问题:Python tcflow函数的具体用法?Python tcflow怎么用?Python tcflow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tcflow函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: flowControl
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)
示例2: startIO
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)
示例3: set_term_input
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
示例4: flowControl
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)
示例5: on
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
示例6: off
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
示例7: setXON
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)
示例8: flowControlOut
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)
示例9: set_input_flow_control
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)
示例10: set_output_flow_control
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)
示例11: TerminalReadLine
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)
示例12: stopIO
def stopIO(self):
fdin = sys.stdin.fileno()
fdout = sys.stdout.fileno()
termios.tcflow(fdout, termios.TCOOFF)
termios.tcflow(fdin, termios.TCIOFF)
示例13: tcflow
def tcflow(space, fd, action):
try:
termios.tcflow(fd, action)
except termios.error, e:
e.errno = e.args[0]
raise convert_error(space, e)
示例14: accept
def accept(self):
'''accept new chars'''
termios.tcflush(self.fd, termios.TCIFLUSH)
termios.tcflow(self.fd,termios.TCION)
示例15: wait
def wait(self):
'''do not accept new characters'''
termios.tcflow(self.fd,termios.TCIOFF)