From 5f92abd07815ca52c84bfec12d0906975b6ac586 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 14 Mar 2019 13:03:47 -0400 Subject: [PATCH] Have autocons auto-react to SOL connect When connecting, DCD indicates the activity. Use DCD to commence/discontinue the SOL console. --- xCAT-genesis-scripts/usr/bin/autocons.py | 40 +++++++++++++++++++++--- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/xCAT-genesis-scripts/usr/bin/autocons.py b/xCAT-genesis-scripts/usr/bin/autocons.py index 66d50d159..4b6555a0d 100644 --- a/xCAT-genesis-scripts/usr/bin/autocons.py +++ b/xCAT-genesis-scripts/usr/bin/autocons.py @@ -1,6 +1,10 @@ +import fcntl import os +import signal import struct +import subprocess import termios +import time addrtoname = { 0x3f8: '/dev/ttyS0', @@ -46,13 +50,41 @@ def do_serial_config(): currattr = termios.tcgetattr(ttyf) currattr[4:6] = [0, termiobaud[retval['speed']]] termios.tcsetattr(ttyf, termios.TCSANOW, currattr) + retval['connected'] = bool(struct.unpack(' {0} >&0 2>&1'.format(serialinfo['tty'])) - + running = False + while True: + if running and running.poll() is not None: + running = False + if running and not is_connected(serialinfo['tty']): + try: + running.terminate() + running.wait() + except Exception: + pass + time.sleep(0.5) + running = subprocess.Popen(['/bin/sh', '-c', 'exec screen -x console <> {0} >&0 2>&1'.format(serialinfo['tty'])]) + time.sleep(0.5) + try: + running.terminate() + running.wait() + except Exception: + pass + running = False + elif not running and is_connected(serialinfo['tty']): + running = subprocess.Popen(['/bin/sh', '-c', 'exec screen -x console <> {0} >&0 2>&1'.format(serialinfo['tty'])]) + time.sleep(0.5)