python类TCSAFLUSH的实例源码

miniterm.py 文件源码 项目:driveboardapp 作者: nortd 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def cleanup(self):
            if self.old is not None:
                termios.tcsetattr(self.fd, termios.TCSAFLUSH, self.old)
keyboard_detection.py 文件源码 项目:Halite 作者: shummie 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __exit__(self, type, value, traceback):
        # swith to normal terminal
        termios.tcsetattr(self.fd, termios.TCSAFLUSH, self.old_term)
haps_boot.py 文件源码 项目:bootrom-tools 作者: MotorolaMobilityLLC 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
def run(self):
        if os.name != "posix":
            raise ValueError("Can only be run on Posix systems")
            return

        buffer = ""
        # While PySerial would be preferable and more machine-independant,
        # it does not support echo suppression
        with open(self.dbgser_tty_name, 'r+') as dbgser:
            # Config the debug serial port
            oldattrs = termios.tcgetattr(dbgser)
            newattrs = termios.tcgetattr(dbgser)
            newattrs[4] = termios.B115200  # ispeed
            newattrs[5] = termios.B115200  # ospeed
            newattrs[3] = newattrs[3] & ~termios.ICANON & ~termios.ECHO
            newattrs[6][termios.VMIN] = 0
            newattrs[6][termios.VTIME] = 10
            termios.tcsetattr(dbgser, termios.TCSANOW, newattrs)

            # As long as we weren't asked to stop, try to capture dbgserial
            # output and push each line up the result queue.
            try:
                while not self.stoprequest.isSet():
                    ch = dbgser.read(1)
                    if ch:
                        if ch == "\n":
                            # Push the line (sans newline) into our queue
                            # and clear the buffer for the next line.
                            self.result_q.put(buffer)
                            buffer = ""
                        elif ch != "\r":
                            buffer += ch
            except IOError:
                pass
            finally:
                # Restore previous settings
                termios.tcsetattr(dbgser, termios.TCSAFLUSH, oldattrs)
                # Flush any partial buffer
                if buffer:
                    self.result_q.put(buffer)
KeyPoller.py 文件源码 项目:vrptw-pgss-2016 作者: conwayje 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __exit__(self, type, value, traceback):
        if isWindows:
            pass
        else:
            termios.tcsetattr(self.fd, termios.TCSAFLUSH, self.old_term)
kbhit.py 文件源码 项目:overhead_mobile_tracker 作者: NU-MSR 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def set_normal_term(self):
        ''' Resets to normal terminal.  On Windows this is a no-op.
        '''

        if os.name == 'nt':
            pass

        else:
            termios.tcsetattr(self.fd, termios.TCSAFLUSH, self.old_term)
miniterm.py 文件源码 项目:mb_sdcard 作者: whaleygeek 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def cleanup(self):
            if self.old is not None:
                termios.tcsetattr(self.fd, termios.TCSAFLUSH, self.old)
miniterm.py 文件源码 项目:ddt4all 作者: cedricp 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def cleanup(self):
            termios.tcsetattr(self.fd, termios.TCSAFLUSH, self.old)
kbhit.py 文件源码 项目:RobotControl 作者: vdwel 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def set_normal_term(self):
        ''' Resets to normal terminal.  On Windows this is a no-op.
        '''

        if os.name == 'nt':
            pass

        else:
            termios.tcsetattr(self.fd, termios.TCSAFLUSH, self.old_term)
keyboard_detection.py 文件源码 项目:HaliteBot 作者: jheilema-nerdery 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __enter__(self):
        # save the terminal settings
        self.fd = sys.stdin.fileno()
        self.new_term = termios.tcgetattr(self.fd)
        self.old_term = termios.tcgetattr(self.fd)

        # new terminal setting unbuffered
        self.new_term[3] = (self.new_term[3] & ~termios.ICANON & ~termios.ECHO)     

        # switch to unbuffered terminal
        termios.tcsetattr(self.fd, termios.TCSAFLUSH, self.new_term)

        return self.query_keyboard
keyboard_detection.py 文件源码 项目:HaliteBot 作者: jheilema-nerdery 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def __exit__(self, type, value, traceback):
        # swith to normal terminal
        termios.tcsetattr(self.fd, termios.TCSAFLUSH, self.old_term)
kbhit.py 文件源码 项目:speech_ml 作者: coopie 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def set_normal_term(self):
        ''' Resets to normal terminal.  On Windows this is a no-op.
        '''
        if os.name == 'nt':
            pass
        else:
            termios.tcsetattr(self.fd, termios.TCSAFLUSH, self.old_term)
miniterm.py 文件源码 项目:mt7687-serial-uploader 作者: will127534 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def cleanup(self):
            termios.tcsetattr(self.fd, termios.TCSAFLUSH, self.old)
miniterm.py 文件源码 项目:get_started_with_respeaker 作者: respeaker 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def cleanup(self):
            termios.tcsetattr(self.fd, termios.TCSAFLUSH, self.old)
vminute.py 文件源码 项目:5minute 作者: SatelliteQE 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def warning(message, answer=None):
    """
    Print warning message into srdErr and may can for answer
    :param message: message
    :param answer: list of supported options. Default is first item.
    """
    c = ""
    if sys.stderr.isatty():
        sys.stderr.write("\n\x1b[92;01m%s " % message)
    else:
        sys.stderr.write("\n%s " % message)
    if answer:
        fd = sys.stdin.fileno()
        oldterm = termios.tcgetattr(fd)
        newattr = termios.tcgetattr(fd)
        newattr[3] = newattr[3] & ~termios.ICANON & ~termios.ECHO
        termios.tcsetattr(fd, termios.TCSANOW, newattr)
        oldflags = fcntl.fcntl(fd, fcntl.F_GETFL)
        fcntl.fcntl(fd, fcntl.F_SETFL, oldflags | os.O_NONBLOCK)
        try:
            while 1:
                try:
                    c = sys.stdin.read(1)
                    break
                except IOError:
                    pass
        finally:
            termios.tcsetattr(fd, termios.TCSAFLUSH, oldterm)
            fcntl.fcntl(fd, fcntl.F_SETFL, oldflags)
        c = ("%s" % c).lower()
    if sys.stderr.isatty():
        sys.stderr.write(" %s\x1b[39;49;00m\n\n" % c)
    else:
        sys.stderr.write(" %s\n\n" % c)
    if answer:
        for it in answer:
            if c in it:
                return c
        return answer.pop(0)
miniterm.py 文件源码 项目:Jackal_Velodyne_Duke 作者: MengGuo 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def cleanup(self):
            termios.tcsetattr(self.fd, termios.TCSAFLUSH, self.old)
miniterm.py 文件源码 项目:Jackal_Velodyne_Duke 作者: MengGuo 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def cleanup(self):
            termios.tcsetattr(self.fd, termios.TCSAFLUSH, self.old)
miniterm.py 文件源码 项目:Jackal_Velodyne_Duke 作者: MengGuo 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def cleanup(self):
            termios.tcsetattr(self.fd, termios.TCSAFLUSH, self.old)
kbhit.py 文件源码 项目:kimhun_rl_windows 作者: nalsil 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def set_normal_term(self):
        ''' Resets to normal terminal.  On Windows this is a no-op.
        '''

        if os.name == 'nt':
            pass

        else:
            termios.tcsetattr(self.fd, termios.TCSAFLUSH, self.old_term)
miniterm.py 文件源码 项目:btc-fpga-miner 作者: marsohod4you 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def cleanup(self):
            termios.tcsetattr(self.fd, termios.TCSAFLUSH, self.old)
miniterm.py 文件源码 项目:btc-fpga-miner 作者: marsohod4you 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def cleanup(self):
            termios.tcsetattr(self.fd, termios.TCSAFLUSH, self.old)


问题


面经


文章

微信
公众号

扫码关注公众号