Python termios.TCIFLUSH Examples

The following are 11 code examples of termios.TCIFLUSH(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module termios , or try the search function .
Example #1
Source File: serialposix.py    From ddt4all with GNU General Public License v3.0 5 votes vote down vote up
def reset_input_buffer(self):
        """Clear input buffer, discarding all that is in the buffer."""
        if not self.is_open:
            raise portNotOpenError
        termios.tcflush(self.fd, termios.TCIFLUSH) 
Example #2
Source File: serialposix.py    From android3dblendermouse with Apache License 2.0 5 votes vote down vote up
def reset_input_buffer(self):
        """Clear input buffer, discarding all that is in the buffer."""
        if not self.is_open:
            raise portNotOpenError
        termios.tcflush(self.fd, termios.TCIFLUSH) 
Example #3
Source File: __init__.py    From enlighten with Mozilla Public License 2.0 5 votes vote down vote up
def clear(self):
        termios.tcflush(self.stdread, termios.TCIFLUSH) 
Example #4
Source File: randpool.py    From python-for-android with Apache License 2.0 5 votes vote down vote up
def getch(self):
                termios.tcflush(0, termios.TCIFLUSH) # XXX Leave this in?
                return os.read(self._fd, 1) 
Example #5
Source File: randpool.py    From python-for-android with Apache License 2.0 5 votes vote down vote up
def close(self, delay = 0):
                if delay:
                    time.sleep(delay)
                    termios.tcflush(self._fd, termios.TCIFLUSH)
                termios.tcsetattr(self._fd, termios.TCSAFLUSH, self._old) 
Example #6
Source File: randpool.py    From python-for-android with Apache License 2.0 5 votes vote down vote up
def getch(self):
                termios.tcflush(0, termios.TCIFLUSH) # XXX Leave this in?
                return os.read(self._fd, 1) 
Example #7
Source File: randpool.py    From python-for-android with Apache License 2.0 5 votes vote down vote up
def close(self, delay = 0):
                if delay:
                    time.sleep(delay)
                    termios.tcflush(self._fd, termios.TCIFLUSH)
                termios.tcsetattr(self._fd, termios.TCSAFLUSH, self._old) 
Example #8
Source File: randpool.py    From python-for-android with Apache License 2.0 5 votes vote down vote up
def getch(self):
                termios.tcflush(0, termios.TCIFLUSH) # XXX Leave this in?
                return os.read(self._fd, 1) 
Example #9
Source File: serialposix.py    From android_universal with MIT License 5 votes vote down vote up
def reset_input_buffer(self):
        """Clear input buffer, discarding all that is in the buffer."""
        if not self.is_open:
            raise portNotOpenError
        termios.tcflush(self.fd, termios.TCIFLUSH) 
Example #10
Source File: runner.py    From Smart-Traffic-Signals-in-India-using-Deep-Reinforcement-Learning-and-Advanced-Computer-Vision with MIT License 4 votes vote down vote up
def run():
    """execute the TraCI control loop"""
    step = 0
    
    traci.trafficlight.setPhase("0", 0)
    while traci.simulation.getMinExpectedNumber() > 0:
        
        traci.simulationStep()
        # timeout = 0.2
        # print("Time right now - ",step)
        # rlist, wlist, xlist = select([sys.stdin],[],[],timeout)

        # if rlist:
        #     print("Key pressed - ")
        #     print(rlist)
        #     traci.vehicle.addFull(vehID='left_'+str(step),routeID='r0',typeID='car',depart='triggered',departLane='random',departPos='random')
        #     termios.tcflush(sys.stdin,termios.TCIFLUSH)

        key = stdscr.getch()
        stdscr.addch(20,25,key)
        stdscr.refresh()

        if key == curses.KEY_RIGHT: 
            stdscr.addstr(2, 20, "Up")
            traci.vehicle.addFull(vehID='right_'+str(step),routeID='r0',typeID='car',depart='triggered',departLane='random',departPos='random')

        elif key == curses.KEY_DOWN: 
            stdscr.addstr(3, 20, "Down")
            traci.vehicle.addFull(vehID='down_'+str(step),routeID='r3',typeID='car',depart='triggered',departLane='random',departPos='random')

        elif key == curses.KEY_LEFT: 
            stdscr.addstr(4, 20, "Left")
            traci.vehicle.addFull(vehID='left_'+str(step),routeID='r6',typeID='car',depart='triggered',departLane='random',departPos='random')

        elif key == curses.KEY_UP: 
            stdscr.addstr(5, 20, "Up")
            traci.vehicle.addFull(vehID='up_'+str(step),routeID='r9',typeID='car',depart='triggered',departLane='random',departPos='random')

        step += 1
    curses.endwin()
    traci.close()
    sys.stdout.flush() 
Example #11
Source File: runner.py    From Smart-Traffic-Signals-in-India-using-Deep-Reinforcement-Learning-and-Advanced-Computer-Vision with MIT License 4 votes vote down vote up
def run(self):
        import traci
        """execute the TraCI control loop"""
        step = 0
        phase = 0
        states = [0,1,2,3,4,5,6,7]
        traci.trafficlight.setPhase("0", 0)
        while traci.simulation.getMinExpectedNumber() > 0:
            
            traci.simulationStep()
            
            action = random.choice(states)
            traci.trafficlight.setPhase("0", action)
            phase = traci.trafficlight.getPhase("0")
            #print(phase)
            # timeout = 0.2
            # print("Time right now - ",step)
            # rlist, wlist, xlist = select([sys.stdin],[],[],timeout)

            # if rlist:
            #     print("Key pressed - ")
            #     print(rlist)
            #     traci.vehicle.addFull(vehID='left_'+str(step),routeID='r0',typeID='car',depart='triggered',departLane='random',departPos='random')
            #     termios.tcflush(sys.stdin,termios.TCIFLUSH)
            '''
            key = fstdscr.getch()
            stdscr.addch(20,25,key)
            stdscr.refresh()

            if key == curses.KEY_RIGHT: 
                stdscr.addstr(2, 20, "Up")
                traci.vehicle.addFull(vehID='right_'+str(step),routeID='r0',typeID='car',depart='triggered',departLane='random',departPos='random')

            elif key == curses.KEY_DOWN: 
                stdscr.addstr(3, 20, "Down")
                traci.vehicle.addFull(vehID='down_'+str(step),routeID='r3',typeID='car',depart='triggered',departLane='random',departPos='random')

            elif key == curses.KEY_LEFT: 
                stdscr.addstr(4, 20, "Left")
                traci.vehicle.addFull(vehID='left_'+str(step),routeID='r6',typeID='car',depart='triggered',departLane='random',departPos='random')

            elif key == curses.KEY_UP: 
                stdscr.addstr(5, 20, "Up")
                traci.vehicle.addFull(vehID='up_'+str(step),routeID='r9',typeID='car',depart='triggered',departLane='random',departPos='random')
               ''' 

            step += 1
        #.curses.endwin()
        traci.close()
        sys.stdout.flush()