Browse Source

Fix hang on killing keyboard_teleop

pull/58/head
Binit Shah 2 years ago
parent
commit
b3db7eff6c
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

@ -13,9 +13,13 @@ def getch():
# fd, as follows: [iflag, oflag, cflag, lflag, ispeed, ospeed, cc]"
# from https://docs.python.org/2/library/termios.html
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
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:
termios.tcsetattr(stdin_fd, termios.TCSAFLUSH, new_tty_attributes)
ch1 = sys.stdin.read(1)

Loading…
Cancel
Save