From 1849815e6a7658520651b663295e64e051fa9159 Mon Sep 17 00:00:00 2001 From: Lars Brinkhoff Date: Thu, 13 Jun 2024 12:50:32 +0200 Subject: [PATCH] tmp --- build/mchn/PT/pidp10.screen | 4 +++ build/mchn/PT/pidp10.sh | 70 ++++++++++++++++++++++++++++--------- build/mchn/PT/run | 2 +- build/pdp10-ka/start | 5 ++- 4 files changed, 62 insertions(+), 19 deletions(-) diff --git a/build/mchn/PT/pidp10.screen b/build/mchn/PT/pidp10.screen index 1948ffa3..de9e9b50 100644 --- a/build/mchn/PT/pidp10.screen +++ b/build/mchn/PT/pidp10.screen @@ -1,3 +1,7 @@ +bell_msg "" +msgminwait 0 +msgwait 1 + # Make F9 the new command key. bindkey -k k9 command escape "" diff --git a/build/mchn/PT/pidp10.sh b/build/mchn/PT/pidp10.sh index cbca7717..e0050bb8 100755 --- a/build/mchn/PT/pidp10.sh +++ b/build/mchn/PT/pidp10.sh @@ -9,6 +9,8 @@ # Short-Description: PiDP-10 emulator ### END INIT INFO +verbose=message + HOME="/home/lars/src/its2" MCHN="$HOME/build/mchn/PT" TOOLS="$HOME/tools" @@ -17,16 +19,24 @@ PID="$HOME/pidp10.pid" action="$1" -fail() { +message() { echo "$1" 1>&2 +} + +fail() { + message "$1" exit 1 } expect() { text="$1" + timeout="${2:-10}" + i=0 while :; do - grep -q "$text" "$LOG" && return - sleep 0.5 + grep -q "$text" "$LOG" && return 0 + i=`expr $i + 1` + test $i -ge $timeout && return 1 + sleep 1 done } @@ -42,11 +52,13 @@ case "$action" in status) status_screen || fail "PiDP-10 is down." status_emulator || fail "PiDP-10 is down." - echo "PiDP-10 is up." 1>&2 + message "PiDP-10 is up." ;; start) cd "$HOME" + $verbose "Starting PiDP-10 screen." screen -c "$MCHN/pidp10.screen" -dmS pidp10 + $verbose "Starting DSKDMP." screen -S pidp10 -X logfile flush 1 screen -S pidp10 -X select 0 screen -S pidp10 -X title "SIMH control console" @@ -56,13 +68,30 @@ case "$action" in screen -S pidp10 -X logfile "$LOG" screen -S pidp10 -X log on screen -S pidp10 -X title "KA10 console teletype" - expect "DSKDMP" - screen -S pidp10 -X log off - rm -f "$LOG" - screen -S pidp10 -X logfile "$HOME/ka10.log" - screen -S pidp10 -X log on - screen -S pidp10 -X stuff "ITS\r" - screen -S pidp10 -X stuff "\033G" + if expect "DSKDMP"; then + $verbose "Starting ITS." + screen -S pidp10 -X stuff "ITS\r" + screen -S pidp10 -X stuff "\033G" + if expect "IN OPERATION" 20; then + $verbose "ITS in operation." + screen -S pidp10 -X log off + rm -f "$LOG" + screen -S pidp10 -X log on + screen -S pidp10 -X logfile "$HOME/ka10.log" + exit 0 + else + fail "ITS failed to start." + fi + else + fail "DSKDMP not started." + fi + + # Something failed, shut everything down. + if status_emulator; then + kill `cat "$PID"` 2>/dev/null; sleep 1 + status_emulator && kill -9 `cat $PID` 2>/dev/null + fi + screen -S pidp10 -X quit ;; stop) cd "$HOME" @@ -71,25 +100,32 @@ case "$action" in screen -S pidp10 -X select 1 screen -S pidp10 -X logfile "$LOG" screen -S pidp10 -X log on + $verbose "Shutting down ITS." "$TOOLS/chaosnet-tools/shutdown" its - expect "NOT IN OPERATION" - expect "SHUTDOWN COMPLETE" + expect "NOT IN OPERATION" || fail "ITS failed to shut down." + $verbose "ITS not in operation." + expect "SHUTDOWN COMPLETE" 60 || fail "ITS failed to shut down." + $verbose "ITS shutdown complete." screen -S pidp10 -X log off rm -f "$LOG" - screen -S pidp10 -p0 -X stuff "\034"; sleep 1 - screen -S pidp10 -p0 -X stuff "quit\r"; sleep 1 - screen -S pidp10 -X quit + $verbose "Quitting KA10 emulator." + screen -S pidp10 -X select 0 + screen -S pidp10 -X stuff "\034"; sleep 1 + screen -S pidp10 -X stuff "quit\r"; sleep 1 if status_emulator; then + $verbose "Emulator still running; forcibly killing it." kill `cat "$PID"` 2>/dev/null; sleep 1 status_emulator && kill -9 `cat $PID` 2>/dev/null fi rm -f "$PID" + $verbose "Stopping PiDP-10 screen." + screen -S pidp10 -X quit ;; restart) $MCHN/pidp10.sh stop $MCHN/pidp10.sh start ;; *) - echo "Unknown action: $action" 1>&2 + message "Unknown action: $action" ;; esac diff --git a/build/mchn/PT/run b/build/mchn/PT/run index 77a59785..486404ad 100644 --- a/build/mchn/PT/run +++ b/build/mchn/PT/run @@ -1,4 +1,4 @@ -set console wru=034 +#set console wru=034 set cpu its set cpu 1024k set cpu idle diff --git a/build/pdp10-ka/start b/build/pdp10-ka/start index bab0a125..cc91e90f 100755 --- a/build/pdp10-ka/start +++ b/build/pdp10-ka/start @@ -112,4 +112,7 @@ while test -n "$1"; do done tools/sims/BIN/pdp10-ka out/pdp10-ka/run -exit 0 +#pid=$! +#echo $pid > pidp10.pid +#wait $pid +#exit 0