Browse Source

Fix hang on killing keyboard_teleop

pull/62/head
Binit Shah 2 years ago
parent
commit
2ad9707c38
1 changed files with 5 additions and 1 deletions
  1. +5
    -1
      stretch_core/nodes/keyboard.py

+ 5
- 1
stretch_core/nodes/keyboard.py View File

@ -15,9 +15,13 @@ def getch():
# fd, as follows: [iflag, oflag, cflag, lflag, ispeed, ospeed, cc]" # fd, as follows: [iflag, oflag, cflag, lflag, ispeed, ospeed, cc]"
# from https://docs.python.org/2/library/termios.html # from https://docs.python.org/2/library/termios.html
original_tty_attributes = termios.tcgetattr(stdin_fd) original_tty_attributes = termios.tcgetattr(stdin_fd)
new_tty_attributes = original_tty_attributes[:]
new_tty_attributes = termios.tcgetattr(stdin_fd)
# Change the lflag (local modes) to turn off canonical mode # Change the lflag (local modes) to turn off canonical mode
new_tty_attributes[3] &= ~termios.ICANON new_tty_attributes[3] &= ~termios.ICANON
# Set VMIN = 0 and VTIME > 0 for a timed read, as explained in:
# http://unixwiz.net/techtips/termios-vmin-vtime.html
new_tty_attributes[6][termios.VMIN] = b'\x00'
new_tty_attributes[6][termios.VTIME] = b'\x01'
try: try:
termios.tcsetattr(stdin_fd, termios.TCSAFLUSH, new_tty_attributes) termios.tcsetattr(stdin_fd, termios.TCSAFLUSH, new_tty_attributes)
ch1 = sys.stdin.read(1) ch1 = sys.stdin.read(1)

Loading…
Cancel
Save