當前位置: 首頁>>代碼示例>>Python>>正文


Python termios.VMIN屬性代碼示例

本文整理匯總了Python中termios.VMIN屬性的典型用法代碼示例。如果您正苦於以下問題:Python termios.VMIN屬性的具體用法?Python termios.VMIN怎麽用?Python termios.VMIN使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在termios的用法示例。


在下文中一共展示了termios.VMIN屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: init

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import VMIN [as 別名]
def init():
    if os.name == 'posix':
        global old
        old = termios.tcgetattr(fd)
        new = termios.tcgetattr(fd)
        new[3] = new[3] & ~termios.ICANON & ~termios.ECHO
        new[6][termios.VMIN] = 1
        new[6][termios.VTIME] = 0

        # -- Cambiar los atributos
        termios.tcsetattr(fd, termios.TCSANOW, new)

        # -- Restaurar el terminal a la salida
        atexit.register(cleanup_console)
    pass


# -------------------------------------
# Pequena prueba del modulo
# ------------------------------------- 
開發者ID:Obijuan,項目名稱:simplez-fpga,代碼行數:22,代碼來源:consola_io.py

示例2: _set_vmin

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import VMIN [as 別名]
def _set_vmin(self, vmin):
        if not isinstance(vmin, int):
            raise TypeError("Invalid vmin type, should be integer.")
        elif not (0 <= vmin <= 255):
            raise ValueError("Invalid vmin, can be 0 to 255.")

        try:
            iflag, oflag, cflag, lflag, ispeed, ospeed, cc = termios.tcgetattr(self._fd)
        except termios.error as e:
            raise SerialError(e.errno, "Setting serial port attributes: " + e.strerror)

        cc[termios.VMIN] = vmin

        try:
            termios.tcsetattr(self._fd, termios.TCSANOW, [iflag, oflag, cflag, lflag, ispeed, ospeed, cc])
        except termios.error as e:
            raise SerialError(e.errno, "Setting serial port attributes: " + e.strerror)

        self._use_termios_timeout = vmin > 0 
開發者ID:vsergeev,項目名稱:python-periphery,代碼行數:21,代碼來源:serial.py

示例3: initialise

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import VMIN [as 別名]
def initialise(self):
        if not self.enabled:
            return
        if termios is None:
            self.enabled = False
            return
        try:
            self.tty = open("/dev/tty", "w+")
            os.tcgetpgrp(self.tty.fileno())
            self.clean_tcattr = termios.tcgetattr(self.tty)
            iflag, oflag, cflag, lflag, ispeed, ospeed, cc = self.clean_tcattr
            new_lflag = lflag & (0xffffffff ^ termios.ICANON)
            new_cc = cc[:]
            new_cc[termios.VMIN] = 0
            self.cbreak_tcattr = [
                iflag, oflag, cflag, new_lflag, ispeed, ospeed, new_cc]
        except Exception:
            self.enabled = False
            return 
開發者ID:pnprog,項目名稱:goreviewpartner,代碼行數:21,代碼來源:terminal_input.py

示例4: getch

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import VMIN [as 別名]
def getch():
        """getch function
        """
        fd = sys.stdin.fileno()
        old = termios.tcgetattr(fd)
        new = termios.tcgetattr(fd)
        new[3] = new[3] & ~termios.ICANON & ~termios.ECHO
        new[6][termios.VMIN] = 1
        new[6][termios.VTIME] = 0
        termios.tcsetattr(fd, termios.TCSANOW, new)
        key = None
        try:
            key = os.read(fd, 80)
        finally:
            termios.tcsetattr(fd, termios.TCSAFLUSH, old)
        return key 
開發者ID:mysql,項目名稱:mysql-utilities,代碼行數:18,代碼來源:console.py

示例5: getch

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import VMIN [as 別名]
def getch():
        """Make a get character keyboard method for Posix machines.
        """
        fd = sys.stdin.fileno()
        old = termios.tcgetattr(fd)
        new = termios.tcgetattr(fd)
        new[3] = new[3] & ~termios.ICANON & ~termios.ECHO
        new[6][termios.VMIN] = 1
        new[6][termios.VTIME] = 0
        termios.tcsetattr(fd, termios.TCSANOW, new)
        key = None
        try:
            key = os.read(fd, 4)
        finally:
            termios.tcsetattr(fd, termios.TCSAFLUSH, old)
        return key 
開發者ID:mysql,項目名稱:mysql-utilities,代碼行數:18,代碼來源:failover_console.py

示例6: __enter__

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import VMIN [as 別名]
def __enter__(self) -> None:
        # NOTE: On os X systems, using pty.setraw() fails. Therefor we are using this:
        try:
            newattr = termios.tcgetattr(self.fileno)
        except termios.error:
            pass
        else:
            newattr[tty.LFLAG] = self._patch_lflag(newattr[tty.LFLAG])
            newattr[tty.IFLAG] = self._patch_iflag(newattr[tty.IFLAG])

            # VMIN defines the number of characters read at a time in
            # non-canonical mode. It seems to default to 1 on Linux, but on
            # Solaris and derived operating systems it defaults to 4. (This is
            # because the VMIN slot is the same as the VEOF slot, which
            # defaults to ASCII EOT = Ctrl-D = 4.)
            newattr[tty.CC][termios.VMIN] = 1  # type: ignore

            termios.tcsetattr(self.fileno, termios.TCSANOW, newattr)

            # Put the terminal in cursor mode. (Instead of application mode.)
            os.write(self.fileno, b"\x1b[?1l") 
開發者ID:prompt-toolkit,項目名稱:python-prompt-toolkit,代碼行數:23,代碼來源:vt100.py

示例7: __enter__

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import VMIN [as 別名]
def __enter__(self):
        # NOTE: On os X systems, using pty.setraw() fails. Therefor we are using this:
        try:
            newattr = termios.tcgetattr(self.fileno)
        except termios.error:
            pass
        else:
            newattr[tty.LFLAG] = self._patch_lflag(newattr[tty.LFLAG])
            newattr[tty.IFLAG] = self._patch_iflag(newattr[tty.IFLAG])

            # VMIN defines the number of characters read at a time in
            # non-canonical mode. It seems to default to 1 on Linux, but on
            # Solaris and derived operating systems it defaults to 4. (This is
            # because the VMIN slot is the same as the VEOF slot, which
            # defaults to ASCII EOT = Ctrl-D = 4.)
            newattr[tty.CC][termios.VMIN] = 1

            termios.tcsetattr(self.fileno, termios.TCSANOW, newattr)

            # Put the terminal in cursor mode. (Instead of application mode.)
            os.write(self.fileno, b'\x1b[?1l') 
開發者ID:bkerler,項目名稱:android_universal,代碼行數:23,代碼來源:vt100_input.py

示例8: make_terminal_unbuffered

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import VMIN [as 別名]
def make_terminal_unbuffered():
    # Based on https://stackoverflow.com/questions/21791621/taking-input-from-sys-stdin-non-blocking
    # pylint:disable=global-statement
    global OLD_TERMINAL_SETTINGS
    OLD_TERMINAL_SETTINGS = termios.tcgetattr(sys.stdin)
    new_settings = termios.tcgetattr(sys.stdin)
    new_settings[3] = new_settings[3] & ~(termios.ECHO | termios.ICANON)
    new_settings[6][termios.VMIN] = 0
    new_settings[6][termios.VTIME] = 0
    termios.tcsetattr(sys.stdin, termios.TCSADRAIN, new_settings) 
開發者ID:brunorijsman,項目名稱:rift-python,代碼行數:12,代碼來源:engine.py

示例9: _get_vmin

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import VMIN [as 別名]
def _get_vmin(self):
        try:
            iflag, oflag, cflag, lflag, ispeed, ospeed, cc = termios.tcgetattr(self._fd)
        except termios.error as e:
            raise SerialError(e.errno, "Getting serial port attributes: " + e.strerror)

        return cc[termios.VMIN] 
開發者ID:vsergeev,項目名稱:python-periphery,代碼行數:9,代碼來源:serial.py

示例10: _reconfigure_port

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import VMIN [as 別名]
def _reconfigure_port(self, force_update=True):
        """Set communication parameters on opened port."""
        super(VTIMESerial, self)._reconfigure_port()
        fcntl.fcntl(self.fd, fcntl.F_SETFL, 0)  # clear O_NONBLOCK

        if self._inter_byte_timeout is not None:
            vmin = 1
            vtime = int(self._inter_byte_timeout * 10)
        elif self._timeout is None:
            vmin = 1
            vtime = 0
        else:
            vmin = 0
            vtime = int(self._timeout * 10)
        try:
            orig_attr = termios.tcgetattr(self.fd)
            iflag, oflag, cflag, lflag, ispeed, ospeed, cc = orig_attr
        except termios.error as msg:      # if a port is nonexistent but has a /dev file, it'll fail here
            raise serial.SerialException("Could not configure port: {}".format(msg))

        if vtime < 0 or vtime > 255:
            raise ValueError('Invalid vtime: {!r}'.format(vtime))
        cc[termios.VTIME] = vtime
        cc[termios.VMIN] = vmin

        termios.tcsetattr(
                self.fd,
                termios.TCSANOW,
                [iflag, oflag, cflag, lflag, ispeed, ospeed, cc]) 
開發者ID:cedricp,項目名稱:ddt4all,代碼行數:31,代碼來源:serialposix.py

示例11: setup

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import VMIN [as 別名]
def setup(self):
            new = termios.tcgetattr(self.fd)
            new[3] = new[3] & ~termios.ICANON & ~termios.ECHO & ~termios.ISIG
            new[6][termios.VMIN] = 1
            new[6][termios.VTIME] = 0
            termios.tcsetattr(self.fd, termios.TCSANOW, new) 
開發者ID:cedricp,項目名稱:ddt4all,代碼行數:8,代碼來源:miniterm.py

示例12: setup

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import VMIN [as 別名]
def setup(self):
            self.old = termios.tcgetattr(self.fd)
            new = termios.tcgetattr(self.fd)
            new[3] = new[3] & ~termios.ICANON & ~termios.ECHO & ~termios.ISIG
            new[6][termios.VMIN] = 1
            new[6][termios.VTIME] = 0
            termios.tcsetattr(self.fd, termios.TCSANOW, new) 
開發者ID:FSecureLABS,項目名稱:Jandroid,代碼行數:9,代碼來源:miniterm.py

示例13: prepare_tty

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import VMIN [as 別名]
def prepare_tty():                       
    "set the terminal in char mode (return each keyboard press at once) and"\
    " switch off echoing of this input; return the original settings"
    stdin_fd = sys.stdin.fileno()  # will most likely be 0  ;->
    old_stdin_config = termios.tcgetattr(stdin_fd)
    [ iflag, oflag, cflag, lflag, ispeed, ospeed, cc ] = \
        termios.tcgetattr(stdin_fd)
    cc[termios.VTIME] = 1
    cc[termios.VMIN] = 1
    iflag = iflag & ~(termios.IGNBRK |
                      termios.BRKINT |
                      termios.PARMRK |
                      termios.ISTRIP |
                      termios.INLCR |
                      termios.IGNCR |
                      #termios.ICRNL |
                      termios.IXON)
    #  oflag = oflag & ~termios.OPOST
    cflag = cflag | termios.CS8
    lflag = lflag & ~(termios.ECHO |
                      termios.ECHONL |
                      termios.ICANON |
                      # termios.ISIG |
                      termios.IEXTEN)
    termios.tcsetattr(stdin_fd, termios.TCSANOW,
                      [ iflag, oflag, cflag, lflag, ispeed, ospeed, cc ])
    return (stdin_fd, old_stdin_config) 
開發者ID:ActiveState,項目名稱:code,代碼行數:29,代碼來源:recipe-580680.py

示例14: _reconfigure_port

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import VMIN [as 別名]
def _reconfigure_port(self, force_update=True):
        """Set communication parameters on opened port."""
        super(VTIMESerial, self)._reconfigure_port()
        fcntl.fcntl(self.fd, fcntl.F_SETFL, 0) # clear O_NONBLOCK

        if self._inter_byte_timeout is not None:
            vmin = 1
            vtime = int(self._inter_byte_timeout * 10)
        else:
            vmin = 0
            vtime = int(self._timeout * 10)
        try:
            orig_attr = termios.tcgetattr(self.fd)
            iflag, oflag, cflag, lflag, ispeed, ospeed, cc = orig_attr
        except termios.error as msg:      # if a port is nonexistent but has a /dev file, it'll fail here
            raise serial.SerialException("Could not configure port: %s" % msg)

        if vtime < 0 or vtime > 255:
            raise ValueError('Invalid vtime: %r' % vtime)
        cc[termios.VTIME] = vtime
        cc[termios.VMIN] = vmin

        termios.tcsetattr(
                self.fd,
                termios.TCSANOW,
                [iflag, oflag, cflag, lflag, ispeed, ospeed, cc]) 
開發者ID:sketchpunk,項目名稱:android3dblendermouse,代碼行數:28,代碼來源:serialposix.py

示例15: _becomeLogSlave

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import VMIN [as 別名]
def _becomeLogSlave(self, slaveFd, loggerPid):
        """ hand over control of io to logging process, grab info
            from pseudo tty
        """
        self.loggerPid = loggerPid

        if self.withStdin and sys.stdin.isatty():
            self.oldTermios = termios.tcgetattr(sys.stdin.fileno())
        else:
            self.oldTermios = None

        newTermios = termios.tcgetattr(slaveFd)
        # Don't wait after receiving a character
        newTermios[6][termios.VTIME] = '\x00'
        # Read at least these many characters before returning
        newTermios[6][termios.VMIN] = '\x01'

        termios.tcsetattr(slaveFd, termios.TCSADRAIN, newTermios)
        # Raw mode
        tty.setraw(slaveFd)

        self.oldStderr = os.dup(sys.stderr.fileno())
        self.oldStdout = os.dup(sys.stdout.fileno())
        if self.withStdin:
            self.oldStdin = os.dup(sys.stdin.fileno())
            os.dup2(slaveFd, 0)
        else:
            self.oldStdin = sys.stdin.fileno()
        os.dup2(slaveFd, 1)
        os.dup2(slaveFd, 2)
        os.close(slaveFd)
        self.logging = True 
開發者ID:sassoftware,項目名稱:conary,代碼行數:34,代碼來源:logger.py


注:本文中的termios.VMIN屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。