0000: 23 21 2f 75 73 72 2f 62 69 6e 2f 65 6e 76 20 70 #!/usr/bin/env p
0010: 79 74 68 6f 6e 0a 23 20 2d 2a 2d 20 63 6f 64 69 ython.# -*- codi
0020: 6e 67 3a 20 75 74 66 2d 38 20 2d 2a 2d 0a 23 23 ng: utf-8 -*-.##
0030: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
0040: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
0050: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
0060: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
0070: 23 23 23 23 23 23 0a 23 20 73 69 6d 68 2f 5f 5f ######.# simh/__
0080: 69 6e 69 74 5f 5f 2e 70 79 20 2d 20 41 20 77 72 init__.py - A wr
0090: 61 70 70 65 72 20 63 6c 61 73 73 20 61 72 6f 75 apper class arou
00a0: 6e 64 20 70 65 78 70 65 63 74 20 66 6f 72 20 63 nd pexpect for c
00b0: 6f 6d 6d 75 6e 69 63 61 74 69 6e 67 0a 23 20 20 ommunicating.#
00c0: 20 77 69 74 68 20 61 6e 20 69 6e 73 74 61 6e 63 with an instanc
00d0: 65 20 6f 66 20 74 68 65 20 50 69 44 50 2d 38 2f e of the PiDP-8/
00e0: 49 20 53 49 4d 48 20 73 69 6d 75 6c 61 74 6f 72 I SIMH simulator
00f0: 20 72 75 6e 6e 69 6e 67 20 4f 53 2f 38 2e 0a 23 running OS/8..#
0100: 0a 23 20 20 20 53 65 65 20 2e 2e 2f 64 6f 63 2f .# See ../doc/
0110: 63 6c 61 73 73 2d 73 69 6d 68 2e 6d 64 20 66 6f class-simh.md fo
0120: 72 20 61 20 75 73 61 67 65 20 74 75 74 6f 72 69 r a usage tutori
0130: 61 6c 2e 0a 23 0a 23 20 43 6f 70 79 72 69 67 68 al..#.# Copyrigh
0140: 74 20 c2 a9 20 32 30 31 37 20 62 79 20 4a 6f 6e t © 2017 by Jon
0150: 61 74 68 61 6e 20 54 72 69 74 65 73 2c 20 c2 a9 athan Trites, ©
0160: 20 32 30 31 37 2d 32 30 31 39 20 62 79 20 57 69 2017-2019 by Wi
0170: 6c 6c 69 61 6d 20 43 61 74 74 65 79 0a 23 20 61 lliam Cattey.# a
0180: 6e 64 20 57 61 72 72 65 6e 20 59 6f 75 6e 67 2e nd Warren Young.
0190: 0a 23 0a 23 20 50 65 72 6d 69 73 73 69 6f 6e 20 .#.# Permission
01a0: 69 73 20 68 65 72 65 62 79 20 67 72 61 6e 74 65 is hereby grante
01b0: 64 2c 20 66 72 65 65 20 6f 66 20 63 68 61 72 67 d, free of charg
01c0: 65 2c 20 74 6f 20 61 6e 79 20 70 65 72 73 6f 6e e, to any person
01d0: 20 6f 62 74 61 69 6e 69 6e 67 0a 23 20 61 20 63 obtaining.# a c
01e0: 6f 70 79 20 6f 66 20 74 68 69 73 20 73 6f 66 74 opy of this soft
01f0: 77 61 72 65 20 61 6e 64 20 61 73 73 6f 63 69 61 ware and associa
0200: 74 65 64 20 64 6f 63 75 6d 65 6e 74 61 74 69 6f ted documentatio
0210: 6e 20 66 69 6c 65 73 20 28 74 68 65 0a 23 20 22 n files (the.# "
0220: 53 6f 66 74 77 61 72 65 22 29 2c 20 74 6f 20 64 Software"), to d
0230: 65 61 6c 20 69 6e 20 74 68 65 20 53 6f 66 74 77 eal in the Softw
0240: 61 72 65 20 77 69 74 68 6f 75 74 20 72 65 73 74 are without rest
0250: 72 69 63 74 69 6f 6e 2c 20 69 6e 63 6c 75 64 69 riction, includi
0260: 6e 67 0a 23 20 77 69 74 68 6f 75 74 20 6c 69 6d ng.# without lim
0270: 69 74 61 74 69 6f 6e 20 74 68 65 20 72 69 67 68 itation the righ
0280: 74 73 20 74 6f 20 75 73 65 2c 20 63 6f 70 79 2c ts to use, copy,
0290: 20 6d 6f 64 69 66 79 2c 20 6d 65 72 67 65 2c 20 modify, merge,
02a0: 70 75 62 6c 69 73 68 2c 0a 23 20 64 69 73 74 72 publish,.# distr
02b0: 69 62 75 74 65 2c 20 73 75 62 6c 69 63 65 6e 73 ibute, sublicens
02c0: 65 2c 20 61 6e 64 2f 6f 72 20 73 65 6c 6c 20 63 e, and/or sell c
02d0: 6f 70 69 65 73 20 6f 66 20 74 68 65 20 53 6f 66 opies of the Sof
02e0: 74 77 61 72 65 2c 20 61 6e 64 20 74 6f 0a 23 20 tware, and to.#
02f0: 70 65 72 6d 69 74 20 70 65 72 73 6f 6e 73 20 74 permit persons t
0300: 6f 20 77 68 6f 6d 20 74 68 65 20 53 6f 66 74 77 o whom the Softw
0310: 61 72 65 20 69 73 20 66 75 72 6e 69 73 68 65 64 are is furnished
0320: 20 74 6f 20 64 6f 20 73 6f 2c 20 73 75 62 6a 65 to do so, subje
0330: 63 74 20 74 6f 0a 23 20 74 68 65 20 66 6f 6c 6c ct to.# the foll
0340: 6f 77 69 6e 67 20 63 6f 6e 64 69 74 69 6f 6e 73 owing conditions
0350: 3a 0a 23 0a 23 20 54 68 65 20 61 62 6f 76 65 20 :.#.# The above
0360: 63 6f 70 79 72 69 67 68 74 20 6e 6f 74 69 63 65 copyright notice
0370: 20 61 6e 64 20 74 68 69 73 20 70 65 72 6d 69 73 and this permis
0380: 73 69 6f 6e 20 6e 6f 74 69 63 65 20 73 68 61 6c sion notice shal
0390: 6c 20 62 65 0a 23 20 69 6e 63 6c 75 64 65 64 20 l be.# included
03a0: 69 6e 20 61 6c 6c 20 63 6f 70 69 65 73 20 6f 72 in all copies or
03b0: 20 73 75 62 73 74 61 6e 74 69 61 6c 20 70 6f 72 substantial por
03c0: 74 69 6f 6e 73 20 6f 66 20 74 68 65 20 53 6f 66 tions of the Sof
03d0: 74 77 61 72 65 2e 0a 23 0a 23 20 54 48 45 20 53 tware..#.# THE S
03e0: 4f 46 54 57 41 52 45 20 49 53 20 50 52 4f 56 49 OFTWARE IS PROVI
03f0: 44 45 44 20 22 41 53 20 49 53 22 2c 20 57 49 54 DED "AS IS", WIT
0400: 48 4f 55 54 20 57 41 52 52 41 4e 54 59 20 4f 46 HOUT WARRANTY OF
0410: 20 41 4e 59 20 4b 49 4e 44 2c 0a 23 20 45 58 50 ANY KIND,.# EXP
0420: 52 45 53 53 20 4f 52 20 49 4d 50 4c 49 45 44 2c RESS OR IMPLIED,
0430: 20 49 4e 43 4c 55 44 49 4e 47 20 42 55 54 20 4e INCLUDING BUT N
0440: 4f 54 20 4c 49 4d 49 54 45 44 20 54 4f 20 54 48 OT LIMITED TO TH
0450: 45 20 57 41 52 52 41 4e 54 49 45 53 20 4f 46 0a E WARRANTIES OF.
0460: 23 20 4d 45 52 43 48 41 4e 54 41 42 49 4c 49 54 # MERCHANTABILIT
0470: 59 2c 20 46 49 54 4e 45 53 53 20 46 4f 52 20 41 Y, FITNESS FOR A
0480: 20 50 41 52 54 49 43 55 4c 41 52 20 50 55 52 50 PARTICULAR PURP
0490: 4f 53 45 20 41 4e 44 20 4e 4f 4e 49 4e 46 52 49 OSE AND NONINFRI
04a0: 4e 47 45 4d 45 4e 54 2e 0a 23 20 49 4e 20 4e 4f NGEMENT..# IN NO
04b0: 20 45 56 45 4e 54 20 53 48 41 4c 4c 20 54 48 45 EVENT SHALL THE
04c0: 20 41 55 54 48 4f 52 53 20 4c 49 53 54 45 44 20 AUTHORS LISTED
04d0: 41 42 4f 56 45 20 42 45 20 4c 49 41 42 4c 45 20 ABOVE BE LIABLE
04e0: 46 4f 52 20 41 4e 59 20 43 4c 41 49 4d 2c 0a 23 FOR ANY CLAIM,.#
04f0: 20 44 41 4d 41 47 45 53 20 4f 52 20 4f 54 48 45 DAMAGES OR OTHE
0500: 52 20 4c 49 41 42 49 4c 49 54 59 2c 20 57 48 45 R LIABILITY, WHE
0510: 54 48 45 52 20 49 4e 20 41 4e 20 41 43 54 49 4f THER IN AN ACTIO
0520: 4e 20 4f 46 20 43 4f 4e 54 52 41 43 54 2c 20 54 N OF CONTRACT, T
0530: 4f 52 54 0a 23 20 4f 52 20 4f 54 48 45 52 57 49 ORT.# OR OTHERWI
0540: 53 45 2c 20 41 52 49 53 49 4e 47 20 46 52 4f 4d SE, ARISING FROM
0550: 2c 20 4f 55 54 20 4f 46 20 4f 52 20 49 4e 20 43 , OUT OF OR IN C
0560: 4f 4e 4e 45 43 54 49 4f 4e 20 57 49 54 48 20 54 ONNECTION WITH T
0570: 48 45 20 53 4f 46 54 57 41 52 45 0a 23 20 4f 52 HE SOFTWARE.# OR
0580: 20 54 48 45 20 55 53 45 20 4f 52 20 4f 54 48 45 THE USE OR OTHE
0590: 52 20 44 45 41 4c 49 4e 47 53 20 49 4e 20 54 48 R DEALINGS IN TH
05a0: 45 20 53 4f 46 54 57 41 52 45 2e 0a 23 0a 23 20 E SOFTWARE..#.#
05b0: 45 78 63 65 70 74 20 61 73 20 63 6f 6e 74 61 69 Except as contai
05c0: 6e 65 64 20 69 6e 20 74 68 69 73 20 6e 6f 74 69 ned in this noti
05d0: 63 65 2c 20 74 68 65 20 6e 61 6d 65 73 20 6f 66 ce, the names of
05e0: 20 74 68 65 20 61 75 74 68 6f 72 73 20 61 62 6f the authors abo
05f0: 76 65 0a 23 20 73 68 61 6c 6c 20 6e 6f 74 20 62 ve.# shall not b
0600: 65 20 75 73 65 64 20 69 6e 20 61 64 76 65 72 74 e used in advert
0610: 69 73 69 6e 67 20 6f 72 20 6f 74 68 65 72 77 69 ising or otherwi
0620: 73 65 20 74 6f 20 70 72 6f 6d 6f 74 65 20 74 68 se to promote th
0630: 65 20 73 61 6c 65 2c 0a 23 20 75 73 65 20 6f 72 e sale,.# use or
0640: 20 6f 74 68 65 72 20 64 65 61 6c 69 6e 67 73 20 other dealings
0650: 69 6e 20 74 68 69 73 20 53 6f 66 74 77 61 72 65 in this Software
0660: 20 77 69 74 68 6f 75 74 20 70 72 69 6f 72 20 77 without prior w
0670: 72 69 74 74 65 6e 0a 23 20 61 75 74 68 6f 72 69 ritten.# authori
0680: 7a 61 74 69 6f 6e 20 66 72 6f 6d 20 74 68 6f 73 zation from thos
0690: 65 20 61 75 74 68 6f 72 73 2e 0a 23 23 23 23 23 e authors..#####
06a0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
06b0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
06c0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
06d0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
06e0: 23 23 23 0a 0a 69 6d 70 6f 72 74 20 6f 73 0a 69 ###..import os.i
06f0: 6d 70 6f 72 74 20 70 65 78 70 65 63 74 0a 69 6d mport pexpect.im
0700: 70 6f 72 74 20 70 6b 67 5f 72 65 73 6f 75 72 63 port pkg_resourc
0710: 65 73 0a 69 6d 70 6f 72 74 20 73 75 62 70 72 6f es.import subpro
0720: 63 65 73 73 0a 69 6d 70 6f 72 74 20 74 65 6d 70 cess.import temp
0730: 66 69 6c 65 0a 69 6d 70 6f 72 74 20 74 69 6d 65 file.import time
0740: 0a 69 6d 70 6f 72 74 20 72 65 0a 69 6d 70 6f 72 .import re.impor
0750: 74 20 73 79 73 0a 0a 69 6d 70 6f 72 74 20 70 69 t sys..import pi
0760: 64 70 38 69 0a 0a 63 6c 61 73 73 20 73 69 6d 68 dp8i..class simh
0770: 3a 20 0a 20 20 23 20 70 65 78 70 65 63 74 20 6f : . # pexpect o
0780: 62 6a 65 63 74 20 69 6e 73 74 61 6e 63 65 2c 20 bject instance,
0790: 73 65 74 20 62 79 20 63 74 6f 72 0a 20 20 5f 63 set by ctor. _c
07a0: 68 69 6c 64 20 3d 20 4e 6f 6e 65 0a 0a 20 20 23 hild = None.. #
07b0: 20 43 6f 6e 73 74 61 6e 74 20 75 73 65 64 20 62 Constant used b
07c0: 79 20 6f 73 38 5f 6b 62 64 5f 64 65 6c 61 79 2c y os8_kbd_delay,
07d0: 20 61 73 73 65 6d 62 6c 65 64 20 69 6e 20 73 74 assembled in st
07e0: 61 67 65 73 3a 0a 20 20 23 0a 20 20 23 20 31 2e ages:. #. # 1.
07f0: 20 50 44 50 2d 38 20 52 53 2d 32 33 32 20 62 69 PDP-8 RS-232 bi
0800: 74 73 20 70 65 72 20 63 68 61 72 61 63 74 65 72 ts per character
0810: 3a 20 37 2d 62 69 74 20 41 53 43 49 49 20 70 6c : 7-bit ASCII pl
0820: 75 73 20 6e 65 63 65 73 73 61 72 79 0a 20 20 23 us necessary. #
0830: 20 20 20 20 73 74 61 72 74 2c 20 73 74 6f 70 2c start, stop,
0840: 20 61 6e 64 20 70 61 72 69 74 79 20 62 69 74 73 and parity bits
0850: 2e 0a 20 20 23 0a 20 20 23 20 32 2e 20 54 68 65 .. #. # 2. The
0860: 20 72 61 74 69 6f 20 6f 66 20 74 68 65 20 69 6e ratio of the in
0870: 73 74 72 75 63 74 69 6f 6e 73 20 70 65 72 20 73 structions per s
0880: 65 63 6f 6e 64 20 72 61 74 69 6f 73 20 6f 66 20 econd ratios of
0890: 61 20 50 44 50 2d 38 2f 49 20 74 6f 0a 20 20 23 a PDP-8/I to. #
08a0: 20 20 20 20 74 68 61 74 20 6f 66 20 74 68 65 20 that of the
08b0: 68 6f 73 74 20 68 61 72 64 77 61 72 65 20 72 75 host hardware ru
08c0: 6e 6e 69 6e 67 20 74 68 65 20 73 69 6d 75 6c 61 nning the simula
08d0: 74 6f 72 2e 20 20 54 68 65 20 66 6f 72 6d 65 72 tor. The former
08e0: 20 69 73 0a 20 20 23 20 20 20 20 61 6e 20 61 70 is. # an ap
08f0: 70 72 6f 78 69 6d 61 74 65 20 76 61 6c 75 65 3b proximate value;
0900: 20 73 65 65 20 6c 69 62 2f 70 69 64 70 38 69 2f see lib/pidp8i/
0910: 69 70 73 2e 70 79 2e 69 6e 20 66 6f 72 20 74 68 ips.py.in for th
0920: 65 20 76 61 6c 75 65 20 61 6e 64 0a 20 20 23 20 e value and. #
0930: 20 20 20 69 74 73 20 64 65 66 65 6e 73 65 2e 20 its defense.
0940: 20 54 68 65 20 6c 61 74 74 65 72 20 69 73 20 65 The latter is e
0950: 69 74 68 65 72 20 74 68 65 20 49 50 53 20 72 61 ither the IPS ra
0960: 74 65 20 66 6f 72 3a 0a 20 20 23 0a 20 20 23 20 te for:. #. #
0970: 20 20 20 61 29 20 61 20 52 61 73 70 62 65 72 72 a) a Raspberr
0980: 79 20 50 69 20 4d 6f 64 65 6c 20 42 2b 2c 20 74 y Pi Model B+, t
0990: 68 61 74 20 62 65 69 6e 67 20 74 68 65 20 73 6c hat being the sl
09a0: 6f 77 65 73 74 20 68 6f 73 74 20 73 79 73 74 65 owest host syste
09b0: 6d 0a 20 20 23 20 20 20 20 20 20 20 77 65 20 72 m. # we r
09c0: 75 6e 20 74 68 69 73 20 73 69 6d 75 6c 61 74 6f un this simulato
09d0: 72 20 6f 6e 3b 20 6f 72 0a 20 20 23 0a 20 20 23 r on; or. #. #
09e0: 20 20 20 20 62 29 20 74 68 65 20 49 50 53 20 72 b) the IPS r
09f0: 61 74 65 20 6f 66 20 74 68 65 20 61 63 74 75 61 ate of the actua
0a00: 6c 20 68 6f 73 74 20 68 61 72 64 77 61 72 65 20 l host hardware
0a10: 69 66 20 79 6f 75 20 68 61 76 65 20 72 75 6e 20 if you have run
0a20: 74 68 65 0a 20 20 23 20 20 20 20 20 20 20 22 62 the. # "b
0a30: 69 6e 2f 74 65 63 6f 2d 70 69 2d 64 65 6d 6f 20 in/teco-pi-demo
0a40: 2d 62 22 20 62 65 6e 63 68 6d 61 72 6b 20 6f 6e -b" benchmark on
0a50: 20 69 74 2e 0a 20 20 23 0a 20 20 23 20 32 2e 20 it.. #. # 2.
0a60: 54 68 65 20 66 61 63 74 20 74 68 61 74 20 72 65 The fact that re
0a70: 61 6c 20 50 44 50 2d 38 73 20 72 61 6e 20 4f 53 al PDP-8s ran OS
0a80: 2f 38 20 72 65 6c 69 61 62 6c 79 20 61 74 20 33 /8 reliably at 3
0a90: 30 30 20 62 70 73 2c 20 61 6e 64 20 68 61 76 65 00 bps, and have
0aa0: 0a 20 20 23 20 20 20 20 62 65 65 6e 20 63 6c 61 . # been cla
0ab0: 69 6d 65 64 20 74 6f 20 67 65 74 20 66 6c 61 6b imed to get flak
0ac0: 79 20 61 73 20 65 61 72 6c 79 20 61 73 20 36 30 y as early as 60
0ad0: 30 20 62 70 73 20 62 79 20 73 6f 6d 65 2e 20 20 0 bps by some.
0ae0: 28 4f 74 68 65 72 73 0a 20 20 23 20 20 20 20 63 (Others. # c
0af0: 6c 61 69 6d 20 74 6f 20 68 61 76 65 20 72 75 6e laim to have run
0b00: 20 74 68 65 6d 20 75 70 20 74 6f 20 39 2c 36 30 them up to 9,60
0b10: 30 20 62 70 73 2e 29 0a 20 20 23 0a 20 20 23 20 0 bps.). #. #
0b20: 33 2e 20 54 68 65 20 22 73 61 66 65 20 42 50 53 3. The "safe BPS
0b30: 22 20 76 61 6c 75 65 20 69 73 20 74 68 65 20 66 " value is the f
0b40: 61 73 74 65 73 74 20 62 69 74 20 70 65 72 20 73 astest bit per s
0b50: 65 63 6f 6e 64 20 73 70 65 65 64 20 61 63 74 75 econd speed actu
0b60: 61 6c 0a 20 20 23 20 20 20 20 50 44 50 2d 38 20 al. # PDP-8
0b70: 68 61 72 64 77 61 72 65 20 77 61 73 20 6b 6e 6f hardware was kno
0b80: 77 6e 20 74 6f 20 72 75 6e 20 4f 53 2f 38 20 74 wn to run OS/8 t
0b90: 65 72 6d 69 6e 61 6c 20 49 2f 4f 20 61 74 2e 20 erminal I/O at.
0ba0: 20 49 6e 20 74 68 69 73 0a 20 20 23 20 20 20 20 In this. #
0bb0: 63 61 73 65 2c 20 69 74 20 69 73 20 74 68 65 20 case, it is the
0bc0: 68 69 67 68 2d 73 70 65 65 64 20 74 61 70 65 20 high-speed tape
0bd0: 72 65 61 64 65 72 2e 0a 20 20 23 0a 20 20 23 20 reader.. #. #
0be0: 20 20 20 54 4f 44 4f 3a 20 57 65 20 6d 61 79 20 TODO: We may
0bf0: 62 65 20 61 62 6c 65 20 74 6f 20 69 6e 63 72 65 be able to incre
0c00: 61 73 65 20 74 68 69 73 2e 0a 20 20 23 0a 20 20 ase this.. #.
0c10: 23 20 20 20 20 57 65 20 68 61 76 65 20 6f 6e 65 # We have one
0c20: 20 72 65 70 6f 72 74 20 74 68 61 74 20 4f 53 2f report that OS/
0c30: 38 20 77 61 73 20 74 65 73 74 65 64 20 77 69 74 8 was tested wit
0c40: 68 20 74 65 72 6d 69 6e 61 6c 73 20 75 70 20 74 h terminals up t
0c50: 6f 0a 20 20 23 20 20 20 20 61 62 6f 75 74 20 7e o. # about ~
0c60: 36 30 30 20 62 70 73 20 62 65 66 6f 72 65 20 62 600 bps before b
0c70: 65 63 6f 6d 69 6e 67 20 75 6e 72 65 6c 69 61 62 ecoming unreliab
0c80: 6c 65 2e 0a 20 20 23 0a 20 20 23 20 20 20 20 57 le.. #. # W
0c90: 65 20 68 61 76 65 20 61 6e 6f 74 68 65 72 20 72 e have another r
0ca0: 65 70 6f 72 74 20 74 68 61 74 20 4f 53 2f 38 20 eport that OS/8
0cb0: 63 6f 75 6c 64 20 72 75 6e 20 75 6e 64 65 72 20 could run under
0cc0: 45 54 4f 53 20 77 69 74 68 0a 20 20 23 20 20 20 ETOS with. #
0cd0: 20 39 2c 36 30 30 20 62 70 73 20 74 65 72 6d 69 9,600 bps termi
0ce0: 6e 61 6c 73 2c 20 62 75 74 20 77 65 20 64 6f 6e nals, but we don
0cf0: 27 74 20 6b 6e 6f 77 20 69 66 20 74 68 61 74 20 't know if that
0d00: 74 65 6c 6c 73 20 75 73 20 61 6e 79 74 68 69 6e tells us anythin
0d10: 67 0a 20 20 23 20 20 20 20 61 62 6f 75 74 20 4f g. # about O
0d20: 53 2f 38 20 72 75 6e 6e 69 6e 67 20 77 69 74 68 S/8 running with
0d30: 6f 75 74 20 74 68 65 20 45 54 4f 53 20 6d 75 6c out the ETOS mul
0d40: 74 69 74 61 73 6b 69 6e 67 20 68 61 72 64 77 61 titasking hardwa
0d50: 72 65 2e 0a 20 20 23 0a 20 20 23 20 34 2e 20 47 re.. #. # 4. G
0d60: 69 76 65 6e 20 61 62 6f 76 65 2c 20 63 61 6c 63 iven above, calc
0d70: 75 6c 61 74 65 20 73 61 66 65 20 63 68 61 72 61 ulate safe chara
0d80: 63 74 65 72 73 20 70 65 72 20 73 65 63 6f 6e 64 cters per second
0d90: 20 66 6f 72 20 68 6f 73 74 20 48 57 2e 0a 20 20 for host HW..
0da0: 23 0a 20 20 23 20 35 2e 20 49 6e 76 65 72 74 20 #. # 5. Invert
0db0: 74 6f 20 67 65 74 20 73 65 63 6f 6e 64 73 20 70 to get seconds p
0dc0: 65 72 20 63 68 61 72 61 63 74 65 72 2c 20 74 68 er character, th
0dd0: 61 74 20 62 65 69 6e 67 20 74 68 65 20 64 65 6c at being the del
0de0: 61 79 20 76 61 6c 75 65 2e 0a 20 20 5f 62 70 63 ay value.. _bpc
0df0: 20 3d 20 37 20 2b 20 31 20 2b 20 31 20 2b 20 31 = 7 + 1 + 1 + 1
0e00: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0e10: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0e20: 20 20 20 20 20 20 20 23 20 5b 31 5d 0a 20 20 5f # [1]. _
0e30: 69 70 73 5f 72 61 74 69 6f 20 3d 20 66 6c 6f 61 ips_ratio = floa
0e40: 74 20 28 70 69 64 70 38 69 2e 69 70 73 2e 63 75 t (pidp8i.ips.cu
0e50: 72 72 65 6e 74 29 20 2f 20 70 69 64 70 38 69 2e rrent) / pidp8i.
0e60: 69 70 73 2e 70 64 70 38 69 20 23 20 5b 32 5d 0a ips.pdp8i # [2].
0e70: 20 20 5f 70 64 70 38 69 5f 73 61 66 65 5f 62 70 _pdp8i_safe_bp
0e80: 73 20 3d 20 33 30 30 20 20 20 20 20 20 20 20 20 s = 300
0e90: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0ea0: 20 20 20 20 20 20 20 20 20 20 20 20 20 23 20 5b # [
0eb0: 33 5d 0a 20 20 5f 68 6f 73 74 5f 73 61 66 65 5f 3]. _host_safe_
0ec0: 63 70 73 20 3d 20 5f 70 64 70 38 69 5f 73 61 66 cps = _pdp8i_saf
0ed0: 65 5f 62 70 73 20 2a 20 5f 69 70 73 5f 72 61 74 e_bps * _ips_rat
0ee0: 69 6f 20 2f 20 5f 62 70 63 20 20 20 20 20 20 20 io / _bpc
0ef0: 23 20 5b 34 5d 0a 20 20 5f 6f 73 38 5f 6b 62 64 # [4]. _os8_kbd
0f00: 5f 64 65 6c 61 79 20 3d 20 31 20 2f 20 5f 68 6f _delay = 1 / _ho
0f10: 73 74 5f 73 61 66 65 5f 63 70 73 20 20 20 20 20 st_safe_cps
0f20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0f30: 20 20 20 23 20 5b 35 5d 0a 0a 20 20 23 20 4b 6e # [5].. # Kn
0f40: 6f 77 6e 20 4f 53 2f 38 20 65 72 72 6f 72 20 73 own OS/8 error s
0f50: 74 72 69 6e 67 73 20 61 6e 64 20 61 20 66 6c 61 trings and a fla
0f60: 67 20 69 6e 64 69 63 61 74 69 6e 67 20 77 68 65 g indicating whe
0f70: 74 68 65 72 20 74 68 65 20 65 72 72 6f 72 0a 20 ther the error.
0f80: 20 23 20 64 75 6d 70 73 20 75 73 20 62 61 63 6b # dumps us back
0f90: 20 6f 75 74 20 74 6f 20 74 68 65 20 4f 53 2f 38 out to the OS/8
0fa0: 20 63 6f 6d 6d 61 6e 64 20 6d 6f 6e 69 74 6f 72 command monitor
0fb0: 20 6f 72 20 6c 65 61 76 65 73 20 75 73 20 69 6e or leaves us in
0fc0: 20 74 68 65 0a 20 20 23 20 63 61 6c 6c 65 64 20 the. # called
0fd0: 70 72 6f 67 72 61 6d 2e 0a 0a 20 20 5f 6f 73 38 program... _os8
0fe0: 5f 65 72 72 6f 72 73 20 3d 20 5b 0a 20 20 20 20 _errors = [.
0ff0: 23 20 54 68 65 20 64 61 74 65 20 63 6f 6d 6d 65 # The date comme
1000: 6e 74 20 74 65 6c 6c 73 20 77 68 65 6e 20 65 61 nt tells when ea
1010: 63 68 20 6d 65 73 73 61 67 65 20 69 73 20 6f 62 ch message is ob
1020: 73 65 72 76 65 64 20 61 6e 64 20 76 61 6c 69 64 served and valid
1030: 61 74 65 64 0a 20 20 20 20 23 0a 20 20 20 20 23 ated. #. #
1040: 20 4f 53 2f 38 20 48 61 6e 64 62 6f 6f 6b 20 31 OS/8 Handbook 1
1050: 39 37 34 20 70 61 67 65 20 31 2d 34 33 2f 38 31 974 page 1-43/81
1060: 20 4b 65 79 62 6f 61 72 64 20 4d 6f 6e 69 74 6f Keyboard Monito
1070: 72 20 45 72 72 6f 72 20 4d 65 73 73 61 67 65 73 r Error Messages
1080: 3a 0a 20 20 20 20 5b 22 4d 4f 4e 49 54 4f 52 20 :. ["MONITOR
1090: 45 52 52 4f 52 20 32 20 41 54 20 5c 64 2b 20 5c ERROR 2 AT \d+ \
10a0: 5c 28 44 49 52 45 43 54 4f 52 59 20 49 2f 4f 20 \(DIRECTORY I/O
10b0: 45 52 52 4f 52 5c 5c 29 22 2c 20 54 72 75 65 5d ERROR\\)", True]
10c0: 2c 20 20 20 23 20 32 30 31 38 2e 30 32 2e 31 31 , # 2018.02.11
10d0: 0a 20 20 20 20 5b 22 4d 4f 4e 49 54 4f 52 20 45 . ["MONITOR E
10e0: 52 52 4f 52 20 35 20 41 54 20 5c 64 2b 20 5c 5c RROR 5 AT \d+ \\
10f0: 28 49 2f 4f 20 45 52 52 4f 52 20 4f 4e 20 53 59 (I/O ERROR ON SY
1100: 53 5c 5c 29 22 2c 20 54 72 75 65 5d 2c 0a 20 20 S\\)", True],.
1110: 20 20 5b 22 4d 4f 4e 49 54 4f 52 20 45 52 52 4f ["MONITOR ERRO
1120: 52 20 36 20 41 54 20 5c 64 2b 20 5c 5c 28 44 49 R 6 AT \d+ \\(DI
1130: 52 45 43 54 4f 52 59 20 49 2f 4f 20 45 52 52 4f RECTORY I/O ERRO
1140: 52 5c 5c 29 22 2c 20 54 72 75 65 5d 2c 0a 20 20 R\\)", True],.
1150: 20 20 5b 22 28 5c 53 2b 29 20 4e 4f 54 20 41 56 ["(\S+) NOT AV
1160: 41 49 4c 41 42 4c 45 22 2c 20 46 61 6c 73 65 5d AILABLE", False]
1170: 2c 0a 20 20 20 20 5b 22 28 5c 53 2b 29 20 4e 4f ,. ["(\S+) NO
1180: 54 20 46 4f 55 4e 44 22 2c 20 46 61 6c 73 65 5d T FOUND", False]
1190: 2c 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ,
11a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
11b0: 20 20 20 20 23 20 32 30 31 38 2e 30 32 2e 31 31 # 2018.02.11
11c0: 0a 20 20 20 20 23 20 4f 53 2f 38 20 48 61 6e 64 . # OS/8 Hand
11d0: 62 6f 6f 6b 20 31 39 37 34 20 70 61 67 65 20 31 book 1974 page 1
11e0: 2d 35 31 2f 38 39 20 43 6f 6d 6d 61 6e 64 20 44 -51/89 Command D
11f0: 65 63 6f 64 65 72 20 45 72 72 6f 72 20 4d 65 73 ecoder Error Mes
1200: 73 61 67 65 73 0a 20 20 20 20 5b 22 49 4c 4c 45 sages. ["ILLE
1210: 47 41 4c 20 53 59 4e 54 41 58 22 2c 20 46 61 6c GAL SYNTAX", Fal
1220: 73 65 5d 2c 20 20 20 20 20 20 20 20 20 20 20 20 se],
1230: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1240: 20 20 20 20 20 20 20 20 23 20 32 30 31 38 2e 30 # 2018.0
1250: 32 2e 31 31 0a 20 20 20 20 5b 22 28 5c 53 2b 29 2.11. ["(\S+)
1260: 20 44 4f 45 53 20 4e 4f 54 20 45 58 49 53 54 22 DOES NOT EXIST"
1270: 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 23 20 , False],. #
1280: 5b 22 28 5c 53 2b 29 20 4e 4f 54 20 46 4f 55 4e ["(\S+) NOT FOUN
1290: 44 22 2c 20 46 61 6c 73 65 5d 2c 20 20 20 20 20 D", False],
12a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
12b0: 20 20 20 20 20 20 20 20 20 20 20 20 23 20 53 65 # Se
12c0: 65 20 61 62 6f 76 65 0a 20 20 20 20 5b 22 54 4f e above. ["TO
12d0: 4f 20 4d 41 4e 59 20 46 49 4c 45 53 22 2c 20 46 O MANY FILES", F
12e0: 61 6c 73 65 5d 2c 0a 20 20 20 20 23 20 4f 53 2f alse],. # OS/
12f0: 38 20 48 61 6e 64 62 6f 6f 6b 20 31 39 37 34 20 8 Handbook 1974
1300: 70 61 67 65 20 31 2d 37 35 2f 31 31 33 20 43 43 page 1-75/113 CC
1310: 4c 20 45 72 72 6f 72 20 4d 65 73 73 61 67 65 73 L Error Messages
1320: 0a 20 20 20 20 5b 22 42 41 44 20 44 45 56 49 43 . ["BAD DEVIC
1330: 45 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 E", False],.
1340: 5b 22 42 41 44 20 45 58 54 45 4e 53 49 4f 4e 22 ["BAD EXTENSION"
1350: 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 23 20 , False],. #
1360: 4f 53 2f 38 20 48 61 6e 64 62 6f 6f 6b 20 31 39 OS/8 Handbook 19
1370: 37 34 20 70 61 67 65 20 31 2d 31 30 36 2f 31 34 74 page 1-106/14
1380: 34 20 50 49 50 20 45 72 72 6f 72 20 4d 65 73 73 4 PIP Error Mess
1390: 61 67 65 73 0a 20 20 20 20 5b 22 41 52 45 20 59 ages. ["ARE Y
13a0: 4f 55 20 53 55 52 45 22 2c 20 46 61 6c 73 65 5d OU SURE", False]
13b0: 2c 0a 20 20 20 20 5b 22 42 41 44 20 44 49 52 45 ,. ["BAD DIRE
13c0: 43 54 4f 52 59 20 4f 4e 20 44 45 56 49 43 45 20 CTORY ON DEVICE
13d0: 23 5c 73 3f 5c 64 2b 22 2c 20 46 61 6c 73 65 5d #\s?\d+", False]
13e0: 2c 0a 20 20 20 20 5b 22 42 41 44 20 53 59 53 54 ,. ["BAD SYST
13f0: 45 4d 20 48 45 41 44 22 2c 20 46 61 6c 73 65 5d EM HEAD", False]
1400: 2c 0a 20 20 20 20 5b 22 43 41 4e 27 54 20 4f 50 ,. ["CAN'T OP
1410: 45 4e 20 4f 55 54 50 55 54 20 46 49 4c 45 22 2c EN OUTPUT FILE",
1420: 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 5b 22 44 False],. ["D
1430: 45 56 49 43 45 20 23 5c 64 2b 20 4e 4f 54 20 41 EVICE #\d+ NOT A
1440: 20 44 49 52 45 43 54 4f 52 59 20 44 45 56 49 43 DIRECTORY DEVIC
1450: 45 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 E", False],.
1460: 5b 22 44 49 52 45 43 54 4f 52 59 20 45 52 52 4f ["DIRECTORY ERRO
1470: 52 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 R", False],.
1480: 5b 22 45 52 52 4f 52 20 44 45 4c 45 54 49 4e 47 ["ERROR DELETING
1490: 20 46 49 4c 45 22 2c 20 46 61 6c 73 65 5d 2c 0a FILE", False],.
14a0: 20 20 20 20 5b 22 49 4c 4c 45 47 49 41 4c 20 42 ["ILLEGIAL B
14b0: 49 4e 41 52 59 20 49 4e 50 55 54 2c 20 46 49 4c INARY INPUT, FIL
14c0: 45 20 23 5c 64 2b 22 2c 20 46 61 6c 73 65 5d 2c E #\d+", False],
14d0: 0a 20 20 20 20 5b 22 49 4e 50 55 54 20 45 52 52 . ["INPUT ERR
14e0: 4f 52 2c 20 46 49 4c 45 20 23 5c 73 3f 5c 64 2b OR, FILE #\s?\d+
14f0: 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 5b ", False],. [
1500: 22 49 4f 20 45 52 52 4f 52 20 49 4e 20 5c 5c 28 "IO ERROR IN \\(
1510: 66 69 6c 65 20 6e 61 6d 65 5c 5c 29 20 2d 2d 43 file name\\) --C
1520: 4f 4e 54 49 4e 55 49 4e 47 22 2c 20 46 61 6c 73 ONTINUING", Fals
1530: 65 5d 2c 0a 20 20 20 20 5b 22 4e 4f 20 52 4f 4f e],. ["NO ROO
1540: 4d 20 46 4f 52 20 4f 55 54 50 55 54 20 46 49 4c M FOR OUTPUT FIL
1550: 45 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 E", False],.
1560: 5b 22 4e 4f 20 52 4f 4f 4d 20 49 4e 20 5c 5c 28 ["NO ROOM IN \\(
1570: 66 69 6c 65 20 6e 61 6d 65 5c 5c 29 20 2d 2d 43 file name\\) --C
1580: 4f 4e 54 49 4e 55 49 4e 47 22 2c 20 46 61 6c 73 ONTINUING", Fals
1590: 65 5d 2c 0a 20 20 20 20 5b 22 4f 55 54 50 55 54 e],. ["OUTPUT
15a0: 20 45 52 52 4f 52 22 2c 20 46 61 6c 73 65 5d 2c ERROR", False],
15b0: 0a 20 20 20 20 5b 22 50 52 45 4d 41 54 55 52 45 . ["PREMATURE
15c0: 20 45 4e 44 20 4f 46 20 46 49 4c 45 2c 20 46 49 END OF FILE, FI
15d0: 4c 45 20 23 5c 73 3f 5c 64 2b 22 2c 20 46 61 6c LE #\s?\d+", Fal
15e0: 73 65 5d 2c 0a 20 20 20 20 5b 22 5a 45 52 4f 20 se],. ["ZERO
15f0: 53 59 53 3f 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 SYS?", False],.
1600: 20 20 20 23 20 4f 53 2f 38 20 48 61 6e 64 62 6f # OS/8 Handbo
1610: 6f 6b 20 31 39 37 34 20 70 61 67 65 20 32 2d 38 ok 1974 page 2-8
1620: 31 2f 32 34 34 3a 20 44 49 52 45 43 54 20 45 72 1/244: DIRECT Er
1630: 72 6f 72 20 4d 65 73 73 61 67 65 73 0a 20 20 20 ror Messages.
1640: 20 5b 22 42 41 44 20 49 4e 50 55 54 20 44 49 52 ["BAD INPUT DIR
1650: 45 43 54 4f 52 59 22 2c 20 46 61 6c 73 65 5d 2c ECTORY", False],
1660: 0a 20 20 20 20 5b 22 44 45 56 49 43 45 20 44 4f . ["DEVICE DO
1670: 45 53 20 4e 4f 54 20 48 41 56 45 20 41 20 44 49 ES NOT HAVE A DI
1680: 52 45 43 54 4f 52 59 22 2c 20 46 61 6c 73 65 5d RECTORY", False]
1690: 2c 0a 20 20 20 20 5b 22 45 52 52 4f 52 20 43 4c ,. ["ERROR CL
16a0: 4f 53 49 4e 47 20 46 49 4c 45 22 2c 20 46 61 6c OSING FILE", Fal
16b0: 73 65 5d 2c 0a 20 20 20 20 5b 22 45 52 52 4f 52 se],. ["ERROR
16c0: 20 43 4c 4f 53 49 4e 47 20 46 49 4c 45 22 2c 20 CLOSING FILE",
16d0: 46 61 6c 73 65 5d 2c 0a 20 20 20 20 5b 22 45 52 False],. ["ER
16e0: 52 4f 52 20 52 45 41 44 49 4e 47 20 49 4e 50 55 ROR READING INPU
16f0: 54 20 44 49 52 45 43 54 4f 52 59 22 2c 20 46 61 T DIRECTORY", Fa
1700: 6c 73 65 5d 2c 0a 20 20 20 20 5b 22 49 4c 4c 45 lse],. ["ILLE
1710: 47 41 4c 20 5c 5c 2a 22 2c 20 46 61 6c 73 65 5d GAL \\*", False]
1720: 2c 0a 20 20 20 20 23 20 4f 53 2f 38 20 48 61 6e ,. # OS/8 Han
1730: 64 62 6f 6f 6b 20 31 39 37 34 20 70 61 67 65 3a dbook 1974 page:
1740: 20 32 2d 31 30 39 2f 32 37 32 3a 20 46 4f 54 50 2-109/272: FOTP
1750: 20 45 72 72 6f 72 20 4d 65 73 73 61 67 65 73 0a Error Messages.
1760: 20 20 20 20 5b 22 45 52 52 4f 52 20 4f 4e 20 49 ["ERROR ON I
1770: 4e 50 55 54 20 44 45 56 49 43 45 2c 20 53 4b 49 NPUT DEVICE, SKI
1780: 50 50 49 4e 47 20 5c 5c 28 28 5c 53 2b 29 5c 5c PPING \\((\S+)\\
1790: 29 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 )", False],.
17a0: 5b 22 45 52 52 4f 52 20 4f 4e 20 4f 55 54 50 55 ["ERROR ON OUTPU
17b0: 54 20 44 45 56 49 43 45 2c 20 53 4b 49 50 50 49 T DEVICE, SKIPPI
17c0: 4e 47 20 5c 5c 28 28 5c 53 2b 29 5c 5c 29 22 2c NG \\((\S+)\\)",
17d0: 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 5b 22 45 False],. ["E
17e0: 52 52 4f 52 20 52 45 41 44 49 4e 47 20 49 4e 50 RROR READING INP
17f0: 55 54 20 44 49 52 45 43 54 4f 52 59 22 2c 20 46 UT DIRECTORY", F
1800: 61 6c 73 65 5d 2c 0a 20 20 20 20 5b 22 45 52 52 alse],. ["ERR
1810: 4f 52 20 52 45 41 44 49 4e 47 20 4f 55 54 50 55 OR READING OUTPU
1820: 54 20 44 49 52 45 43 54 4f 52 59 22 2c 20 46 61 T DIRECTORY", Fa
1830: 6c 73 65 5d 2c 0a 20 20 20 20 5b 22 49 4c 4c 45 lse],. ["ILLE
1840: 47 41 4c 20 5c 5c 3f 22 2c 20 46 61 6c 73 65 5d GAL \\?", False]
1850: 2c 0a 20 20 20 20 5b 22 4e 4f 20 46 49 4c 45 53 ,. ["NO FILES
1860: 20 4f 46 20 54 48 45 20 46 4f 52 4d 20 28 5c 53 OF THE FORM (\S
1870: 2b 29 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 20 +)", False],.
1880: 20 5b 22 4e 4f 20 52 4f 4f 4d 2c 20 53 4b 49 50 ["NO ROOM, SKIP
1890: 50 49 4e 47 20 5c 5c 28 28 5c 53 2b 29 5c 5c 29 PING \\((\S+)\\)
18a0: 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 5b ", False],. [
18b0: 22 53 59 53 54 45 4d 20 45 52 52 4f 52 2d 43 4c "SYSTEM ERROR-CL
18c0: 4f 53 49 4e 47 20 46 49 4c 45 22 2c 20 46 61 6c OSING FILE", Fal
18d0: 73 65 5d 2c 0a 20 20 20 20 5b 22 55 53 45 20 50 se],. ["USE P
18e0: 49 50 20 46 4f 52 20 4e 4f 4e 2d 46 49 4c 45 20 IP FOR NON-FILE
18f0: 53 54 52 55 43 54 55 52 45 44 20 44 45 56 49 43 STRUCTURED DEVIC
1900: 45 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 E", False],.
1910: 5b 22 4c 49 4e 45 20 54 4f 4f 20 4c 4f 4e 47 20 ["LINE TOO LONG
1920: 49 4e 20 46 49 4c 45 23 5c 64 2b 22 2c 20 46 61 IN FILE#\d+", Fa
1930: 6c 73 65 5d 2c 0a 20 20 5d 0a 0a 20 20 23 20 50 lse],. ].. # P
1940: 61 74 74 65 72 6e 20 74 6f 20 6d 61 74 63 68 20 attern to match
1950: 61 20 53 49 4d 48 20 63 6f 6d 6d 61 6e 64 2e 20 a SIMH command.
1960: 20 54 68 65 20 63 6f 6d 6d 61 6e 64 20 76 65 72 The command ver
1970: 62 20 65 6e 64 73 20 75 70 20 69 6e 0a 20 20 23 b ends up in. #
1980: 20 6d 61 74 63 68 28 29 2e 67 72 6f 75 70 28 31 match().group(1
1990: 29 2c 20 61 6e 64 20 61 6e 79 74 68 69 6e 67 20 ), and anything
19a0: 61 66 74 65 72 20 74 68 65 20 76 65 72 62 20 69 after the verb i
19b0: 6e 20 67 72 6f 75 70 28 33 29 2e 0a 20 20 5f 73 n group(3).. _s
19c0: 69 6d 68 5f 63 6f 6d 6d 5f 72 65 20 3d 20 72 65 imh_comm_re = re
19d0: 2e 63 6f 6d 70 69 6c 65 20 28 22 5e 5c 73 2a 28 .compile ("^\s*(
19e0: 5c 53 2b 29 28 5c 73 2b 28 2e 2a 29 29 3f 24 22 \S+)(\s+(.*))?$"
19f0: 29 0a 0a 20 20 23 20 53 69 67 6e 69 66 69 63 61 ).. # Significa
1a00: 6e 74 20 70 72 65 66 69 78 65 73 20 6f 66 20 53 nt prefixes of S
1a10: 49 4d 48 20 63 6f 6d 6d 61 6e 64 20 76 65 72 62 IMH command verb
1a20: 73 20 74 68 61 74 20 74 72 61 6e 73 69 74 69 6f s that transitio
1a30: 6e 20 66 72 6f 6d 20 53 49 4d 48 0a 20 20 23 20 n from SIMH. #
1a40: 63 6f 6d 6d 61 6e 64 20 63 6f 6e 74 65 78 74 20 command context
1a50: 62 61 63 6b 20 69 6e 74 6f 20 74 68 65 20 73 69 back into the si
1a60: 6d 75 6c 61 74 69 6f 6e 3a 20 42 4f 4f 54 2c 20 mulation: BOOT,
1a70: 43 4f 4e 54 49 4e 55 45 2c 20 61 6e 64 20 47 4f CONTINUE, and GO
1a80: 2e 0a 20 20 23 20 57 65 20 6e 65 65 64 20 6f 6e .. # We need on
1a90: 6c 79 20 74 68 65 20 66 69 72 73 74 20 6c 65 74 ly the first let
1aa0: 74 65 72 20 69 6e 20 61 6c 6c 20 63 61 73 65 73 ter in all cases
1ab0: 2c 20 73 69 6e 63 65 20 74 68 65 73 65 20 70 61 , since these pa
1ac0: 72 74 69 63 75 6c 61 72 0a 20 20 23 20 63 6f 6d rticular. # com
1ad0: 6d 61 6e 64 73 20 61 72 65 20 6e 6f 74 20 61 6d mands are not am
1ae0: 62 69 67 75 6f 75 73 2e 20 20 54 68 65 79 27 72 biguous. They'r
1af0: 65 20 75 70 70 65 72 63 61 73 65 20 62 65 63 61 e uppercase beca
1b00: 75 73 65 20 74 68 65 20 63 6f 64 65 20 74 68 61 use the code tha
1b10: 74 0a 20 20 23 20 75 73 65 73 20 74 68 69 73 20 t. # uses this
1b20: 61 6c 77 61 79 73 20 75 70 70 65 72 63 61 73 65 always uppercase
1b30: 73 20 74 68 65 20 63 6f 6d 6d 61 6e 64 20 62 65 s the command be
1b40: 66 6f 72 65 20 73 65 61 72 63 68 69 6e 67 20 74 fore searching t
1b50: 68 69 73 20 6c 69 73 74 2e 0a 20 20 5f 65 6e 74 his list.. _ent
1b60: 65 72 73 5f 6f 73 38 5f 63 6f 6e 74 65 78 74 20 ers_os8_context
1b70: 3d 20 5b 22 42 22 2c 20 22 43 22 2c 20 22 47 22 = ["B", "C", "G"
1b80: 5d 0a 0a 0a 20 20 23 23 23 23 20 63 74 6f 72 20 ]... #### ctor
1b90: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
1ba0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
1bb0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
1bc0: 23 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 23 ############. #
1bd0: 20 62 61 73 65 64 69 72 20 69 73 20 74 68 65 20 basedir is the
1be0: 70 61 72 65 6e 74 20 6f 66 20 62 69 6e 2f 7b 70 parent of bin/{p
1bf0: 64 70 38 2c 70 69 64 70 38 69 2d 73 69 6d 7d 2e dp8,pidp8i-sim}.
1c00: 0a 20 20 23 0a 20 20 23 20 53 65 74 74 69 6e 67 . #. # Setting
1c10: 20 74 68 65 20 73 6b 69 70 5f 67 70 69 6f 20 66 the skip_gpio f
1c20: 6c 61 67 20 74 6f 20 54 72 75 65 20 63 61 75 73 lag to True caus
1c30: 65 73 20 75 73 20 74 6f 20 75 73 65 20 62 69 6e es us to use bin
1c40: 2f 70 64 70 38 20 69 6e 73 74 65 61 64 0a 20 20 /pdp8 instead.
1c50: 23 20 6f 66 20 62 69 6e 2f 70 69 64 70 38 69 2d # of bin/pidp8i-
1c60: 73 69 6d 2c 20 77 68 69 63 68 20 72 75 6e 73 20 sim, which runs
1c70: 74 68 65 20 73 69 6d 75 6c 61 74 6f 72 20 77 69 the simulator wi
1c80: 74 68 20 74 68 65 20 50 69 44 50 2d 38 2f 49 20 th the PiDP-8/I
1c90: 47 50 49 4f 20 0a 20 20 23 20 74 68 72 65 61 64 GPIO . # thread
1ca0: 20 64 69 73 61 62 6c 65 64 2e 20 20 59 6f 75 20 disabled. You
1cb0: 6d 69 67 68 74 20 64 6f 20 74 68 69 73 20 62 65 might do this be
1cc0: 63 61 75 73 65 20 79 6f 75 20 64 6f 6e 27 74 20 cause you don't
1cd0: 6e 65 65 64 20 61 6e 79 20 66 72 6f 6e 74 0a 20 need any front.
1ce0: 20 23 20 70 61 6e 65 6c 20 69 6e 74 65 72 61 63 # panel interac
1cf0: 74 69 6f 6e 20 6f 72 20 62 65 63 61 75 73 65 20 tion or because
1d00: 79 6f 75 20 6b 6e 6f 77 20 79 6f 75 27 72 65 20 you know you're
1d10: 6e 6f 74 20 72 75 6e 6e 69 6e 67 20 6f 6e 20 61 not running on a
1d20: 6e 20 52 50 69 0a 20 20 23 20 69 6e 20 74 68 65 n RPi. # in the
1d30: 20 66 69 72 73 74 20 70 6c 61 63 65 2e 0a 20 20 first place..
1d40: 0a 20 20 64 65 66 20 5f 5f 69 6e 69 74 5f 5f 20 . def __init__
1d50: 28 73 65 6c 66 2c 20 62 61 73 65 64 69 72 2c 20 (self, basedir,
1d60: 73 6b 69 70 5f 67 70 69 6f 20 3d 20 46 61 6c 73 skip_gpio = Fals
1d70: 65 29 3a 0a 20 20 20 20 23 20 53 74 61 72 74 20 e):. # Start
1d80: 74 68 65 20 73 69 6d 75 6c 61 74 6f 72 20 69 6e the simulator in
1d90: 73 74 61 6e 63 65 0a 20 20 20 20 73 69 6d 20 3d stance. sim =
1da0: 20 27 70 64 70 38 27 20 69 66 20 73 6b 69 70 5f 'pdp8' if skip_
1db0: 67 70 69 6f 20 65 6c 73 65 20 27 70 69 64 70 38 gpio else 'pidp8
1dc0: 69 2d 73 69 6d 27 3b 0a 20 20 20 20 73 65 6c 66 i-sim';. self
1dd0: 2e 5f 63 68 69 6c 64 20 3d 20 70 65 78 70 65 63 ._child = pexpec
1de0: 74 2e 73 70 61 77 6e 20 28 6f 73 2e 70 61 74 68 t.spawn (os.path
1df0: 2e 6a 6f 69 6e 20 28 62 61 73 65 64 69 72 2c 20 .join (basedir,
1e00: 27 62 69 6e 27 2c 20 73 69 6d 29 29 0a 20 20 20 'bin', sim)).
1e10: 20 73 65 6c 66 2e 5f 76 61 6c 69 64 5f 70 69 70 self._valid_pip
1e20: 5f 6f 70 74 69 6f 6e 73 20 3d 20 5b 22 2f 41 22 _options = ["/A"
1e30: 2c 20 22 2f 42 22 2c 20 22 2f 49 22 5d 0a 20 20 , "/B", "/I"].
1e40: 20 20 73 65 6c 66 2e 5f 6f 73 38 5f 66 69 6c 65 self._os8_file
1e50: 5f 72 65 20 3d 20 72 65 2e 63 6f 6d 70 69 6c 65 _re = re.compile
1e60: 28 22 28 5c 53 2b 29 3a 28 5c 53 2b 29 3f 22 29 ("(\S+):(\S+)?")
1e70: 0a 20 20 20 20 73 65 6c 66 2e 5f 6f 73 38 5f 65 . self._os8_e
1e80: 72 72 6f 72 5f 6d 61 74 63 68 5f 73 74 72 69 6e rror_match_strin
1e90: 67 73 20 3d 20 5b 5d 0a 20 20 20 20 73 65 6c 66 gs = []. self
1ea0: 2e 5f 6f 73 38 5f 66 61 74 61 6c 5f 63 68 65 63 ._os8_fatal_chec
1eb0: 6b 20 3d 20 5b 5d 0a 20 20 20 20 73 65 6c 66 2e k = []. self.
1ec0: 76 65 72 62 6f 73 65 20 3d 20 46 61 6c 73 65 0a verbose = False.
1ed0: 0a 20 20 20 20 23 20 57 65 20 6b 65 65 70 20 74 . # We keep t
1ee0: 72 61 63 6b 20 6f 66 20 77 68 61 74 20 6f 75 72 rack of what our
1ef0: 20 63 6f 6d 6d 61 6e 64 20 63 6f 6e 74 65 78 74 command context
1f00: 20 69 73 20 73 6f 20 6f 75 72 20 63 61 6c 6c 65 is so our calle
1f10: 72 20 64 6f 65 73 0a 20 20 20 20 23 20 6e 6f 74 r does. # not
1f20: 20 6e 65 65 64 20 74 6f 20 65 78 70 6c 69 63 69 need to explici
1f30: 74 6c 79 20 63 61 6c 6c 20 62 61 63 6b 5f 74 6f tly call back_to
1f40: 5f 63 6d 64 28 29 20 6f 72 20 73 65 6e 64 63 6f _cmd() or sendco
1f50: 6e 74 72 6f 6c 20 28 27 65 27 29 2e 0a 20 20 20 ntrol ('e')..
1f60: 20 23 20 57 65 20 6b 65 65 70 20 74 72 61 63 6b # We keep track
1f70: 20 6f 66 20 74 68 65 20 63 6f 6d 6d 61 6e 64 20 of the command
1f80: 63 6f 6e 74 65 78 74 20 61 6e 64 20 74 72 61 6e context and tran
1f90: 73 69 74 69 6f 6e 20 61 75 74 6f 6d 61 74 69 63 sition automatic
1fa0: 61 6c 6c 79 2e 0a 20 20 20 20 73 65 6c 66 2e 5f ally.. self._
1fb0: 63 6f 6e 74 65 78 74 20 3d 20 22 73 69 6d 68 22 context = "simh"
1fc0: 0a 20 20 20 20 0a 20 20 20 20 23 20 50 61 72 73 . . # Pars
1fd0: 65 20 6f 75 72 20 4f 53 2f 38 20 45 72 72 6f 72 e our OS/8 Error
1fe0: 73 20 74 61 62 6c 65 20 69 6e 74 6f 20 61 63 74 s table into act
1ff0: 69 6f 6e 61 62 6c 65 20 63 68 75 6e 6b 73 0a 20 ionable chunks.
2000: 20 20 20 66 6f 72 20 65 72 72 6f 72 5f 73 70 65 for error_spe
2010: 63 20 69 6e 20 73 65 6c 66 2e 5f 6f 73 38 5f 65 c in self._os8_e
2020: 72 72 6f 72 73 3a 0a 20 20 20 20 20 20 73 65 6c rrors:. sel
2030: 66 2e 5f 6f 73 38 5f 65 72 72 6f 72 5f 6d 61 74 f._os8_error_mat
2040: 63 68 5f 73 74 72 69 6e 67 73 2e 61 70 70 65 6e ch_strings.appen
2050: 64 28 65 72 72 6f 72 5f 73 70 65 63 5b 30 5d 29 d(error_spec[0])
2060: 0a 20 20 20 20 20 20 73 65 6c 66 2e 5f 6f 73 38 . self._os8
2070: 5f 66 61 74 61 6c 5f 63 68 65 63 6b 2e 61 70 70 _fatal_check.app
2080: 65 6e 64 28 65 72 72 6f 72 5f 73 70 65 63 5b 31 end(error_spec[1
2090: 5d 29 0a 0a 20 20 20 20 73 65 6c 66 2e 5f 70 69 ]).. self._pi
20a0: 70 5f 74 6f 5f 72 65 70 6c 69 65 73 20 3d 20 5b p_to_replies = [
20b0: 27 5c 5c 5e 27 5d 0a 20 20 20 20 73 65 6c 66 2e '\\^']. self.
20c0: 5f 70 69 70 5f 74 6f 5f 72 65 70 6c 69 65 73 2e _pip_to_replies.
20d0: 65 78 74 65 6e 64 28 73 65 6c 66 2e 5f 6f 73 38 extend(self._os8
20e0: 5f 65 72 72 6f 72 5f 6d 61 74 63 68 5f 73 74 72 _error_match_str
20f0: 69 6e 67 73 29 0a 20 20 20 20 23 20 44 69 64 20 ings). # Did
2100: 63 6f 6d 6d 61 6e 64 20 73 74 61 72 74 20 74 68 command start th
2110: 65 20 63 6f 6d 6d 61 6e 64 20 64 65 63 6f 64 65 e command decode
2120: 72 20 6f 72 20 64 69 65 20 77 69 74 68 20 61 20 r or die with a
2130: 6d 6f 6e 69 74 6f 72 20 65 72 72 6f 72 3f 0a 20 monitor error?.
2140: 20 20 20 73 65 6c 66 2e 5f 63 64 5f 72 65 70 6c self._cd_repl
2150: 69 65 73 20 3d 20 5b 27 5c 5c 2a 27 5d 0a 20 20 ies = ['\\*'].
2160: 20 20 73 65 6c 66 2e 5f 63 64 5f 72 65 70 6c 69 self._cd_repli
2170: 65 73 2e 65 78 74 65 6e 64 28 73 65 6c 66 2e 5f es.extend(self._
2180: 6f 73 38 5f 65 72 72 6f 72 5f 6d 61 74 63 68 5f os8_error_match_
2190: 73 74 72 69 6e 67 73 29 0a 0a 20 20 20 20 23 20 strings).. #
21a0: 54 75 72 6e 20 6f 66 66 20 70 65 78 70 65 63 74 Turn off pexpect
21b0: 27 73 20 64 65 66 61 75 6c 74 20 69 6e 74 65 72 's default inter
21c0: 2d 73 65 6e 64 28 29 20 64 65 6c 61 79 2e 20 20 -send() delay.
21d0: 57 65 20 61 64 64 20 6f 75 72 20 6f 77 6e 20 61 We add our own a
21e0: 73 0a 20 20 20 20 23 20 6e 65 63 65 73 73 61 72 s. # necessar
21f0: 79 2e 20 20 54 68 65 20 63 6f 6e 64 69 74 69 6f y. The conditio
2200: 6e 61 6c 20 74 72 61 63 6b 73 20 61 6e 20 41 50 nal tracks an AP
2210: 49 20 63 68 61 6e 67 65 20 62 65 74 77 65 65 6e I change between
2220: 20 33 20 61 6e 64 20 34 2e 0a 20 20 20 20 70 65 3 and 4.. pe
2230: 76 34 20 3d 20 28 70 6b 67 5f 72 65 73 6f 75 72 v4 = (pkg_resour
2240: 63 65 73 2e 67 65 74 5f 64 69 73 74 72 69 62 75 ces.get_distribu
2250: 74 69 6f 6e 28 22 70 65 78 70 65 63 74 22 29 2e tion("pexpect").
2260: 70 61 72 73 65 64 5f 76 65 72 73 69 6f 6e 20 3e parsed_version >
2270: 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 6b 67 . pkg
2280: 5f 72 65 73 6f 75 72 63 65 73 2e 70 61 72 73 65 _resources.parse
2290: 5f 76 65 72 73 69 6f 6e 28 22 34 2e 30 22 29 29 _version("4.0"))
22a0: 0a 20 20 20 20 73 65 6c 66 2e 5f 63 68 69 6c 64 . self._child
22b0: 2e 64 65 6c 61 79 62 65 66 6f 72 65 73 65 6e 64 .delaybeforesend
22c0: 20 3d 20 4e 6f 6e 65 20 69 66 20 70 65 76 34 20 = None if pev4
22d0: 65 6c 73 65 20 30 0a 0a 20 20 20 20 23 20 57 61 else 0.. # Wa
22e0: 69 74 20 66 6f 72 20 74 68 65 20 73 69 6d 75 6c it for the simul
22f0: 61 74 6f 72 27 73 20 73 74 61 72 74 75 70 20 6d ator's startup m
2300: 65 73 73 61 67 65 2e 0a 20 20 20 20 69 66 20 6e essage.. if n
2310: 6f 74 20 73 65 6c 66 2e 74 72 79 5f 77 61 69 74 ot self.try_wait
2320: 20 28 27 50 44 50 2d 38 20 73 69 6d 75 6c 61 74 ('PDP-8 simulat
2330: 6f 72 20 56 2e 2a 67 69 74 20 63 6f 6d 6d 69 74 or V.*git commit
2340: 20 69 64 3a 20 5b 30 2d 39 61 2d 66 5d 27 2c 20 id: [0-9a-f]',
2350: 31 30 29 3a 0a 20 20 20 20 20 20 72 61 69 73 65 10):. raise
2360: 20 52 75 6e 74 69 6d 65 45 72 72 6f 72 20 28 27 RuntimeError ('
2370: 53 69 6d 75 6c 61 74 6f 72 20 66 61 69 6c 65 64 Simulator failed
2380: 20 74 6f 20 73 74 61 72 74 27 29 0a 0a 0a 20 20 to start')...
2390: 23 23 23 23 20 62 61 63 6b 5f 74 6f 5f 63 6d 64 #### back_to_cmd
23a0: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ###############
23b0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
23c0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
23d0: 23 23 23 23 23 23 23 0a 20 20 23 20 50 61 75 73 #######. # Paus
23e0: 65 20 74 68 65 20 73 69 6d 75 6c 61 74 69 6f 6e e the simulation
23f0: 20 61 6e 64 20 72 65 74 75 72 6e 20 74 6f 20 74 and return to t
2400: 68 65 20 53 49 4d 48 20 63 6f 6d 6d 61 6e 64 20 he SIMH command
2410: 70 72 6f 6d 70 74 20 77 68 65 6e 20 74 68 65 0a prompt when the.
2420: 20 20 23 20 73 69 6d 75 6c 61 74 65 64 20 73 6f # simulated so
2430: 66 74 77 61 72 65 20 65 6d 69 74 73 20 74 68 65 ftware emits the
2440: 20 67 69 76 65 6e 20 70 72 6f 6d 70 74 20 73 74 given prompt st
2450: 72 69 6e 67 2e 20 20 54 79 70 69 63 61 6c 6c 79 ring. Typically
2460: 20 75 73 65 64 20 74 6f 0a 20 20 23 20 77 61 69 used to. # wai
2470: 74 20 66 6f 72 20 4f 53 2f 38 20 74 6f 20 66 69 t for OS/8 to fi
2480: 6e 69 73 68 20 72 75 6e 6e 69 6e 67 20 61 20 63 nish running a c
2490: 6f 6d 6d 61 6e 64 20 73 6f 20 77 65 20 63 61 6e ommand so we can
24a0: 20 64 6f 20 73 6f 6d 65 74 68 69 6e 67 0a 20 20 do something.
24b0: 23 20 64 6f 77 6e 20 61 74 20 74 68 65 20 53 49 # down at the SI
24c0: 4d 48 20 6c 61 79 65 72 20 69 6e 73 74 65 61 64 MH layer instead
24d0: 2e 0a 0a 20 20 64 65 66 20 62 61 63 6b 5f 74 6f ... def back_to
24e0: 5f 63 6d 64 20 28 73 65 6c 66 2c 20 70 72 6f 6d _cmd (self, prom
24f0: 70 74 29 3a 0a 20 20 20 20 73 65 6c 66 2e 5f 63 pt):. self._c
2500: 68 69 6c 64 2e 65 78 70 65 63 74 20 28 22 5c 6e hild.expect ("\n
2510: 25 73 24 22 20 25 20 70 72 6f 6d 70 74 29 0a 20 %s$" % prompt).
2520: 20 20 20 73 65 6c 66 2e 6f 73 38 5f 6b 62 64 5f self.os8_kbd_
2530: 64 65 6c 61 79 20 28 29 0a 20 20 20 20 73 65 6c delay (). sel
2540: 66 2e 5f 63 68 69 6c 64 2e 73 65 6e 64 63 6f 6e f._child.sendcon
2550: 74 72 6f 6c 20 28 27 65 27 29 0a 20 20 20 20 73 trol ('e'). s
2560: 65 6c 66 2e 5f 63 6f 6e 74 65 78 74 20 3d 20 22 elf._context = "
2570: 73 69 6d 68 22 0a 0a 0a 20 20 23 23 23 23 20 6f simh"... #### o
2580: 73 38 5f 67 65 74 5f 66 69 6c 65 20 23 23 23 23 s8_get_file ####
2590: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
25a0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
25b0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
25c0: 0a 20 20 23 20 52 6f 75 67 68 20 69 6e 76 65 72 . # Rough inver
25d0: 73 65 20 6f 66 20 6f 73 38 5f 73 65 6e 64 5f 66 se of os8_send_f
25e0: 69 6c 65 2e 0a 20 20 23 0a 20 20 23 20 42 6f 74 ile.. #. # Bot
25f0: 68 20 70 61 74 68 73 20 6d 75 73 74 20 62 65 20 h paths must be
2600: 67 69 76 65 6e 20 61 6e 64 20 61 72 65 20 75 73 given and are us
2610: 65 64 20 6c 69 74 65 72 61 6c 6c 79 2e 20 20 28 ed literally. (
2620: 43 6f 6e 74 72 61 73 74 20 6f 75 72 0a 20 20 23 Contrast our. #
2630: 20 69 6e 76 65 72 73 65 2c 20 77 68 65 72 65 20 inverse, where
2640: 74 68 65 20 64 65 73 74 69 6e 61 74 69 6e 6f 6e the destinatinon
2650: 20 66 69 6c 65 20 6e 61 6d 65 20 69 73 20 70 72 file name is pr
2660: 6f 64 75 63 65 64 20 66 72 6f 6d 20 74 68 65 0a oduced from the.
2670: 20 20 23 20 73 6f 75 72 63 65 20 69 66 20 6e 6f # source if no
2680: 74 20 67 69 76 65 6e 2e 29 0a 20 20 23 0a 20 20 t given.). #.
2690: 23 20 57 68 65 6e 20 74 68 69 73 20 66 75 6e 63 # When this func
26a0: 74 69 6f 6e 20 69 73 20 63 61 6c 6c 65 64 20 74 tion is called t
26b0: 6f 20 70 75 6c 6c 20 61 20 66 69 6c 65 20 73 65 o pull a file se
26c0: 6e 74 20 62 79 20 6f 75 72 20 69 6e 76 65 72 73 nt by our invers
26d0: 65 2c 20 74 68 65 0a 20 20 23 20 63 6f 6e 76 65 e, the. # conve
26e0: 72 73 69 6f 6e 20 73 68 6f 75 6c 64 20 62 65 20 rsion should be
26f0: 6c 6f 73 73 6c 65 73 73 20 65 78 63 65 70 74 20 lossless except
2700: 66 6f 72 20 74 68 65 20 74 72 61 6e 73 66 6f 72 for the transfor
2710: 6d 73 20 64 6f 6e 65 20 62 79 20 6f 75 72 0a 20 ms done by our.
2720: 20 23 20 75 6e 64 65 72 6c 79 69 6e 67 20 75 74 # underlying ut
2730: 69 6c 69 74 79 20 74 6f 6f 6c 73 2c 20 73 75 63 ility tools, suc
2740: 68 20 61 73 20 74 68 65 20 4c 46 20 2d 3e 20 43 h as the LF -> C
2750: 52 2b 4c 46 20 64 6f 6e 65 20 62 79 20 74 78 74 R+LF done by txt
2760: 32 70 74 70 0a 20 20 23 20 62 75 74 20 6e 6f 74 2ptp. # but not
2770: 20 75 6e 64 6f 6e 65 20 62 79 20 70 74 70 32 74 undone by ptp2t
2780: 78 74 2e 0a 20 20 23 0a 20 20 23 20 45 6e 74 72 xt.. #. # Entr
2790: 79 20 63 6f 6e 74 65 78 74 20 73 68 6f 75 6c 64 y context should
27a0: 20 62 65 20 69 6e 73 69 64 65 20 4f 53 2f 38 2e be inside OS/8.
27b0: 20 20 45 78 69 74 20 63 6f 6e 74 65 78 74 20 69 Exit context i
27c0: 73 20 69 6e 73 69 64 65 20 4f 53 2f 38 2e 0a 0a s inside OS/8...
27d0: 20 20 64 65 66 20 6f 73 38 5f 67 65 74 5f 66 69 def os8_get_fi
27e0: 6c 65 20 28 73 65 6c 66 2c 20 69 6e 74 6e 61 6d le (self, intnam
27f0: 65 2c 20 65 78 74 6e 61 6d 65 29 3a 0a 20 20 20 e, extname):.
2800: 20 23 20 41 74 74 61 63 68 20 61 20 62 6c 61 6e # Attach a blan
2810: 6b 20 70 61 70 65 72 20 74 61 70 65 20 74 6f 20 k paper tape to
2820: 74 68 65 20 73 69 6d 75 6c 61 74 6f 72 2e 0a 20 the simulator..
2830: 20 20 20 70 74 66 20 3d 20 74 65 6d 70 66 69 6c ptf = tempfil
2840: 65 2e 4e 61 6d 65 64 54 65 6d 70 6f 72 61 72 79 e.NamedTemporary
2850: 46 69 6c 65 20 28 73 75 66 66 69 78 20 3d 20 27 File (suffix = '
2860: 2e 70 74 27 2c 20 64 65 6c 65 74 65 20 3d 20 46 .pt', delete = F
2870: 61 6c 73 65 29 0a 20 20 20 20 70 74 66 2e 63 6c alse). ptf.cl
2880: 6f 73 65 20 28 29 0a 20 20 20 20 70 74 6e 20 3d ose (). ptn =
2890: 20 70 74 66 2e 6e 61 6d 65 0a 20 20 20 20 73 65 ptf.name. se
28a0: 6c 66 2e 62 61 63 6b 5f 74 6f 5f 63 6d 64 20 28 lf.back_to_cmd (
28b0: 27 5c 5c 2e 27 29 0a 20 20 20 20 73 65 6c 66 2e '\\.'). self.
28c0: 73 65 6e 64 5f 63 6d 64 20 28 27 61 74 74 61 63 send_cmd ('attac
28d0: 68 20 70 74 70 20 27 20 2b 20 70 74 6e 29 0a 0a h ptp ' + ptn)..
28e0: 20 20 20 20 23 20 50 75 6e 63 68 20 69 6e 74 65 # Punch inte
28f0: 72 6e 61 6c 20 66 69 6c 65 20 74 6f 20 65 78 74 rnal file to ext
2900: 65 72 6e 61 6c 20 70 61 70 65 72 20 74 61 70 65 ernal paper tape
2910: 20 69 6d 61 67 65 0a 20 20 20 20 73 65 6c 66 2e image. self.
2920: 6f 73 38 5f 72 65 73 74 61 72 74 20 28 29 0a 20 os8_restart ().
2930: 20 20 20 73 65 6c 66 2e 6f 73 38 5f 73 65 6e 64 self.os8_send
2940: 5f 63 6d 64 20 28 27 5c 5c 2e 27 2c 20 27 50 55 _cmd ('\\.', 'PU
2950: 4e 43 48 20 27 20 2b 20 69 6e 74 6e 61 6d 65 29 NCH ' + intname)
2960: 3b 0a 20 20 20 20 73 65 6c 66 2e 62 61 63 6b 5f ;. self.back_
2970: 74 6f 5f 63 6d 64 20 28 27 5c 5c 2e 27 29 20 20 to_cmd ('\\.')
2980: 20 20 20 20 20 20 23 20 77 61 69 74 20 66 6f 72 # wait for
2990: 20 74 72 61 6e 73 66 65 72 20 74 6f 20 66 69 6e transfer to fin
29a0: 69 73 68 0a 0a 20 20 20 20 23 20 43 6f 6e 76 65 ish.. # Conve
29b0: 72 74 20 74 65 78 74 20 66 69 6c 65 20 66 72 6f rt text file fro
29c0: 6d 20 53 49 4d 48 20 70 61 70 65 72 20 74 61 70 m SIMH paper tap
29d0: 65 20 66 6f 72 6d 61 74 0a 20 20 20 20 74 6f 6f e format. too
29e0: 6c 20 3d 20 6f 73 2e 70 61 74 68 2e 6a 6f 69 6e l = os.path.join
29f0: 20 28 70 69 64 70 38 69 2e 64 69 72 73 2e 62 75 (pidp8i.dirs.bu
2a00: 69 6c 64 2c 20 27 62 69 6e 27 2c 20 27 70 74 70 ild, 'bin', 'ptp
2a10: 32 74 78 74 27 29 0a 20 20 20 20 73 65 6c 66 2e 2txt'). self.
2a20: 73 65 6e 64 5f 63 6d 64 20 28 27 64 65 74 61 63 send_cmd ('detac
2a30: 68 20 70 74 70 27 29 0a 20 20 20 20 73 75 62 70 h ptp'). subp
2a40: 72 6f 63 65 73 73 2e 63 61 6c 6c 20 28 74 6f 6f rocess.call (too
2a50: 6c 20 2b 20 27 20 3c 20 27 20 2b 20 20 70 74 6e l + ' < ' + ptn
2a60: 20 2b 20 27 20 3e 20 27 20 2b 20 65 78 74 6e 61 + ' > ' + extna
2a70: 6d 65 2c 20 73 68 65 6c 6c 20 3d 20 54 72 75 65 me, shell = True
2a80: 29 0a 0a 20 20 20 20 23 20 52 65 74 75 72 6e 20 ).. # Return
2a90: 74 6f 20 4f 53 2f 38 2c 20 6a 75 73 74 20 62 65 to OS/8, just be
2aa0: 63 61 75 73 65 20 74 68 61 74 27 73 20 77 68 65 cause that's whe
2ab0: 72 65 20 77 65 20 77 65 72 65 20 6f 6e 20 65 6e re we were on en
2ac0: 74 72 79 2c 20 73 6f 20 77 65 0a 20 20 20 20 23 try, so we. #
2ad0: 20 73 68 6f 75 6c 64 20 6e 6f 74 20 63 68 61 6e should not chan
2ae0: 67 65 20 74 68 61 74 2e 0a 20 20 20 20 73 65 6c ge that.. sel
2af0: 66 2e 6f 73 38 5f 72 65 73 74 61 72 74 20 28 29 f.os8_restart ()
2b00: 0a 0a 0a 20 20 23 23 23 23 20 6f 73 38 5f 6b 62 ... #### os8_kb
2b10: 64 5f 64 65 6c 61 79 20 23 23 23 23 23 23 23 23 d_delay ########
2b20: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
2b30: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
2b40: 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 23 20 ###########. #
2b50: 41 72 74 69 66 69 63 69 61 6c 6c 79 20 64 65 6c Artificially del
2b60: 61 79 20 74 68 65 20 6d 65 64 69 61 20 67 65 6e ay the media gen
2b70: 65 72 61 74 69 6f 6e 20 70 72 6f 63 65 73 73 20 eration process
2b80: 74 6f 20 61 63 63 6f 75 6e 74 20 66 6f 72 20 74 to account for t
2b90: 68 65 0a 20 20 23 20 66 61 63 74 20 74 68 61 74 he. # fact that
2ba0: 20 4f 53 2f 38 20 6c 61 63 6b 73 20 61 20 6d 6f OS/8 lacks a mo
2bb0: 64 65 72 6e 20 6d 75 6c 74 69 2d 63 68 61 72 61 dern multi-chara
2bc0: 63 74 65 72 20 6b 65 79 62 6f 61 72 64 20 69 6e cter keyboard in
2bd0: 70 75 74 20 62 75 66 66 65 72 2e 0a 20 20 23 20 put buffer.. #
2be0: 49 74 20 69 73 20 75 6e 73 61 66 65 20 74 6f 20 It is unsafe to
2bf0: 73 65 6e 64 20 74 65 78 74 20 66 61 73 74 65 72 send text faster
2c00: 20 74 68 61 6e 20 61 20 63 6f 6e 74 65 6d 70 6f than a contempo
2c10: 72 61 72 79 20 74 65 72 6d 69 6e 61 6c 20 63 6f rary terminal co
2c20: 75 6c 64 2c 0a 20 20 23 20 74 68 6f 75 67 68 20 uld,. # though
2c30: 77 65 20 63 61 6e 20 73 63 61 6c 65 20 69 74 20 we can scale it
2c40: 62 61 73 65 64 20 6f 6e 20 68 6f 77 20 6d 75 63 based on how muc
2c50: 68 20 66 61 73 74 65 72 20 74 68 69 73 20 68 6f h faster this ho
2c60: 73 74 20 69 73 20 74 68 61 6e 20 61 0a 20 20 23 st is than a. #
2c70: 20 72 65 61 6c 20 50 44 50 2d 38 2e 20 20 53 65 real PDP-8. Se
2c80: 65 20 74 68 65 20 63 6f 6e 73 74 61 6e 74 73 20 e the constants
2c90: 61 62 6f 76 65 20 66 6f 72 20 74 68 65 20 63 61 above for the ca
2ca0: 6c 63 75 6c 61 74 69 6f 6e 2e 0a 0a 20 20 64 65 lculation... de
2cb0: 66 20 6f 73 38 5f 6b 62 64 5f 64 65 6c 61 79 20 f os8_kbd_delay
2cc0: 28 73 65 6c 66 29 3a 0a 20 20 20 20 74 69 6d 65 (self):. time
2cd0: 2e 73 6c 65 65 70 20 28 73 65 6c 66 2e 5f 6f 73 .sleep (self._os
2ce0: 38 5f 6b 62 64 5f 64 65 6c 61 79 29 0a 0a 0a 20 8_kbd_delay)...
2cf0: 20 23 23 23 23 20 6f 73 38 5f 73 65 6e 64 5f 63 #### os8_send_c
2d00: 6d 64 20 23 23 23 23 23 23 23 23 23 23 23 23 23 md #############
2d10: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
2d20: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
2d30: 23 23 23 23 23 23 23 0a 20 20 23 20 57 61 69 74 #######. # Wait
2d40: 20 66 6f 72 20 61 6e 20 4f 53 2f 38 20 63 6f 6d for an OS/8 com
2d50: 6d 61 6e 64 20 70 72 6f 6d 70 74 20 72 75 6e 6e mand prompt runn
2d60: 69 6e 67 20 77 69 74 68 69 6e 20 53 49 4d 48 2c ing within SIMH,
2d70: 20 74 68 65 6e 20 73 65 6e 64 20 74 68 65 0a 20 then send the.
2d80: 20 23 20 67 69 76 65 6e 20 6c 69 6e 65 2e 0a 20 # given line..
2d90: 20 23 0a 20 20 23 20 54 68 65 20 64 65 66 61 75 #. # The defau
2da0: 6c 74 20 74 69 6d 65 6f 75 74 20 6d 61 79 20 73 lt timeout may s
2db0: 65 65 6d 20 65 78 63 65 73 73 69 76 65 2c 20 62 eem excessive, b
2dc0: 75 74 20 69 74 20 69 73 20 62 61 73 65 64 20 6f ut it is based o
2dd0: 6e 20 68 61 72 64 0a 20 20 23 20 65 78 70 65 72 n hard. # exper
2de0: 69 65 6e 63 65 3a 20 77 68 65 6e 20 53 49 4d 48 ience: when SIMH
2df0: 20 69 73 20 72 75 6e 6e 69 6e 67 20 6f 6e 20 61 is running on a
2e00: 20 73 6c 6f 77 20 68 6f 73 74 20 77 69 74 68 20 slow host with
2e10: 73 6c 6f 77 20 64 65 76 69 63 65 73 0a 20 20 23 slow devices. #
2e20: 20 28 65 2e 67 2e 20 74 68 65 20 62 79 74 65 2d (e.g. the byte-
2e30: 62 79 2d 62 79 74 65 20 74 72 61 6e 73 66 65 72 by-byte transfer
2e40: 20 6f 66 20 74 68 65 20 54 44 38 45 20 74 61 70 of the TD8E tap
2e50: 65 20 63 6f 6e 74 72 6f 6c 6c 65 72 29 20 61 0a e controller) a.
2e60: 20 20 23 20 73 69 6e 67 6c 65 20 4f 53 2f 38 20 # single OS/8
2e70: 63 6f 6d 6d 61 6e 64 20 63 61 6e 20 74 61 6b 65 command can take
2e80: 20 61 20 76 65 72 79 20 6c 6f 6e 67 20 74 69 6d a very long tim
2e90: 65 20 69 66 20 69 74 20 72 65 71 75 69 72 65 73 e if it requires
2ea0: 20 61 20 6c 6f 74 0a 20 20 23 20 6f 66 20 49 2f a lot. # of I/
2eb0: 4f 2e 20 20 49 66 20 79 6f 75 20 61 72 65 20 63 O. If you are c
2ec0: 61 6c 6c 69 6e 67 20 74 68 69 73 20 66 6f 72 20 alling this for
2ed0: 61 20 63 6f 6d 6d 61 6e 64 20 74 68 61 74 20 79 a command that y
2ee0: 6f 75 20 6b 6e 6f 77 20 66 6f 72 20 61 0a 20 20 ou know for a.
2ef0: 23 20 66 61 63 74 20 74 61 6b 65 73 20 6c 65 73 # fact takes les
2f00: 73 20 74 69 6d 65 20 6f 6e 20 61 6c 6c 20 68 6f s time on all ho
2f10: 73 74 73 20 61 6e 64 20 77 69 74 68 20 61 6c 6c sts and with all
2f20: 20 70 72 61 63 74 69 63 61 6c 20 64 65 76 69 63 practical devic
2f30: 65 0a 20 20 23 20 63 6f 6e 66 69 67 75 72 61 74 e. # configurat
2f40: 69 6f 6e 73 2c 20 77 65 20 65 6e 63 6f 75 72 61 ions, we encoura
2f50: 67 65 20 79 6f 75 20 74 6f 20 70 61 73 73 20 61 ge you to pass a
2f60: 20 73 6d 61 6c 6c 65 72 20 76 61 6c 75 65 2e 0a smaller value..
2f70: 20 20 23 0a 20 20 23 20 54 68 65 20 63 61 6c 6c #. # The call
2f80: 65 72 20 6d 75 73 74 20 70 61 73 73 20 61 20 70 er must pass a p
2f90: 72 6f 6d 70 74 20 73 74 72 69 6e 67 20 62 65 63 rompt string bec
2fa0: 61 75 73 65 20 4f 53 2f 38 20 68 61 73 20 73 65 ause OS/8 has se
2fb0: 76 65 72 61 6c 0a 20 20 23 20 64 69 66 66 65 72 veral. # differ
2fc0: 65 6e 74 20 70 72 6f 6d 70 74 20 74 79 70 65 73 ent prompt types
2fd0: 3a 20 2e 2c 20 2a 2c 20 24 2c 20 61 6e 64 20 23 : ., *, $, and #
2fe0: 2c 20 61 74 20 6c 65 61 73 74 2e 20 20 42 65 77 , at least. Bew
2ff0: 61 72 65 20 69 6e 20 70 61 73 73 69 6e 67 0a 20 are in passing.
3000: 20 23 20 74 68 65 73 65 20 74 68 61 74 20 74 68 # these that th
3010: 65 79 27 72 65 20 74 72 65 61 74 65 64 20 61 73 ey're treated as
3020: 20 72 65 67 75 6c 61 72 20 65 78 70 72 65 73 73 regular express
3030: 69 6f 6e 73 2c 20 73 6f 20 63 68 61 72 61 63 74 ions, so charact
3040: 65 72 73 0a 20 20 23 20 73 70 65 63 69 61 6c 20 ers. # special
3050: 69 6e 20 50 79 74 68 6f 6e 20 52 45 73 20 6d 75 in Python REs mu
3060: 73 74 20 62 65 20 65 73 63 61 70 65 64 2e 20 20 st be escaped.
3070: 41 6e 64 20 74 68 65 6e 20 73 69 6e 63 65 20 74 And then since t
3080: 68 65 20 52 45 20 65 73 63 61 70 65 0a 20 20 23 he RE escape. #
3090: 20 63 68 61 72 61 63 74 65 72 20 28 5c 29 20 69 character (\) i
30a0: 73 20 61 6c 73 6f 20 73 70 65 63 69 61 6c 20 69 s also special i
30b0: 6e 20 50 79 74 68 6f 6e 20 73 74 72 69 6e 67 73 n Python strings
30c0: 2c 20 79 6f 75 20 6d 75 73 74 20 64 6f 75 62 6c , you must doubl
30d0: 65 2d 0a 20 20 23 20 65 73 63 61 70 65 20 2a 69 e-. # escape *i
30e0: 74 2a 2e 20 20 53 6f 2c 20 27 5c 5c 24 27 20 69 t*. So, '\\$' i
30f0: 73 20 61 20 72 65 61 73 6f 6e 61 62 6c 65 20 74 s a reasonable t
3100: 68 69 6e 67 20 74 6f 20 70 61 73 73 20 61 73 20 hing to pass as
3110: 74 68 65 20 70 72 6f 6d 70 74 0a 20 20 23 20 76 the prompt. # v
3120: 61 6c 75 65 2c 20 6d 65 61 6e 69 6e 67 20 22 6c alue, meaning "l
3130: 6f 6f 6b 20 66 6f 72 20 61 20 6c 69 74 65 72 61 ook for a litera
3140: 6c 20 24 20 63 68 61 72 61 63 74 65 72 2e 22 0a l $ character.".
3150: 20 20 23 0a 20 20 23 20 54 68 69 73 20 72 6f 75 #. # This rou
3160: 74 69 6e 65 20 72 65 71 75 69 72 65 73 20 74 68 tine requires th
3170: 65 20 63 61 6c 6c 65 72 20 74 6f 20 65 6e 73 75 e caller to ensu
3180: 72 65 20 74 68 61 74 20 74 68 65 20 73 79 73 74 re that the syst
3190: 65 6d 20 69 73 20 69 6e 0a 20 20 23 20 4f 53 2f em is in. # OS/
31a0: 38 20 4b 65 79 62 6f 61 72 64 20 4d 6f 6e 69 74 8 Keyboard Monit
31b0: 6f 72 20 63 6f 6e 74 65 78 74 20 e2 80 94 20 74 or context — t
31c0: 68 61 74 20 69 73 2c 20 72 65 61 64 79 20 66 6f hat is, ready fo
31d0: 72 20 61 6e 6f 74 68 65 72 20 4f 53 2f 38 0a 20 r another OS/8.
31e0: 20 23 20 63 6f 6d 6d 61 6e 64 20 e2 80 94 20 62 # command — b
31f0: 65 66 6f 72 65 20 63 61 6c 6c 69 6e 67 20 69 74 efore calling it
3200: 2e 20 20 57 68 69 6c 65 20 74 68 69 73 20 72 6f . While this ro
3210: 75 74 69 6e 65 20 69 73 20 61 62 6c 65 20 74 6f utine is able to
3220: 20 63 68 65 63 6b 0a 20 20 23 20 77 68 65 74 68 check. # wheth
3230: 65 72 20 77 65 27 72 65 20 69 6e 20 4f 53 2f 38 er we're in OS/8
3240: 20 63 6f 6e 74 65 78 74 20 61 73 20 61 20 70 72 context as a pr
3250: 65 72 65 71 75 69 73 69 74 65 2c 20 69 74 20 69 erequisite, it i
3260: 73 20 6e 6f 74 20 70 72 61 63 74 69 63 61 6c 0a s not practical.
3270: 20 20 23 20 66 6f 72 20 75 73 20 74 6f 20 72 65 # for us to re
3280: 74 75 72 6e 20 74 68 65 20 73 79 73 74 65 6d 20 turn the system
3290: 74 6f 20 4f 53 2f 38 20 63 6f 6e 74 65 78 74 20 to OS/8 context
32a0: 61 75 74 6f 6d 61 74 69 63 61 6c 6c 79 20 66 72 automatically fr
32b0: 6f 6d 20 73 6f 6d 65 0a 20 20 23 20 6f 74 68 65 om some. # othe
32c0: 72 20 63 6f 6e 74 65 78 74 20 62 65 63 61 75 73 r context becaus
32d0: 65 20 74 68 61 74 20 77 6f 75 6c 64 20 72 65 71 e that would req
32e0: 75 69 72 65 20 75 73 20 74 6f 20 6b 6e 6f 77 20 uire us to know
32f0: 74 68 65 20 63 75 72 72 65 6e 74 0a 20 20 23 20 the current. #
3300: 63 6f 6e 74 65 78 74 20 69 6e 20 64 65 74 61 69 context in detai
3310: 6c 2c 20 62 75 74 20 6f 6e 6c 79 20 74 68 65 20 l, but only the
3320: 63 61 6c 6c 65 72 20 68 61 73 20 74 68 61 74 20 caller has that
3330: 66 75 6c 6c 20 6b 6e 6f 77 6c 65 64 67 65 2e 0a full knowledge..
3340: 20 20 23 20 0a 20 20 23 20 50 61 72 74 20 6f 66 # . # Part of
3350: 20 74 68 65 20 70 72 6f 62 6c 65 6d 20 69 73 20 the problem is
3360: 74 68 61 74 20 69 6e 20 6f 72 64 65 72 20 74 6f that in order to
3370: 20 73 79 6e 63 68 72 6f 6e 69 7a 65 20 74 68 69 synchronize thi
3380: 73 20 6f 62 6a 65 63 74 27 73 0a 20 20 23 20 69 s object's. # i
3390: 6e 74 65 72 6e 61 6c 20 73 74 61 74 65 20 6d 61 nternal state ma
33a0: 63 68 69 6e 65 20 77 69 74 68 20 74 68 65 20 53 chine with the S
33b0: 49 4d 48 20 2b 20 4f 53 2f 38 20 2b 20 72 75 6e IMH + OS/8 + run
33c0: 6e 69 6e 67 20 70 72 6f 67 72 61 6d 20 73 74 61 ning program sta
33d0: 74 65 2c 0a 20 20 23 20 77 65 20 68 61 76 65 20 te,. # we have
33e0: 74 6f 20 73 6f 6d 65 68 6f 77 20 70 72 6f 76 6f to somehow provo
33f0: 6b 65 20 61 20 70 72 6f 6d 70 74 20 63 68 61 72 ke a prompt char
3400: 61 63 74 65 72 20 66 72 6f 6d 20 74 68 65 20 72 acter from the r
3410: 75 6e 6e 69 6e 67 0a 20 20 23 20 70 72 6f 67 72 unning. # progr
3420: 61 6d 2e 20 20 48 6f 77 20 64 6f 20 77 65 20 64 am. How do we d
3430: 6f 20 74 68 61 74 20 77 69 74 68 6f 75 74 20 6b o that without k
3440: 6e 6f 77 69 6e 67 20 74 68 65 20 63 75 72 72 65 nowing the curre
3450: 6e 74 20 63 6f 6e 74 65 78 74 3f 0a 20 20 23 20 nt context?. #
3460: 49 6e 20 73 6f 6d 65 20 63 6f 6e 74 65 78 74 73 In some contexts
3470: 2c 20 61 20 43 52 20 6f 72 20 4c 46 20 77 69 6c , a CR or LF wil
3480: 6c 20 64 6f 20 69 74 2c 20 69 6e 20 6f 74 68 65 l do it, in othe
3490: 72 73 20 42 53 2c 20 61 6e 64 20 69 6e 20 6f 74 rs BS, and in ot
34a0: 68 65 72 73 0a 20 20 23 20 69 74 27 6c 6c 20 74 hers. # it'll t
34b0: 61 6b 65 20 43 74 72 6c 2d 43 2e 20 20 54 68 65 ake Ctrl-C. The
34c0: 6e 20 79 6f 75 20 68 61 76 65 20 61 20 6e 65 77 n you have a new
34d0: 20 70 72 6f 62 6c 65 6d 2c 20 77 69 74 68 20 69 problem, with i
34e0: 73 20 74 68 61 74 20 74 68 6f 73 65 0a 20 20 23 s that those. #
34f0: 20 73 61 6d 65 20 63 68 61 72 61 63 74 65 72 73 same characters
3500: 20 61 72 65 6e 27 74 20 68 61 72 6d 6c 65 73 73 aren't harmless
3510: 3a 20 74 68 65 79 27 6c 6c 20 63 68 61 6e 67 65 : they'll change
3520: 20 74 68 65 20 76 65 72 79 20 63 6f 6e 74 65 78 the very contex
3530: 74 0a 20 20 23 20 77 65 27 72 65 20 74 72 79 69 t. # we're tryi
3540: 6e 67 20 74 6f 20 70 72 6f 62 65 21 20 20 46 6f ng to probe! Fo
3550: 72 20 69 6e 73 74 61 6e 63 65 2c 20 61 20 43 74 r instance, a Ct
3560: 72 6c 2d 43 20 73 65 6e 74 20 74 6f 20 74 68 65 rl-C sent to the
3570: 20 4f 53 2f 38 0a 20 20 23 20 4b 65 79 62 6f 61 OS/8. # Keyboa
3580: 72 64 20 4d 6f 6e 69 74 6f 72 20 6a 75 73 74 20 rd Monitor just
3590: 72 65 73 75 6c 74 73 20 69 6e 20 61 6e 6f 74 68 results in anoth
35a0: 65 72 20 70 72 6f 6d 70 74 2c 20 62 75 74 20 61 er prompt, but a
35b0: 20 43 74 72 6c 2d 43 20 73 65 6e 74 0a 20 20 23 Ctrl-C sent. #
35c0: 20 74 6f 20 61 20 70 72 6f 67 72 61 6d 20 72 75 to a program ru
35d0: 6e 6e 69 6e 67 20 2a 75 6e 64 65 72 2a 20 4f 53 nning *under* OS
35e0: 2f 38 20 6d 69 67 68 74 20 6b 69 6c 6c 20 69 74 /8 might kill it
35f0: 2e 20 20 4f 72 20 69 74 20 6d 69 67 68 74 20 62 . Or it might b
3600: 65 0a 20 20 23 20 74 72 65 61 74 65 64 20 61 73 e. # treated as
3610: 20 69 6e 70 75 74 2e 20 20 4f 72 20 69 74 20 6d input. Or it m
3620: 69 67 68 74 20 62 65 20 69 67 6e 6f 72 65 64 20 ight be ignored
3630: 65 6e 74 69 72 65 6c 79 2e 0a 20 20 23 0a 20 20 entirely.. #.
3640: 23 20 54 68 65 72 65 20 69 73 20 6e 6f 20 6d 61 # There is no ma
3650: 67 69 63 20 73 65 71 75 65 6e 63 65 20 77 65 20 gic sequence we
3660: 63 61 6e 20 73 65 6e 64 20 74 6f 20 53 49 4d 48 can send to SIMH
3670: 20 6f 72 20 4f 53 2f 38 20 74 6f 20 72 65 74 75 or OS/8 to retu
3680: 72 6e 20 74 68 65 0a 20 20 23 20 73 79 73 74 65 rn the. # syste
3690: 6d 20 74 6f 20 4f 53 2f 38 20 4b 65 79 62 6f 61 m to OS/8 Keyboa
36a0: 72 64 20 4d 6f 6e 69 74 6f 72 20 63 6f 6e 74 65 rd Monitor conte
36b0: 78 74 20 77 69 74 68 6f 75 74 20 65 69 74 68 65 xt without eithe
36c0: 72 20 63 68 61 6e 67 69 6e 67 20 74 68 65 0a 20 r changing the.
36d0: 20 23 20 63 6f 6e 74 65 78 74 20 69 6e 20 73 6f # context in so
36e0: 6d 65 20 77 61 79 20 74 68 61 74 20 6d 69 67 68 me way that migh
36f0: 74 20 62 72 65 61 6b 20 74 68 65 20 63 61 6c 6c t break the call
3700: 65 72 27 73 20 6e 65 65 64 65 64 20 73 74 61 74 er's needed stat
3710: 65 20 28 65 2e 67 2e 0a 20 20 23 20 43 74 72 6c e (e.g.. # Ctrl
3720: 2d 45 2c 20 67 6f 20 37 36 30 30 29 20 6f 72 20 -E, go 7600) or
3730: 6c 6f 73 65 20 64 61 74 61 20 28 65 2e 67 2e 20 lose data (e.g.
3740: 43 74 72 6c 2d 43 29 20 6f 72 20 66 61 69 6c 20 Ctrl-C) or fail
3750: 65 6e 74 69 72 65 6c 79 20 28 65 2e 67 2e 0a 20 entirely (e.g..
3760: 20 23 20 45 6e 74 65 72 2e 29 20 20 49 74 27 73 # Enter.) It's
3770: 20 75 70 20 74 6f 20 74 68 65 20 63 61 6c 6c 65 up to the calle
3780: 72 20 74 6f 20 61 72 72 61 6e 67 65 20 74 68 69 r to arrange thi
3790: 73 2e 0a 0a 20 20 64 65 66 20 6f 73 38 5f 73 65 s... def os8_se
37a0: 6e 64 5f 63 6d 64 20 28 73 65 6c 66 2c 20 70 72 nd_cmd (self, pr
37b0: 6f 6d 70 74 2c 20 6c 69 6e 65 2c 20 64 65 62 75 ompt, line, debu
37c0: 67 3d 46 61 6c 73 65 2c 20 74 69 6d 65 6f 75 74 g=False, timeout
37d0: 3d 36 30 29 3a 0a 20 20 20 20 69 66 20 73 65 6c =60):. if sel
37e0: 66 2e 5f 63 6f 6e 74 65 78 74 20 21 3d 20 27 6f f._context != 'o
37f0: 73 38 27 3a 20 0a 20 20 20 20 20 20 70 72 69 6e s8': . prin
3800: 74 20 22 4f 53 2f 38 20 69 73 20 6e 6f 74 20 72 t "OS/8 is not r
3810: 75 6e 6e 69 6e 67 2e 20 43 61 6e 6e 6f 74 20 65 unning. Cannot e
3820: 78 65 63 75 74 65 3a 20 22 20 2b 20 6c 69 6e 65 xecute: " + line
3830: 20 0a 20 20 20 20 20 20 72 65 74 75 72 6e 0a 20 . return.
3840: 20 20 20 69 66 20 64 65 62 75 67 3a 0a 20 20 20 if debug:.
3850: 20 20 20 70 72 69 6e 74 20 22 6f 73 38 5f 73 65 print "os8_se
3860: 6e 64 5f 63 6d 64 3a 20 65 78 70 65 63 74 69 6e nd_cmd: expectin
3870: 67 3a 20 22 20 2b 20 70 72 6f 6d 70 74 0a 20 20 g: " + prompt.
3880: 20 20 20 20 70 72 69 6e 74 20 22 5c 74 4c 61 73 print "\tLas
3890: 74 20 6d 61 74 63 68 20 62 65 66 6f 72 65 3a 20 t match before:
38a0: 7b 22 20 2b 20 73 65 6c 66 2e 5f 63 68 69 6c 64 {" + self._child
38b0: 2e 62 65 66 6f 72 65 20 2b 20 22 7d 22 0a 20 20 .before + "}".
38c0: 20 20 20 20 70 72 69 6e 74 20 22 5c 74 4c 61 73 print "\tLas
38d0: 74 20 6d 61 74 63 68 20 61 66 74 65 72 3a 20 7b t match after: {
38e0: 22 20 2b 20 73 65 6c 66 2e 5f 63 68 69 6c 64 2e " + self._child.
38f0: 61 66 74 65 72 20 2b 20 22 7d 22 0a 20 20 20 20 after + "}".
3900: 73 65 6c 66 2e 5f 63 68 69 6c 64 2e 65 78 70 65 self._child.expe
3910: 63 74 20 28 22 5c 6e 25 73 24 22 20 25 20 70 72 ct ("\n%s$" % pr
3920: 6f 6d 70 74 2c 20 74 69 6d 65 6f 75 74 20 3d 20 ompt, timeout =
3930: 74 69 6d 65 6f 75 74 29 0a 20 20 20 20 73 65 6c timeout). sel
3940: 66 2e 6f 73 38 5f 73 65 6e 64 5f 6c 69 6e 65 20 f.os8_send_line
3950: 28 6c 69 6e 65 29 0a 0a 0a 20 20 23 23 23 23 20 (line)... ####
3960: 6f 73 38 5f 73 65 6e 64 5f 63 74 72 6c 20 23 23 os8_send_ctrl ##
3970: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3980: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3990: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
39a0: 23 0a 20 20 23 20 53 65 6e 64 20 61 20 63 6f 6e #. # Send a con
39b0: 74 72 6f 6c 20 63 68 61 72 61 63 74 65 72 20 74 trol character t
39c0: 6f 20 4f 53 2f 38 20 63 6f 72 72 65 73 70 6f 6e o OS/8 correspon
39d0: 64 69 6e 67 20 74 6f 20 74 68 65 20 41 53 43 49 ding to the ASCI
39e0: 49 20 6c 65 74 74 65 72 0a 20 20 23 20 67 69 76 I letter. # giv
39f0: 65 6e 2e 20 20 57 65 20 70 72 65 63 65 64 65 20 en. We precede
3a00: 69 74 20 77 69 74 68 20 74 68 65 20 4f 53 2f 38 it with the OS/8
3a10: 20 6b 65 79 62 6f 61 72 64 20 64 65 6c 61 79 2c keyboard delay,
3a20: 20 73 69 6e 63 65 20 77 65 27 72 65 0a 20 20 23 since we're. #
3a30: 20 70 72 6f 62 61 62 6c 79 20 66 6f 6c 6c 6f 77 probably follow
3a40: 69 6e 67 20 61 20 63 61 6c 6c 20 74 6f 20 6f 73 ing a call to os
3a50: 38 5f 73 65 6e 64 5f 6c 69 6e 65 20 6f 72 20 6f 8_send_line or o
3a60: 73 38 5f 73 65 6e 64 5f 63 6d 64 2e 0a 0a 20 20 s8_send_cmd...
3a70: 64 65 66 20 6f 73 38 5f 73 65 6e 64 5f 63 74 72 def os8_send_ctr
3a80: 6c 20 28 73 65 6c 66 2c 20 63 68 61 72 29 3a 0a l (self, char):.
3a90: 20 20 20 20 63 63 20 3d 20 63 68 61 72 5b 30 5d cc = char[0]
3aa0: 2e 6c 6f 77 65 72 20 28 29 0a 20 20 20 20 73 65 .lower (). se
3ab0: 6c 66 2e 6f 73 38 5f 6b 62 64 5f 64 65 6c 61 79 lf.os8_kbd_delay
3ac0: 20 28 29 0a 20 20 20 20 73 65 6c 66 2e 5f 63 68 (). self._ch
3ad0: 69 6c 64 2e 73 65 6e 64 63 6f 6e 74 72 6f 6c 20 ild.sendcontrol
3ae0: 28 63 63 29 0a 20 20 20 20 0a 20 20 20 20 69 66 (cc). . if
3af0: 20 63 63 20 3d 3d 20 27 65 27 3a 20 73 65 6c 66 cc == 'e': self
3b00: 2e 5f 63 6f 6e 74 65 78 74 20 3d 20 27 73 69 6d ._context = 'sim
3b10: 68 27 0a 0a 0a 20 20 23 23 23 23 20 6d 6b 5f 6f h'... #### mk_o
3b20: 73 38 5f 6e 61 6d 65 20 23 20 23 23 23 23 23 23 s8_name # ######
3b30: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3b40: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3b50: 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 #############.
3b60: 23 20 43 72 65 61 74 65 20 61 6e 20 4f 53 2f 38 # Create an OS/8
3b70: 20 66 69 6c 65 6e 61 6d 65 3a 20 6f 66 20 74 68 filename: of th
3b80: 65 20 66 6f 72 6d 20 58 58 58 58 58 58 2e 59 59 e form XXXXXX.YY
3b90: 0a 20 20 23 20 46 72 6f 6d 20 61 20 50 4f 53 49 . # From a POSI
3ba0: 58 20 70 61 74 68 2e 0a 0a 20 20 64 65 66 20 6d X path... def m
3bb0: 6b 5f 6f 73 38 5f 6e 61 6d 65 28 73 65 6c 66 2c k_os8_name(self,
3bc0: 20 64 65 76 2c 20 70 61 74 68 29 3a 0a 20 20 20 dev, path):.
3bd0: 20 62 6e 73 20 3d 20 6f 73 2e 70 61 74 68 2e 62 bns = os.path.b
3be0: 61 73 65 6e 61 6d 65 20 28 70 61 74 68 29 0a 20 asename (path).
3bf0: 20 20 20 62 6e 73 20 3d 20 72 65 2e 73 75 62 28 bns = re.sub(
3c00: 22 2d 7c 3a 7c 5c 28 7c 5c 29 7c 21 22 2c 20 22 "-|:|\(|\)|!", "
3c10: 22 2c 20 62 6e 73 29 0a 20 20 20 20 62 6e 73 20 ", bns). bns
3c20: 3d 20 62 6e 73 2e 75 70 70 65 72 28 29 0a 20 20 = bns.upper().
3c30: 20 20 69 66 20 22 2e 22 20 6e 6f 74 20 69 6e 20 if "." not in
3c40: 62 6e 73 3a 0a 20 20 20 20 20 20 72 65 74 75 72 bns:. retur
3c50: 6e 20 64 65 76 20 2b 20 62 6e 73 5b 3a 6d 69 6e n dev + bns[:min
3c60: 28 36 2c 20 6c 65 6e 28 62 6e 73 29 29 5d 0a 20 (6, len(bns))].
3c70: 20 20 20 65 6c 73 65 3a 0a 20 20 20 20 20 20 64 else:. d
3c80: 6f 74 20 3d 20 62 6e 73 2e 69 6e 64 65 78 28 27 ot = bns.index('
3c90: 2e 27 29 0a 20 20 20 20 20 20 72 65 74 75 72 6e .'). return
3ca0: 20 64 65 76 20 2b 20 62 6e 73 5b 3a 6d 69 6e 28 dev + bns[:min(
3cb0: 36 2c 20 64 6f 74 2c 20 6c 65 6e 28 62 6e 73 29 6, dot, len(bns)
3cc0: 29 5d 20 2b 20 22 2e 22 20 2b 20 62 6e 73 5b 64 )] + "." + bns[d
3cd0: 6f 74 2b 31 3a 20 64 6f 74 2b 33 5d 0a 0a 0a 20 ot+1: dot+3]...
3ce0: 20 23 23 23 23 20 6f 73 38 5f 73 65 6e 64 5f 66 #### os8_send_f
3cf0: 69 6c 65 20 23 23 23 23 23 23 23 23 23 23 23 23 ile ############
3d00: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3d10: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3d20: 23 23 23 23 23 23 23 0a 20 20 23 20 53 65 6e 64 #######. # Send
3d30: 20 61 20 63 6f 70 79 20 6f 66 20 61 20 6c 6f 63 a copy of a loc
3d40: 61 6c 20 74 65 78 74 20 66 69 6c 65 20 74 6f 20 al text file to
3d50: 4f 53 2f 38 2e 20 20 54 68 65 20 6c 6f 63 61 6c OS/8. The local
3d60: 20 70 61 74 68 20 6d 61 79 0a 20 20 23 20 63 6f path may. # co
3d70: 6e 74 61 69 6e 20 64 69 72 65 63 74 6f 72 79 20 ntain directory
3d80: 63 6f 6d 70 6f 6e 65 6e 74 73 2c 20 62 75 74 20 components, but
3d90: 74 68 65 20 72 65 6d 6f 74 65 20 6d 75 73 74 20 the remote must
3da0: 6e 6f 74 2c 20 6f 66 20 63 6f 75 72 73 65 2e 0a not, of course..
3db0: 20 20 23 0a 20 20 23 20 49 66 20 74 68 65 20 64 #. # If the d
3dc0: 65 73 74 69 6e 61 74 69 6f 6e 20 66 69 6c 65 20 estination file
3dd0: 6e 61 6d 65 20 69 73 20 6e 6f 74 20 75 70 70 65 name is not uppe
3de0: 72 63 61 73 65 2c 20 69 74 20 77 69 6c 6c 20 62 rcase, it will b
3df0: 65 20 73 6f 20 66 6f 72 63 65 64 2e 0a 20 20 23 e so forced.. #
3e00: 0a 20 20 23 20 49 66 20 74 68 65 20 64 65 73 74 . # If the dest
3e10: 69 6e 61 74 69 6f 6e 20 66 69 6c 65 20 6e 61 6d ination file nam
3e20: 65 20 69 73 20 6e 6f 74 20 67 69 76 65 6e 2c 20 e is not given,
3e30: 69 74 20 69 73 20 74 61 6b 65 6e 20 61 73 20 74 it is taken as t
3e40: 68 65 0a 20 20 23 20 62 61 73 65 6e 61 6d 65 20 he. # basename
3e50: 6f 66 20 74 68 65 20 73 6f 75 72 63 65 20 66 69 of the source fi
3e60: 6c 65 20 6e 61 6d 65 2e 0a 20 20 23 0a 20 20 23 le name.. #. #
3e70: 20 54 68 65 20 66 69 6c 65 20 69 73 20 73 65 6e The file is sen
3e80: 74 20 76 69 61 20 74 68 65 20 53 49 4d 48 20 70 t via the SIMH p
3e90: 61 70 65 72 20 74 61 70 65 20 64 65 76 69 63 65 aper tape device
3ea0: 20 74 68 72 6f 75 67 68 20 50 49 50 20 69 6e 20 through PIP in
3eb0: 69 74 73 0a 20 20 23 20 64 65 66 61 75 6c 74 20 its. # default
3ec0: 41 53 43 49 49 20 6d 6f 64 65 2c 20 72 61 74 68 ASCII mode, rath
3ed0: 65 72 20 74 68 61 6e 20 63 68 61 72 61 63 74 65 er than characte
3ee0: 72 20 62 79 20 63 68 61 72 61 63 74 65 72 20 66 r by character f
3ef0: 6f 72 20 74 77 6f 20 72 65 61 73 6f 6e 73 3a 0a or two reasons:.
3f00: 20 20 23 0a 20 20 23 20 31 2e 20 49 74 27 73 20 #. # 1. It's
3f10: 66 61 73 74 65 72 2e 20 20 49 74 20 72 75 6e 73 faster. It runs
3f20: 20 61 73 20 66 61 73 74 20 61 73 20 74 68 65 20 as fast as the
3f30: 73 69 6d 75 6c 61 74 6f 72 20 63 61 6e 20 70 72 simulator can pr
3f40: 6f 63 65 73 73 20 74 68 65 0a 20 20 23 20 20 20 ocess the. #
3f50: 20 49 2f 4f 20 69 6e 73 74 72 75 63 74 69 6f 6e I/O instruction
3f60: 73 2c 20 77 69 74 68 6f 75 74 20 61 6e 79 20 6f s, without any o
3f70: 73 38 5f 6b 62 64 5f 64 65 6c 61 79 28 29 20 68 s8_kbd_delay() h
3f80: 6f 6f 65 79 2e 0a 20 20 23 0a 20 20 23 20 32 2e ooey.. #. # 2.
3f90: 20 49 74 20 61 6c 6c 6f 77 73 20 6c 6f 77 65 72 It allows lower
3fa0: 63 61 73 65 20 69 6e 70 75 74 20 72 65 67 61 72 case input regar
3fb0: 64 6c 65 73 73 20 6f 66 20 74 68 65 20 77 61 79 dless of the way
3fc0: 20 74 68 65 20 73 69 6d 75 6c 61 74 6f 72 20 69 the simulator i
3fd0: 73 0a 20 20 23 20 20 20 20 63 6f 6e 66 69 67 75 s. # configu
3fe0: 72 65 64 2e 20 20 41 53 43 49 49 20 69 73 20 41 red. ASCII is A
3ff0: 53 43 49 49 2e 0a 20 20 23 0a 20 20 23 20 45 6e SCII.. #. # En
4000: 74 72 79 20 63 6f 6e 74 65 78 74 20 73 68 6f 75 try context shou
4010: 6c 64 20 62 65 20 69 6e 73 69 64 65 20 4f 53 2f ld be inside OS/
4020: 38 2e 20 20 45 78 69 74 20 63 6f 6e 74 65 78 74 8. Exit context
4030: 20 69 73 20 69 6e 73 69 64 65 20 4f 53 2f 38 2e is inside OS/8.
4040: 0a 0a 20 20 64 65 66 20 6f 73 38 5f 73 65 6e 64 .. def os8_send
4050: 5f 66 69 6c 65 20 28 73 65 6c 66 2c 20 73 6f 75 _file (self, sou
4060: 72 63 65 2c 20 64 65 73 74 20 3d 20 4e 6f 6e 65 rce, dest = None
4070: 29 3a 0a 20 20 20 20 23 20 43 72 65 61 74 65 20 ):. # Create
4080: 70 61 74 68 20 61 6e 64 20 66 69 6c 65 20 6e 61 path and file na
4090: 6d 65 73 20 6e 6f 74 20 67 69 76 65 6e 0a 20 20 mes not given.
40a0: 20 20 62 6e 73 20 3d 20 6f 73 2e 70 61 74 68 2e bns = os.path.
40b0: 62 61 73 65 6e 61 6d 65 20 28 73 6f 75 72 63 65 basename (source
40c0: 29 0a 20 20 20 20 69 66 20 64 65 73 74 20 3d 3d ). if dest ==
40d0: 20 4e 6f 6e 65 3a 20 64 65 73 74 20 3d 20 62 6e None: dest = bn
40e0: 73 0a 20 20 20 20 64 65 73 74 20 3d 20 64 65 73 s. dest = des
40f0: 74 2e 75 70 70 65 72 20 28 29 0a 0a 20 20 20 20 t.upper ()..
4100: 23 20 43 6f 6e 76 65 72 74 20 74 65 78 74 20 66 # Convert text f
4110: 69 6c 65 20 74 6f 20 53 49 4d 48 20 70 61 70 65 ile to SIMH pape
4120: 72 20 74 61 70 65 20 66 6f 72 6d 61 74 0a 20 20 r tape format.
4130: 20 20 62 64 69 72 20 3d 20 70 69 64 70 38 69 2e bdir = pidp8i.
4140: 64 69 72 73 2e 62 75 69 6c 64 0a 20 20 20 20 70 dirs.build. p
4150: 74 20 20 20 3d 20 6f 73 2e 70 61 74 68 2e 6a 6f t = os.path.jo
4160: 69 6e 20 28 62 64 69 72 2c 20 27 6f 62 6a 27 2c in (bdir, 'obj',
4170: 20 62 6e 73 20 2b 20 27 2e 70 74 27 29 0a 20 20 bns + '.pt').
4180: 20 20 74 6f 6f 6c 20 3d 20 6f 73 2e 70 61 74 68 tool = os.path
4190: 2e 6a 6f 69 6e 20 28 62 64 69 72 2c 20 27 62 69 .join (bdir, 'bi
41a0: 6e 27 2c 20 27 74 78 74 32 70 74 70 27 29 0a 20 n', 'txt2ptp').
41b0: 20 20 20 73 75 62 70 72 6f 63 65 73 73 2e 63 61 subprocess.ca
41c0: 6c 6c 20 28 74 6f 6f 6c 20 2b 20 27 20 3c 20 27 ll (tool + ' < '
41d0: 20 2b 20 73 6f 75 72 63 65 20 2b 20 27 20 3e 20 + source + ' >
41e0: 27 20 2b 20 70 74 2c 20 73 68 65 6c 6c 20 3d 20 ' + pt, shell =
41f0: 54 72 75 65 29 0a 0a 20 20 20 20 23 20 50 61 70 True).. # Pap
4200: 65 72 20 74 61 70 65 20 63 72 65 61 74 65 64 2c er tape created,
4210: 20 73 6f 20 61 74 74 61 63 68 20 69 74 20 72 65 so attach it re
4220: 61 64 2d 6f 6e 6c 79 20 61 6e 64 20 63 6f 70 79 ad-only and copy
4230: 20 69 74 20 69 6e 2e 20 20 57 65 27 72 65 0a 20 it in. We're.
4240: 20 20 20 23 20 72 65 6c 79 69 6e 67 20 6f 6e 20 # relying on
4250: 74 78 74 32 70 74 70 20 74 6f 20 69 6e 73 65 72 txt2ptp to inser
4260: 74 20 74 68 65 20 43 74 72 6c 2d 5a 20 45 4f 46 t the Ctrl-Z EOF
4270: 20 6d 61 72 6b 65 72 20 61 74 20 74 68 65 20 65 marker at the e
4280: 6e 64 20 6f 66 0a 20 20 20 20 23 20 74 68 65 20 nd of. # the
4290: 66 69 6c 65 2e 0a 20 20 20 20 73 65 6c 66 2e 62 file.. self.b
42a0: 61 63 6b 5f 74 6f 5f 63 6d 64 20 28 27 5c 5c 2e ack_to_cmd ('\\.
42b0: 27 29 0a 20 20 20 20 73 65 6c 66 2e 73 65 6e 64 '). self.send
42c0: 5f 63 6d 64 20 28 27 61 74 74 61 63 68 20 2d 72 _cmd ('attach -r
42d0: 20 70 74 72 20 27 20 2b 20 70 74 29 0a 20 20 20 ptr ' + pt).
42e0: 20 73 65 6c 66 2e 6f 73 38 5f 72 65 73 74 61 72 self.os8_restar
42f0: 74 20 28 29 0a 20 20 20 20 73 65 6c 66 2e 6f 73 t (). self.os
4300: 38 5f 73 65 6e 64 5f 63 6d 64 20 28 27 5c 5c 2e 8_send_cmd ('\\.
4310: 27 2c 20 27 52 20 50 49 50 27 29 0a 20 20 20 20 ', 'R PIP').
4320: 73 65 6c 66 2e 6f 73 38 5f 73 65 6e 64 5f 63 6d self.os8_send_cm
4330: 64 20 28 27 5c 5c 2a 27 2c 20 64 65 73 74 20 2b d ('\\*', dest +
4340: 20 27 3c 50 54 52 3a 27 29 0a 20 20 20 20 73 65 '<PTR:'). se
4350: 6c 66 2e 5f 63 68 69 6c 64 2e 65 78 70 65 63 74 lf._child.expect
4360: 20 28 27 5c 5c 5e 27 29 0a 20 20 20 20 73 65 6c ('\\^'). sel
4370: 66 2e 6f 73 38 5f 73 65 6e 64 5f 63 74 72 6c 20 f.os8_send_ctrl
4380: 28 27 5b 27 29 20 20 20 20 20 20 23 20 66 69 6e ('[') # fin
4390: 69 73 68 20 74 72 61 6e 73 66 65 72 0a 20 20 20 ish transfer.
43a0: 20 73 65 6c 66 2e 5f 63 68 69 6c 64 2e 65 78 70 self._child.exp
43b0: 65 63 74 20 28 27 5c 5c 2a 27 29 0a 20 20 20 20 ect ('\\*').
43c0: 73 65 6c 66 2e 6f 73 38 5f 73 65 6e 64 5f 63 74 self.os8_send_ct
43d0: 72 6c 20 28 27 5b 27 29 20 20 20 20 20 20 23 20 rl ('[') #
43e0: 65 78 69 74 20 50 49 50 0a 0a 0a 20 20 23 23 23 exit PIP... ###
43f0: 23 20 70 69 70 5f 65 72 72 6f 72 5f 68 61 6e 64 # pip_error_hand
4400: 6c 65 72 20 23 23 23 23 23 23 23 23 23 23 23 23 ler ############
4410: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
4420: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
4430: 23 23 23 0a 20 20 23 20 43 6f 6d 6d 6f 6e 20 65 ###. # Common e
4440: 72 72 6f 72 20 68 61 6e 64 6c 65 72 20 66 6f 72 rror handler for
4450: 20 6f 73 38 5f 70 69 70 5f 74 6f 20 61 6e 64 20 os8_pip_to and
4460: 6f 73 38 5f 70 69 70 5f 66 72 6f 6d 0a 0a 20 20 os8_pip_from..
4470: 64 65 66 20 70 69 70 5f 65 72 72 6f 72 5f 68 61 def pip_error_ha
4480: 6e 64 6c 65 72 28 73 65 6c 66 2c 20 63 61 6c 6c ndler(self, call
4490: 65 72 2c 20 72 65 70 6c 79 29 3a 0a 20 20 20 20 er, reply):.
44a0: 70 72 69 6e 74 20 22 50 49 50 20 65 72 72 6f 72 print "PIP error
44b0: 20 66 72 6f 6d 20 69 6e 73 69 64 65 20 22 20 2b from inside " +
44c0: 20 63 61 6c 6c 65 72 20 2b 20 22 3a 20 22 0a 20 caller + ": ".
44d0: 20 20 20 70 72 69 6e 74 20 22 5c 74 22 20 2b 20 print "\t" +
44e0: 73 65 6c 66 2e 5f 63 68 69 6c 64 2e 62 65 66 6f self._child.befo
44f0: 72 65 2e 73 74 72 69 70 28 29 0a 20 20 20 20 70 re.strip(). p
4500: 72 69 6e 74 20 22 5c 74 22 20 2b 20 73 65 6c 66 rint "\t" + self
4510: 2e 5f 63 68 69 6c 64 2e 61 66 74 65 72 2e 73 74 ._child.after.st
4520: 72 69 70 28 29 0a 20 20 20 20 0a 20 20 20 20 23 rip(). . #
4530: 20 57 61 73 20 74 68 69 73 20 65 72 72 6f 72 20 Was this error
4540: 66 61 74 61 6c 20 6f 72 20 64 6f 20 77 65 20 6e fatal or do we n
4550: 65 65 64 20 74 6f 20 63 6c 65 61 6e 20 75 70 3f eed to clean up?
4560: 0a 20 20 20 20 23 20 52 65 6d 65 6d 62 65 72 20 . # Remember
4570: 77 65 20 73 75 62 74 72 61 63 74 20 31 20 66 72 we subtract 1 fr
4580: 6f 6d 20 72 65 70 6c 79 20 74 6f 20 67 65 74 20 om reply to get
4590: 69 6e 64 65 78 20 69 6e 74 6f 20 65 72 72 6f 72 index into error
45a0: 20 74 61 62 6c 65 73 2e 0a 20 20 20 20 69 66 20 tables.. if
45b0: 6e 6f 74 20 73 65 6c 66 2e 5f 6f 73 38 5f 66 61 not self._os8_fa
45c0: 74 61 6c 5f 63 68 65 63 6b 5b 72 65 70 6c 79 20 tal_check[reply
45d0: 2d 20 31 5d 3a 0a 20 20 20 20 20 20 23 20 4e 6f - 1]:. # No
45e0: 6e 20 66 61 74 61 6c 20 65 72 72 6f 72 2e 20 20 n fatal error.
45f0: 45 78 69 74 20 70 69 70 20 74 6f 20 74 68 65 20 Exit pip to the
4600: 6d 6f 6e 69 74 6f 72 0a 20 20 20 20 20 20 73 65 monitor. se
4610: 6c 66 2e 6f 73 38 5f 73 65 6e 64 5f 63 74 72 6c lf.os8_send_ctrl
4620: 20 28 27 5b 27 29 20 20 20 20 20 20 23 20 65 78 ('[') # ex
4630: 69 74 20 50 49 50 0a 0a 0a 20 20 23 23 23 23 20 it PIP... ####
4640: 6f 73 38 5f 70 69 70 5f 74 6f 20 23 23 23 23 23 os8_pip_to #####
4650: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
4660: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
4670: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 20 ##############.
4680: 20 23 20 53 65 6e 64 20 61 20 63 6f 70 79 20 6f # Send a copy o
4690: 66 20 61 20 6c 6f 63 61 6c 20 66 69 6c 65 20 74 f a local file t
46a0: 6f 20 4f 53 2f 38 20 75 73 69 6e 67 20 50 49 50 o OS/8 using PIP
46b0: 2e 0a 20 20 23 0a 20 20 23 20 54 68 65 20 66 69 .. #. # The fi
46c0: 6c 65 20 69 73 20 73 65 6e 74 20 76 69 61 20 74 le is sent via t
46d0: 68 65 20 53 49 4d 48 20 70 61 70 65 72 20 74 61 he SIMH paper ta
46e0: 70 65 20 64 65 76 69 63 65 20 74 68 72 6f 75 67 pe device throug
46f0: 68 20 50 49 50 0a 20 20 23 20 73 70 65 63 69 66 h PIP. # specif
4700: 79 69 6e 67 20 61 20 74 72 61 6e 73 66 65 72 20 ying a transfer
4710: 6f 70 74 69 6f 6e 2e 20 20 49 66 20 6e 6f 20 6f option. If no o
4720: 70 74 69 6f 6e 20 69 73 20 73 70 65 63 69 66 69 ption is specifi
4730: 65 64 2c 0a 20 20 23 20 41 53 43 49 49 20 69 73 ed,. # ASCII is
4740: 20 61 73 73 75 6d 65 64 2e 0a 20 20 23 0a 20 20 assumed.. #.
4750: 23 20 49 6e 20 41 53 43 49 49 20 6d 6f 64 65 2c # In ASCII mode,
4760: 20 77 65 20 70 72 65 2d 70 72 6f 63 65 73 73 20 we pre-process
4770: 77 69 74 68 20 74 78 74 32 70 74 70 20 77 68 69 with txt2ptp whi
4780: 63 68 20 74 72 61 6e 73 6c 61 74 65 73 0a 20 20 ch translates.
4790: 23 20 50 4f 53 49 58 20 41 53 43 49 49 20 63 6f # POSIX ASCII co
47a0: 6e 76 65 6e 74 69 6f 6e 73 20 74 6f 20 4f 53 2f nventions to OS/
47b0: 38 20 63 6f 6e 76 65 6e 74 69 6f 6e 73 2e 20 20 8 conventions.
47c0: 49 6e 20 61 6c 6c 20 6f 74 68 65 72 0a 20 20 23 In all other. #
47d0: 20 6d 6f 64 65 73 2c 20 77 65 20 64 6f 20 6e 6f modes, we do no
47e0: 74 20 64 6f 20 61 6e 79 20 74 72 61 6e 73 6c 61 t do any transla
47f0: 74 69 6f 6e 2e 0a 20 20 23 0a 20 20 23 20 48 6f tion.. #. # Ho
4800: 77 65 76 65 72 2c 20 77 65 20 73 68 6f 75 6c 64 wever, we should
4810: 20 73 75 70 70 6c 79 20 61 20 73 61 63 72 69 66 supply a sacrif
4820: 69 63 69 61 6c 20 4e 55 4c 4c 20 61 73 20 61 6e icial NULL as an
4830: 20 61 64 64 69 74 69 6f 6e 61 6c 20 63 68 61 72 additional char
4840: 61 63 74 65 72 0a 20 20 23 20 62 65 63 61 75 73 acter. # becaus
4850: 65 20 74 68 65 20 4f 53 2f 38 20 50 54 52 20 64 e the OS/8 PTR d
4860: 72 69 76 65 72 20 74 68 72 6f 77 73 20 74 68 65 river throws the
4870: 20 6c 61 73 74 20 63 68 61 72 61 63 74 65 72 20 last character
4880: 61 77 61 79 2e 20 28 4e 4f 54 20 44 4f 4e 45 20 away. (NOT DONE
4890: 59 45 54 29 0a 20 20 23 0a 20 20 23 20 45 6e 74 YET). #. # Ent
48a0: 72 79 20 63 6f 6e 74 65 78 74 20 73 68 6f 75 6c ry context shoul
48b0: 64 20 62 65 20 69 6e 73 69 64 65 20 4f 53 2f 38 d be inside OS/8
48c0: 2e 20 20 45 78 69 74 20 63 6f 6e 74 65 78 74 20 . Exit context
48d0: 69 73 20 69 6e 73 69 64 65 20 4f 53 2f 38 2e 0a is inside OS/8..
48e0: 0a 20 20 64 65 66 20 6f 73 38 5f 70 69 70 5f 74 . def os8_pip_t
48f0: 6f 20 28 73 65 6c 66 2c 20 70 61 74 68 2c 20 6f o (self, path, o
4900: 73 38 6e 61 6d 65 2c 20 6f 70 74 69 6f 6e 20 3d s8name, option =
4910: 20 4e 6f 6e 65 29 3a 0a 20 20 20 20 69 66 20 6f None):. if o
4920: 70 74 69 6f 6e 20 3d 3d 20 4e 6f 6e 65 3a 20 6f ption == None: o
4930: 70 74 69 6f 6e 20 3d 20 22 22 0a 20 20 20 20 23 ption = "". #
4940: 20 49 66 20 6f 73 38 6e 61 6d 65 20 69 73 20 6a If os8name is j
4950: 75 73 74 20 61 20 64 65 76 69 63 65 2c 20 73 79 ust a device, sy
4960: 6e 74 68 65 73 69 7a 65 20 61 6e 20 75 70 63 61 nthesize an upca
4970: 73 65 64 20 6e 61 6d 65 20 66 72 6f 6d 0a 20 20 sed name from.
4980: 20 20 23 20 74 68 65 20 50 4f 53 49 58 20 66 69 # the POSIX fi
4990: 6c 65 20 62 61 73 65 6e 61 6d 65 2e 0a 20 20 20 le basename..
49a0: 20 69 66 20 6e 6f 74 20 6f 73 2e 70 61 74 68 2e if not os.path.
49b0: 65 78 69 73 74 73 28 70 61 74 68 29 3a 0a 20 20 exists(path):.
49c0: 20 20 20 20 70 72 69 6e 74 20 70 61 74 68 20 2b print path +
49d0: 20 22 20 6e 6f 74 20 66 6f 75 6e 64 2e 20 53 6b " not found. Sk
49e0: 69 70 70 69 6e 67 2e 22 0a 20 20 20 20 20 20 72 ipping.". r
49f0: 65 74 75 72 6e 0a 20 20 20 20 6d 20 3d 20 72 65 eturn. m = re
4a00: 2e 6d 61 74 63 68 28 73 65 6c 66 2e 5f 6f 73 38 .match(self._os8
4a10: 5f 66 69 6c 65 5f 72 65 2c 20 6f 73 38 6e 61 6d _file_re, os8nam
4a20: 65 29 0a 20 20 20 20 69 66 20 6d 20 21 3d 20 4e e). if m != N
4a30: 6f 6e 65 20 61 6e 64 20 28 6d 2e 67 72 6f 75 70 one and (m.group
4a40: 28 32 29 20 3d 3d 20 4e 6f 6e 65 20 6f 72 20 6d (2) == None or m
4a50: 2e 67 72 6f 75 70 28 32 29 20 3d 3d 20 22 22 29 .group(2) == "")
4a60: 3a 0a 20 20 20 20 20 20 20 20 64 65 73 74 20 3d :. dest =
4a70: 20 73 65 6c 66 2e 6d 6b 5f 6f 73 38 5f 6e 61 6d self.mk_os8_nam
4a80: 65 28 6f 73 38 6e 61 6d 65 2c 20 70 61 74 68 29 e(os8name, path)
4a90: 0a 20 20 20 20 65 6c 73 65 3a 0a 20 20 20 20 20 . else:.
4aa0: 20 20 20 64 65 73 74 20 3d 20 6f 73 38 6e 61 6d dest = os8nam
4ab0: 65 0a 0a 20 20 20 20 64 69 64 5f 63 6f 6e 76 65 e.. did_conve
4ac0: 72 73 69 6f 6e 20 3d 20 46 61 6c 73 65 0a 20 20 rsion = False.
4ad0: 20 20 69 66 20 6f 70 74 69 6f 6e 20 3d 3d 20 22 if option == "
4ae0: 22 20 6f 72 20 6f 70 74 69 6f 6e 20 3d 3d 20 22 " or option == "
4af0: 2f 41 22 3a 0a 20 20 20 20 20 20 23 20 43 6f 6e /A":. # Con
4b00: 76 65 72 74 20 74 65 78 74 20 66 69 6c 65 20 74 vert text file t
4b10: 6f 20 53 49 4d 48 20 70 61 70 65 72 20 74 61 70 o SIMH paper tap
4b20: 65 20 66 6f 72 6d 61 74 20 69 6e 20 63 75 72 72 e format in curr
4b30: 65 6e 74 20 64 69 72 20 6f 66 20 70 61 74 68 2e ent dir of path.
4b40: 0a 20 20 20 20 20 20 69 66 20 73 65 6c 66 2e 76 . if self.v
4b50: 65 72 62 6f 73 65 3a 20 70 72 69 6e 74 20 22 46 erbose: print "F
4b60: 6f 72 6d 61 74 20 63 6f 6e 76 65 72 74 69 6e 67 ormat converting
4b70: 20 22 20 2b 20 70 61 74 68 0a 20 20 20 20 20 20 " + path.
4b80: 62 64 69 72 20 3d 20 70 69 64 70 38 69 2e 64 69 bdir = pidp8i.di
4b90: 72 73 2e 62 75 69 6c 64 0a 20 20 20 20 20 20 23 rs.build. #
4ba0: 20 43 72 65 61 74 65 20 75 6e 69 71 75 69 66 69 Create uniquifi
4bb0: 65 64 20 74 65 6d 70 20 70 61 74 68 20 6e 61 6d ed temp path nam
4bc0: 65 2e 0a 20 20 20 20 20 20 70 74 20 20 20 3d 20 e.. pt =
4bd0: 70 61 74 68 20 2b 20 22 2d 22 20 2b 20 73 74 72 path + "-" + str
4be0: 28 6f 73 2e 67 65 74 70 69 64 28 29 29 20 2b 20 (os.getpid()) +
4bf0: 22 2e 70 74 5f 74 65 6d 70 22 0a 20 20 20 20 20 ".pt_temp".
4c00: 20 74 6f 6f 6c 20 3d 20 6f 73 2e 70 61 74 68 2e tool = os.path.
4c10: 6a 6f 69 6e 20 28 62 64 69 72 2c 20 27 62 69 6e join (bdir, 'bin
4c20: 27 2c 20 27 74 78 74 32 70 74 70 27 29 0a 20 20 ', 'txt2ptp').
4c30: 20 20 20 20 73 75 62 70 72 6f 63 65 73 73 2e 63 subprocess.c
4c40: 61 6c 6c 20 28 74 6f 6f 6c 20 2b 20 27 20 3c 20 all (tool + ' <
4c50: 27 20 2b 20 70 61 74 68 20 2b 20 27 20 3e 20 27 ' + path + ' > '
4c60: 20 2b 20 70 74 2c 20 73 68 65 6c 6c 20 3d 20 54 + pt, shell = T
4c70: 72 75 65 29 0a 20 20 20 20 20 20 64 69 64 5f 63 rue). did_c
4c80: 6f 6e 76 65 72 73 69 6f 6e 20 3d 20 54 72 75 65 onversion = True
4c90: 0a 20 20 20 20 65 6c 69 66 20 6f 70 74 69 6f 6e . elif option
4ca0: 20 6e 6f 74 20 69 6e 20 73 65 6c 66 2e 5f 76 61 not in self._va
4cb0: 6c 69 64 5f 70 69 70 5f 6f 70 74 69 6f 6e 73 3a lid_pip_options:
4cc0: 0a 20 20 20 20 20 20 70 72 69 6e 74 20 22 49 6e . print "In
4cd0: 76 61 6c 69 64 20 50 49 50 20 6f 70 74 69 6f 6e valid PIP option
4ce0: 3a 20 22 20 2b 20 6f 70 74 69 6f 6e 20 2b 20 22 : " + option + "
4cf0: 2e 20 49 67 6e 6f 72 69 6e 67 3a 20 22 20 2b 20 . Ignoring: " +
4d00: 70 61 74 68 20 2b 20 22 20 74 6f 20 4f 53 2f 38 path + " to OS/8
4d10: 2e 22 0a 20 20 20 20 20 20 72 65 74 75 72 6e 0a .". return.
4d20: 20 20 20 20 65 6c 73 65 3a 0a 20 20 20 20 20 20 else:.
4d30: 70 74 20 3d 20 70 61 74 68 0a 0a 20 20 20 20 23 pt = path.. #
4d40: 20 54 4f 44 4f 3a 20 53 61 63 72 69 66 69 63 69 TODO: Sacrifici
4d50: 61 6c 20 65 78 74 72 61 20 63 68 61 72 61 63 74 al extra charact
4d60: 65 72 20 63 6f 64 65 20 67 6f 65 73 20 68 65 72 er code goes her
4d70: 65 2e 0a 0a 20 20 20 20 23 20 50 61 70 65 72 20 e... # Paper
4d80: 74 61 70 65 20 63 72 65 61 74 65 64 2c 20 73 6f tape created, so
4d90: 20 61 74 74 61 63 68 20 69 74 20 72 65 61 64 2d attach it read-
4da0: 6f 6e 6c 79 20 61 6e 64 20 63 6f 70 79 20 69 74 only and copy it
4db0: 20 69 6e 2e 20 20 57 65 27 72 65 0a 20 20 20 20 in. We're.
4dc0: 23 20 72 65 6c 79 69 6e 67 20 6f 6e 20 74 78 74 # relying on txt
4dd0: 32 70 74 70 20 74 6f 20 69 6e 73 65 72 74 20 74 2ptp to insert t
4de0: 68 65 20 43 74 72 6c 2d 5a 20 45 4f 46 20 6d 61 he Ctrl-Z EOF ma
4df0: 72 6b 65 72 20 61 74 20 74 68 65 20 65 6e 64 20 rker at the end
4e00: 6f 66 0a 20 20 20 20 23 20 74 68 65 20 66 69 6c of. # the fil
4e10: 65 2e 0a 20 20 20 20 73 65 6c 66 2e 62 61 63 6b e.. self.back
4e20: 5f 74 6f 5f 63 6d 64 20 28 27 5c 5c 2e 27 29 0a _to_cmd ('\\.').
4e30: 20 20 20 20 73 65 6c 66 2e 73 65 6e 64 5f 63 6d self.send_cm
4e40: 64 20 28 27 61 74 74 61 63 68 20 2d 72 20 70 74 d ('attach -r pt
4e50: 72 20 27 20 2b 20 70 74 29 0a 20 20 20 20 73 65 r ' + pt). se
4e60: 6c 66 2e 6f 73 38 5f 72 65 73 74 61 72 74 20 28 lf.os8_restart (
4e70: 29 0a 20 20 20 20 73 65 6c 66 2e 6f 73 38 5f 73 ). self.os8_s
4e80: 65 6e 64 5f 63 6d 64 20 28 27 5c 5c 2e 27 2c 20 end_cmd ('\\.',
4e90: 27 52 20 50 49 50 27 29 0a 20 20 20 20 23 20 57 'R PIP'). # W
4ea0: 61 73 20 74 68 65 20 73 74 61 72 74 20 6f 66 20 as the start of
4eb0: 50 49 50 20 73 75 63 63 65 73 73 66 75 6c 2c 20 PIP successful,
4ec0: 6f 72 20 64 69 64 20 77 65 20 67 65 74 20 61 20 or did we get a
4ed0: 4d 6f 6e 69 74 6f 72 20 65 72 72 6f 72 3f 0a 20 Monitor error?.
4ee0: 20 20 20 72 65 70 6c 79 20 3d 20 73 65 6c 66 2e reply = self.
4ef0: 5f 63 68 69 6c 64 2e 65 78 70 65 63 74 20 28 73 _child.expect (s
4f00: 65 6c 66 2e 5f 63 64 5f 72 65 70 6c 69 65 73 29 elf._cd_replies)
4f10: 0a 20 20 20 20 69 66 20 72 65 70 6c 79 20 21 3d . if reply !=
4f20: 20 30 3a 0a 20 20 20 20 20 20 73 65 6c 66 2e 70 0:. self.p
4f30: 69 70 5f 65 72 72 6f 72 5f 68 61 6e 64 6c 65 72 ip_error_handler
4f40: 20 28 22 6f 73 38 5f 70 69 70 5f 74 6f 22 2c 20 ("os8_pip_to",
4f50: 72 65 70 6c 79 29 0a 20 20 20 20 20 20 72 65 74 reply). ret
4f60: 75 72 6e 0a 0a 20 20 20 20 23 20 48 61 73 20 74 urn.. # Has t
4f70: 68 65 20 72 65 61 64 2d 69 6e 20 62 65 65 6e 20 he read-in been
4f80: 73 75 63 63 65 73 73 66 75 6c 3f 0a 20 20 20 20 successful?.
4f90: 73 65 6c 66 2e 6f 73 38 5f 73 65 6e 64 5f 6c 69 self.os8_send_li
4fa0: 6e 65 20 28 64 65 73 74 20 2b 20 27 3c 50 54 52 ne (dest + '<PTR
4fb0: 3a 27 20 2b 20 6f 70 74 69 6f 6e 29 0a 20 20 20 :' + option).
4fc0: 20 72 65 70 6c 79 20 3d 20 73 65 6c 66 2e 5f 63 reply = self._c
4fd0: 68 69 6c 64 2e 65 78 70 65 63 74 20 28 73 65 6c hild.expect (sel
4fe0: 66 2e 5f 70 69 70 5f 74 6f 5f 72 65 70 6c 69 65 f._pip_to_replie
4ff0: 73 29 0a 20 20 20 20 69 66 20 72 65 70 6c 79 20 s). if reply
5000: 21 3d 30 3a 0a 20 20 20 20 20 20 73 65 6c 66 2e !=0:. self.
5010: 70 69 70 5f 65 72 72 6f 72 5f 68 61 6e 64 6c 65 pip_error_handle
5020: 72 28 22 6f 73 38 5f 70 69 70 5f 74 6f 22 2c 20 r("os8_pip_to",
5030: 72 65 70 6c 79 29 0a 20 20 20 20 20 20 69 66 20 reply). if
5040: 64 69 64 5f 63 6f 6e 76 65 72 73 69 6f 6e 3a 0a did_conversion:.
5050: 20 20 20 20 20 20 20 20 6f 73 2e 72 65 6d 6f 76 os.remov
5060: 65 28 70 74 29 0a 20 20 20 20 20 20 72 65 74 75 e(pt). retu
5070: 72 6e 0a 0a 20 20 20 20 73 65 6c 66 2e 6f 73 38 rn.. self.os8
5080: 5f 73 65 6e 64 5f 63 74 72 6c 20 28 27 5b 27 29 _send_ctrl ('[')
5090: 20 20 20 20 20 20 23 20 66 69 6e 69 73 68 20 74 # finish t
50a0: 72 61 6e 73 66 65 72 0a 20 20 20 20 73 65 6c 66 ransfer. self
50b0: 2e 5f 63 68 69 6c 64 2e 65 78 70 65 63 74 20 28 ._child.expect (
50c0: 27 5c 5c 2a 27 29 0a 20 20 20 20 73 65 6c 66 2e '\\*'). self.
50d0: 6f 73 38 5f 73 65 6e 64 5f 63 74 72 6c 20 28 27 os8_send_ctrl ('
50e0: 5b 27 29 20 20 20 20 20 20 23 20 65 78 69 74 20 [') # exit
50f0: 50 49 50 0a 20 20 20 20 23 20 57 65 20 63 6f 75 PIP. # We cou
5100: 6c 64 20 64 65 74 61 63 68 20 70 74 72 20 61 6e ld detach ptr an
5110: 64 20 72 65 73 74 61 72 74 20 4f 53 2f 38 20 68 d restart OS/8 h
5120: 65 72 65 2c 20 62 75 74 20 77 65 20 64 6f 6e 27 ere, but we don'
5130: 74 20 6e 65 65 64 20 74 6f 2e 0a 20 20 20 20 23 t need to.. #
5140: 20 44 6f 20 72 65 6d 6f 76 65 20 74 68 65 20 74 Do remove the t
5150: 65 6d 70 20 66 69 6c 65 20 69 66 20 77 65 20 63 emp file if we c
5160: 72 65 61 74 65 64 20 6f 6e 65 2e 0a 20 20 20 20 reated one..
5170: 69 66 20 64 69 64 5f 63 6f 6e 76 65 72 73 69 6f if did_conversio
5180: 6e 3a 0a 20 20 20 20 20 20 6f 73 2e 72 65 6d 6f n:. os.remo
5190: 76 65 20 28 70 74 29 0a 0a 0a 20 20 23 23 23 23 ve (pt)... ####
51a0: 20 6f 73 38 5f 70 69 70 5f 66 72 6f 6d 20 23 23 os8_pip_from ##
51b0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
51c0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
51d0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
51e0: 23 0a 20 20 23 20 46 65 74 63 68 20 61 20 66 69 #. # Fetch a fi
51f0: 6c 65 20 66 72 6f 6d 20 4f 53 2f 38 20 74 6f 20 le from OS/8 to
5200: 61 20 6c 6f 63 61 6c 20 70 61 74 68 20 75 73 69 a local path usi
5210: 6e 67 20 50 49 50 2e 0a 20 20 23 0a 20 20 23 20 ng PIP.. #. #
5220: 54 68 65 20 4f 53 2f 38 20 73 6f 75 72 63 65 20 The OS/8 source
5230: 66 69 6c 65 6e 61 6d 65 20 69 73 20 73 79 6e 74 filename is synt
5240: 68 65 73 69 7a 65 64 20 66 72 6f 6d 20 74 68 65 hesized from the
5250: 20 62 61 73 65 6e 61 6d 65 20 6f 66 20 74 68 65 basename of the
5260: 20 70 61 74 68 2c 0a 20 20 23 20 75 70 63 61 73 path,. # upcas
5270: 69 6e 67 20 69 66 20 6e 65 63 65 73 73 61 72 79 ing if necessary
5280: 2e 0a 20 20 23 0a 20 20 23 20 54 68 65 20 66 69 .. #. # The fi
5290: 6c 65 20 69 73 20 73 65 6e 74 20 76 69 61 20 74 le is sent via t
52a0: 68 65 20 53 49 4d 48 20 70 61 70 65 72 20 74 61 he SIMH paper ta
52b0: 70 65 20 64 65 76 69 63 65 20 74 68 72 6f 75 67 pe device throug
52c0: 68 20 50 49 50 0a 20 20 23 20 73 70 65 63 69 66 h PIP. # specif
52d0: 79 69 6e 67 20 61 20 74 72 61 6e 73 66 65 72 20 ying a transfer
52e0: 6f 70 74 69 6f 6e 2e 20 20 49 66 20 6e 6f 20 6f option. If no o
52f0: 70 74 69 6f 6e 20 69 73 20 73 70 65 63 69 66 69 ption is specifi
5300: 65 64 2c 0a 20 20 23 20 41 53 43 49 49 20 69 73 ed,. # ASCII is
5310: 20 61 73 73 75 6d 65 64 2e 0a 20 20 23 0a 20 20 assumed.. #.
5320: 23 20 49 6e 20 41 53 43 49 49 20 6d 6f 64 65 2c # In ASCII mode,
5330: 20 77 65 20 70 6f 73 74 2d 70 72 6f 63 65 73 73 we post-process
5340: 20 77 69 74 68 20 70 74 70 32 74 78 74 20 77 68 with ptp2txt wh
5350: 69 63 68 20 74 72 61 6e 73 6c 61 74 65 73 0a 20 ich translates.
5360: 20 23 20 50 4f 53 49 58 20 41 53 43 49 49 20 63 # POSIX ASCII c
5370: 6f 6e 76 65 6e 74 69 6f 6e 73 20 74 6f 20 4f 53 onventions to OS
5380: 2f 38 20 63 6f 6e 76 65 6e 74 69 6f 6e 73 2e 20 /8 conventions.
5390: 20 49 6e 20 61 6c 6c 20 6f 74 68 65 72 0a 20 20 In all other.
53a0: 23 20 6d 6f 64 65 73 2c 20 77 65 20 64 6f 20 6e # modes, we do n
53b0: 6f 74 20 64 6f 20 61 6e 79 20 74 72 61 6e 73 6c ot do any transl
53c0: 61 74 69 6f 6e 2e 0a 20 20 23 0a 20 20 23 20 45 ation.. #. # E
53d0: 6e 74 72 79 20 63 6f 6e 74 65 78 74 20 73 68 6f ntry context sho
53e0: 75 6c 64 20 62 65 20 69 6e 73 69 64 65 20 4f 53 uld be inside OS
53f0: 2f 38 2e 20 20 45 78 69 74 20 63 6f 6e 74 65 78 /8. Exit contex
5400: 74 20 69 73 20 69 6e 73 69 64 65 20 4f 53 2f 38 t is inside OS/8
5410: 2e 0a 0a 20 20 64 65 66 20 6f 73 38 5f 70 69 70 ... def os8_pip
5420: 5f 66 72 6f 6d 20 28 73 65 6c 66 2c 20 6f 73 38 _from (self, os8
5430: 6e 61 6d 65 2c 20 70 61 74 68 2c 20 6f 70 74 69 name, path, opti
5440: 6f 6e 20 3d 20 4e 6f 6e 65 29 3a 0a 20 20 20 20 on = None):.
5450: 69 66 20 6f 70 74 69 6f 6e 20 3d 3d 20 4e 6f 6e if option == Non
5460: 65 3a 20 6f 70 74 69 6f 6e 20 3d 20 22 22 0a 20 e: option = "".
5470: 20 20 20 23 20 49 66 20 70 61 74 68 20 69 73 20 # If path is
5480: 6e 6f 74 20 61 20 66 69 6c 65 2c 20 75 73 65 20 not a file, use
5490: 74 68 65 20 6e 61 6d 65 20 70 6f 72 74 69 6f 6e the name portion
54a0: 20 6f 66 20 6f 73 38 6e 61 6d 65 2e 0a 20 20 20 of os8name..
54b0: 20 69 66 20 6f 73 2e 70 61 74 68 2e 69 73 64 69 if os.path.isdi
54c0: 72 28 70 61 74 68 29 3a 0a 20 20 20 20 20 20 63 r(path):. c
54d0: 6f 6c 6f 6e 20 3d 20 6f 73 38 6e 61 6d 65 2e 66 olon = os8name.f
54e0: 69 6e 64 28 27 3a 27 29 0a 20 20 20 20 20 20 69 ind(':'). i
54f0: 66 20 63 6f 6c 6f 6e 20 3d 3d 20 2d 31 3a 20 20 f colon == -1:
5500: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 23 20 #
5510: 4e 6f 20 64 65 76 2c 20 6a 75 73 74 20 61 20 6e No dev, just a n
5520: 61 6d 65 2e 0a 20 20 20 20 20 20 20 20 70 61 74 ame.. pat
5530: 68 20 3d 20 70 61 74 68 20 2b 20 22 2f 22 20 2b h = path + "/" +
5540: 20 6f 73 38 6e 61 6d 65 0a 20 20 20 20 20 20 65 os8name. e
5550: 6c 73 65 3a 0a 20 20 20 20 20 20 20 20 70 61 74 lse:. pat
5560: 68 20 3d 20 70 61 74 68 20 2b 20 22 2f 22 20 2b h = path + "/" +
5570: 20 6f 73 38 6e 61 6d 65 5b 63 6f 6c 6f 6e 2b 31 os8name[colon+1
5580: 3a 5d 0a 0a 20 20 20 20 69 66 20 6f 70 74 69 6f :].. if optio
5590: 6e 20 21 3d 20 22 22 20 61 6e 64 20 6f 70 74 69 n != "" and opti
55a0: 6f 6e 20 6e 6f 74 20 69 6e 20 73 65 6c 66 2e 5f on not in self._
55b0: 76 61 6c 69 64 5f 70 69 70 5f 6f 70 74 69 6f 6e valid_pip_option
55c0: 73 3a 0a 20 20 20 20 20 20 70 72 69 6e 74 20 22 s:. print "
55d0: 49 6e 76 61 6c 69 64 20 50 49 50 20 6f 70 74 69 Invalid PIP opti
55e0: 6f 6e 3a 20 22 20 2b 20 6f 70 74 69 6f 6e 20 2b on: " + option +
55f0: 20 22 2e 20 49 67 6e 6f 72 69 6e 67 20 6f 73 38 ". Ignoring os8
5600: 5f 70 69 70 5f 66 72 6f 6d 20 6f 6e 3a 20 22 20 _pip_from on: "
5610: 2b 20 70 61 74 68 0a 20 20 20 20 20 20 72 65 74 + path. ret
5620: 75 72 6e 0a 0a 20 20 20 20 73 65 6c 66 2e 62 61 urn.. self.ba
5630: 63 6b 5f 74 6f 5f 63 6d 64 20 28 27 5c 5c 2e 27 ck_to_cmd ('\\.'
5640: 29 0a 20 20 20 20 73 65 6c 66 2e 73 65 6e 64 5f ). self.send_
5650: 63 6d 64 20 28 27 61 74 74 61 63 68 20 70 74 70 cmd ('attach ptp
5660: 20 27 20 2b 20 70 61 74 68 29 0a 20 20 20 20 73 ' + path). s
5670: 65 6c 66 2e 6f 73 38 5f 72 65 73 74 61 72 74 20 elf.os8_restart
5680: 28 29 0a 20 20 20 20 0a 20 20 20 20 73 65 6c 66 (). . self
5690: 2e 6f 73 38 5f 73 65 6e 64 5f 63 6d 64 20 28 27 .os8_send_cmd ('
56a0: 5c 5c 2e 27 2c 20 27 52 20 50 49 50 27 29 0a 20 \\.', 'R PIP').
56b0: 20 20 20 23 20 57 61 73 20 74 68 65 20 73 74 61 # Was the sta
56c0: 72 74 20 6f 66 20 50 49 50 20 73 75 63 63 65 73 rt of PIP succes
56d0: 73 66 75 6c 20 6f 72 20 64 69 64 20 77 65 20 67 sful or did we g
56e0: 65 74 20 61 20 4d 6f 6e 69 74 6f 72 20 65 72 72 et a Monitor err
56f0: 6f 72 3f 0a 20 20 20 20 72 65 70 6c 79 20 3d 20 or?. reply =
5700: 73 65 6c 66 2e 5f 63 68 69 6c 64 2e 65 78 70 65 self._child.expe
5710: 63 74 20 28 73 65 6c 66 2e 5f 63 64 5f 72 65 70 ct (self._cd_rep
5720: 6c 69 65 73 29 0a 20 20 20 20 69 66 20 72 65 70 lies). if rep
5730: 6c 79 20 21 3d 20 30 3a 0a 20 20 20 20 20 20 73 ly != 0:. s
5740: 65 6c 66 2e 70 69 70 5f 65 72 72 6f 72 5f 68 61 elf.pip_error_ha
5750: 6e 64 6c 65 72 20 28 22 6f 73 38 5f 70 69 70 5f ndler ("os8_pip_
5760: 66 72 6f 6d 22 2c 20 72 65 70 6c 79 29 0a 20 20 from", reply).
5770: 20 20 20 20 72 65 74 75 72 6e 0a 20 20 20 20 0a return. .
5780: 20 20 20 20 73 65 6c 66 2e 6f 73 38 5f 73 65 6e self.os8_sen
5790: 64 5f 6c 69 6e 65 20 28 27 50 54 50 3a 3c 27 20 d_line ('PTP:<'
57a0: 2b 20 6f 73 38 6e 61 6d 65 20 2b 20 6f 70 74 69 + os8name + opti
57b0: 6f 6e 29 0a 0a 20 20 20 20 72 65 70 6c 79 20 3d on).. reply =
57c0: 20 73 65 6c 66 2e 5f 63 68 69 6c 64 2e 65 78 70 self._child.exp
57d0: 65 63 74 20 28 73 65 6c 66 2e 5f 63 64 5f 72 65 ect (self._cd_re
57e0: 70 6c 69 65 73 29 0a 20 20 20 20 69 66 20 72 65 plies). if re
57f0: 70 6c 79 20 21 3d 30 3a 0a 20 20 20 20 20 20 73 ply !=0:. s
5800: 65 6c 66 2e 70 69 70 5f 65 72 72 6f 72 5f 68 61 elf.pip_error_ha
5810: 6e 64 6c 65 72 20 28 22 6f 73 38 5f 70 69 70 5f ndler ("os8_pip_
5820: 66 72 6f 6d 22 2c 20 72 65 70 6c 79 29 0a 20 20 from", reply).
5830: 20 20 20 20 23 20 54 68 65 72 65 20 69 73 20 61 # There is a
5840: 6e 20 65 6d 70 74 79 20 50 54 50 20 66 69 6c 65 n empty PTP file
5850: 20 77 65 20 6e 65 65 64 20 74 6f 20 72 65 6d 6f we need to remo
5860: 76 65 2e 0a 20 20 20 20 20 20 6f 73 2e 72 65 6d ve.. os.rem
5870: 6f 76 65 28 70 61 74 68 29 0a 20 20 20 20 20 20 ove(path).
5880: 72 65 74 75 72 6e 0a 0a 20 20 20 20 73 65 6c 66 return.. self
5890: 2e 6f 73 38 5f 73 65 6e 64 5f 63 74 72 6c 20 28 .os8_send_ctrl (
58a0: 27 5b 27 29 20 20 20 20 20 20 23 20 65 78 69 74 '[') # exit
58b0: 20 50 49 50 0a 20 20 20 20 73 65 6c 66 2e 62 61 PIP. self.ba
58c0: 63 6b 5f 74 6f 5f 63 6d 64 20 28 27 5c 5c 2e 27 ck_to_cmd ('\\.'
58d0: 29 0a 20 20 20 20 73 65 6c 66 2e 73 65 6e 64 5f ). self.send_
58e0: 63 6d 64 20 28 27 64 65 74 61 63 68 20 70 74 70 cmd ('detach ptp
58f0: 27 29 20 20 23 20 43 6c 65 61 6e 20 66 6c 75 73 ') # Clean flus
5900: 68 20 6f 66 20 62 75 66 66 65 72 73 2e 0a 20 20 h of buffers..
5910: 20 20 73 65 6c 66 2e 6f 73 38 5f 72 65 73 74 61 self.os8_resta
5920: 72 74 20 28 29 0a 0a 20 20 20 20 69 66 20 6f 70 rt ().. if op
5930: 74 69 6f 6e 20 3d 3d 20 22 22 20 6f 72 20 6f 70 tion == "" or op
5940: 74 69 6f 6e 20 3d 3d 20 22 2f 41 22 3a 0a 20 20 tion == "/A":.
5950: 20 20 20 20 69 66 20 73 65 6c 66 2e 76 65 72 62 if self.verb
5960: 6f 73 65 3a 20 70 72 69 6e 74 20 22 46 6f 72 6d ose: print "Form
5970: 61 74 20 63 6f 6e 76 65 72 74 69 6e 67 20 22 20 at converting "
5980: 2b 20 70 61 74 68 0a 20 20 20 20 20 20 23 20 43 + path. # C
5990: 6f 6e 76 65 72 74 20 74 65 78 74 20 66 69 6c 65 onvert text file
59a0: 20 74 6f 20 53 49 4d 48 20 70 61 70 65 72 20 74 to SIMH paper t
59b0: 61 70 65 20 66 6f 72 6d 61 74 0a 20 20 20 20 20 ape format.
59c0: 20 62 64 69 72 20 3d 20 70 69 64 70 38 69 2e 64 bdir = pidp8i.d
59d0: 69 72 73 2e 62 75 69 6c 64 0a 20 20 20 20 20 20 irs.build.
59e0: 23 20 43 72 65 61 74 65 20 75 6e 69 71 75 69 66 # Create uniquif
59f0: 69 65 64 20 74 65 6d 70 20 70 61 74 68 20 6e 61 ied temp path na
5a00: 6d 65 2e 0a 20 20 20 20 20 20 70 66 20 3d 20 70 me.. pf = p
5a10: 61 74 68 20 2b 20 22 2d 22 20 2b 20 73 74 72 28 ath + "-" + str(
5a20: 6f 73 2e 67 65 74 70 69 64 28 29 29 20 2b 20 22 os.getpid()) + "
5a30: 2e 70 66 5f 74 65 6d 70 22 0a 20 20 20 20 20 20 .pf_temp".
5a40: 6f 73 2e 72 65 6e 61 6d 65 28 70 61 74 68 2c 20 os.rename(path,
5a50: 70 66 29 0a 20 20 20 20 20 20 74 6f 6f 6c 20 3d pf). tool =
5a60: 20 6f 73 2e 70 61 74 68 2e 6a 6f 69 6e 20 28 62 os.path.join (b
5a70: 64 69 72 2c 20 27 62 69 6e 27 2c 20 27 70 74 70 dir, 'bin', 'ptp
5a80: 32 74 78 74 27 29 0a 20 20 20 20 20 20 73 75 62 2txt'). sub
5a90: 70 72 6f 63 65 73 73 2e 63 61 6c 6c 20 28 74 6f process.call (to
5aa0: 6f 6c 20 2b 20 27 20 3c 20 27 20 2b 20 70 66 20 ol + ' < ' + pf
5ab0: 2b 20 27 20 3e 20 27 20 2b 20 70 61 74 68 2c 20 + ' > ' + path,
5ac0: 73 68 65 6c 6c 20 3d 20 54 72 75 65 29 0a 20 20 shell = True).
5ad0: 20 20 20 20 6f 73 2e 72 65 6d 6f 76 65 28 70 66 os.remove(pf
5ae0: 29 0a 0a 0a 20 20 23 23 23 23 20 6f 73 38 5f 73 )... #### os8_s
5af0: 65 6e 64 5f 6c 69 6e 65 20 23 23 23 23 23 23 23 end_line #######
5b00: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
5b10: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
5b20: 23 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 23 ############. #
5b30: 20 43 6f 72 65 20 6f 66 20 6f 73 38 5f 73 65 6e Core of os8_sen
5b40: 64 5f 63 6d 64 2e 20 20 41 6c 73 6f 20 75 73 65 d_cmd. Also use
5b50: 64 20 62 79 20 63 6f 64 65 20 74 68 61 74 20 6e d by code that n
5b60: 65 65 64 73 20 74 6f 20 73 65 6e 64 20 74 65 78 eeds to send tex
5b70: 74 0a 20 20 23 20 22 62 6c 69 6e 64 22 20 74 6f t. # "blind" to
5b80: 20 4f 53 2f 38 2c 20 77 69 74 68 6f 75 74 20 65 OS/8, without e
5b90: 78 70 65 63 74 69 6e 67 20 61 20 70 72 6f 6d 70 xpecting a promp
5ba0: 74 2c 20 61 73 20 77 68 65 6e 20 64 72 69 76 69 t, as when drivi
5bb0: 6e 67 20 45 44 49 54 2e 0a 0a 20 20 64 65 66 20 ng EDIT... def
5bc0: 6f 73 38 5f 73 65 6e 64 5f 6c 69 6e 65 20 28 73 os8_send_line (s
5bd0: 65 6c 66 2c 20 6c 69 6e 65 29 3a 0a 20 20 20 20 elf, line):.
5be0: 73 65 6c 66 2e 6f 73 38 5f 73 65 6e 64 5f 73 74 self.os8_send_st
5bf0: 72 20 28 6c 69 6e 65 29 0a 20 20 20 20 73 65 6c r (line). sel
5c00: 66 2e 5f 63 68 69 6c 64 2e 73 65 6e 64 20 28 22 f._child.send ("
5c10: 5c 72 22 29 0a 0a 0a 20 20 23 23 23 23 20 6f 73 \r")... #### os
5c20: 38 5f 73 65 6e 64 5f 73 74 72 20 23 23 23 23 23 8_send_str #####
5c30: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
5c40: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
5c50: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
5c60: 23 23 23 0a 20 20 23 20 43 6f 72 65 20 6f 66 20 ###. # Core of
5c70: 6f 73 38 5f 73 65 6e 64 5f 6c 69 6e 65 2e 20 20 os8_send_line.
5c80: 41 6c 73 6f 20 75 73 65 64 20 62 79 20 63 6f 64 Also used by cod
5c90: 65 20 74 68 61 74 20 6e 65 65 64 73 20 74 6f 20 e that needs to
5ca0: 73 65 6e 64 20 74 65 78 74 0a 20 20 23 20 22 62 send text. # "b
5cb0: 6c 69 6e 64 22 20 74 6f 20 4f 53 2f 38 2c 20 77 lind" to OS/8, w
5cc0: 69 74 68 6f 75 74 20 65 78 70 65 63 74 69 6e 67 ithout expecting
5cd0: 20 61 20 70 72 6f 6d 70 74 20 61 6e 64 20 77 69 a prompt and wi
5ce0: 74 68 6f 75 74 20 61 20 43 52 2c 20 61 73 0a 20 thout a CR, as.
5cf0: 20 23 20 77 68 65 6e 20 64 72 69 76 69 6e 67 20 # when driving
5d00: 54 45 43 4f 2e 0a 0a 20 20 64 65 66 20 6f 73 38 TECO... def os8
5d10: 5f 73 65 6e 64 5f 73 74 72 20 28 73 65 6c 66 2c _send_str (self,
5d20: 20 73 74 72 29 3a 0a 20 20 20 20 66 6f 72 20 69 str):. for i
5d30: 20 69 6e 20 78 72 61 6e 67 65 20 28 30 2c 20 6c in xrange (0, l
5d40: 65 6e 20 28 73 74 72 29 29 3a 0a 20 20 20 20 20 en (str)):.
5d50: 20 73 65 6c 66 2e 5f 63 68 69 6c 64 2e 73 65 6e self._child.sen
5d60: 64 20 28 73 74 72 5b 69 5d 29 0a 20 20 20 20 20 d (str[i]).
5d70: 20 73 65 6c 66 2e 6f 73 38 5f 6b 62 64 5f 64 65 self.os8_kbd_de
5d80: 6c 61 79 20 28 29 0a 0a 0a 20 20 23 23 23 23 20 lay ()... ####
5d90: 6f 73 38 5f 72 65 73 75 6d 65 20 23 23 23 23 23 os8_resume #####
5da0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
5db0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
5dc0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
5dd0: 23 23 0a 20 20 23 20 52 65 73 75 6d 65 20 4f 53 ##. # Resume OS
5de0: 2f 38 2e 0a 20 20 23 0a 20 20 23 20 49 74 20 77 /8.. #. # It w
5df0: 6f 75 6c 64 20 62 65 20 6e 69 63 65 20 69 66 20 ould be nice if
5e00: 77 65 20 63 6f 75 6c 64 20 6a 75 73 74 20 73 65 we could just se
5e10: 6e 64 20 20 74 68 65 20 22 63 6f 6e 74 22 20 63 nd the "cont" c
5e20: 6f 6d 6d 61 6e 64 0a 20 20 23 20 61 6e 64 20 68 ommand. # and h
5e30: 61 76 65 20 70 79 74 68 6f 6e 20 65 78 70 65 63 ave python expec
5e40: 74 20 61 6e 64 20 4f 53 2f 38 20 73 79 6e 63 68 t and OS/8 synch
5e50: 20 72 69 67 68 74 20 75 70 2e 0a 20 20 23 20 42 right up.. # B
5e60: 75 74 20 73 6f 20 66 61 72 20 77 65 20 68 61 76 ut so far we hav
5e70: 65 20 6e 6f 74 20 66 69 67 75 72 65 64 20 6f 75 e not figured ou
5e80: 74 20 68 6f 77 20 74 6f 20 64 6f 20 74 68 61 74 t how to do that
5e90: 2e 0a 20 20 23 20 54 6f 20 72 65 73 75 6d 65 20 .. # To resume
5ea0: 4f 53 2f 38 20 66 72 6f 6d 20 53 49 4d 48 20 77 OS/8 from SIMH w
5eb0: 65 20 6e 65 65 64 20 74 6f 20 70 72 6f 76 6f 6b e need to provok
5ec0: 65 20 61 20 70 72 6f 6d 70 74 2e 0a 20 20 23 20 e a prompt.. #
5ed0: 54 79 70 69 6e 67 20 61 20 72 75 62 6f 75 74 20 Typing a rubout
5ee0: 6f 72 20 5e 55 20 61 74 20 61 20 53 49 4d 48 20 or ^U at a SIMH
5ef0: 74 65 72 6d 69 6e 61 6c 20 73 65 73 73 69 6f 6e terminal session
5f00: 20 64 6f 65 73 20 74 68 69 73 2e 0a 20 20 23 20 does this.. #
5f10: 42 75 74 20 6e 6f 74 20 77 68 65 6e 20 53 49 4d But not when SIM
5f20: 48 20 69 73 20 72 75 6e 20 75 6e 64 65 72 20 70 H is run under p
5f30: 79 74 68 6f 6e 20 65 78 70 65 63 74 2e 0a 20 20 ython expect..
5f40: 23 20 57 65 20 64 6f 6e 27 74 20 6b 6e 6f 77 20 # We don't know
5f50: 77 68 79 2e 0a 20 20 23 0a 20 20 23 20 62 6f 6f why.. #. # boo
5f60: 74 20 77 6f 72 6b 73 0a 20 20 23 20 67 6f 20 37 t works. # go 7
5f70: 36 30 30 20 77 6f 72 6b 73 0a 20 20 23 20 5e 43 600 works. # ^C
5f80: 20 3c 70 61 75 73 65 3e 20 5c 6e 5c 72 20 77 6f <pause> \n\r wo
5f90: 72 6b 73 2e 0a 20 20 23 0a 20 20 23 20 54 68 65 rks.. #. # The
5fa0: 20 72 65 73 75 6d 65 20 63 6f 6d 6d 61 6e 64 20 resume command
5fb0: 75 73 65 73 20 74 68 65 20 5e 43 20 6d 65 74 68 uses the ^C meth
5fc0: 6f 64 20 61 73 20 74 68 65 20 6c 65 61 73 74 20 od as the least
5fd0: 64 69 73 72 75 70 74 69 76 65 0a 20 20 23 20 74 disruptive. # t
5fe0: 6f 20 73 79 73 74 65 6d 20 73 74 61 74 65 2e 0a o system state..
5ff0: 0a 20 20 64 65 66 20 6f 73 38 5f 72 65 73 75 6d . def os8_resum
6000: 65 20 28 73 65 6c 66 29 3a 0a 20 20 20 20 69 66 e (self):. if
6010: 20 73 65 6c 66 2e 5f 63 6f 6e 74 65 78 74 20 3d self._context =
6020: 3d 20 22 6f 73 38 22 3a 20 72 65 74 75 72 6e 20 = "os8": return
6030: 20 20 23 20 41 6c 72 65 61 64 79 20 72 75 6e 6e # Already runn
6040: 69 6e 67 2e 0a 20 20 20 20 0a 20 20 20 20 73 65 ing.. . se
6050: 6c 66 2e 73 65 6e 64 5f 63 6d 64 28 22 63 6f 6e lf.send_cmd("con
6060: 74 22 29 20 20 20 23 20 73 65 74 73 20 6f 73 38 t") # sets os8
6070: 20 63 6f 6e 74 65 78 74 20 66 6f 72 20 75 73 2e context for us.
6080: 0a 0a 20 20 20 20 23 20 4e 6f 77 20 70 72 6f 76 .. # Now prov
6090: 6f 6b 65 20 61 20 6b 65 79 62 6f 61 72 64 20 6d oke a keyboard m
60a0: 6f 6e 69 74 6f 72 20 70 72 6f 6d 70 74 2e 0a 20 onitor prompt..
60b0: 20 20 20 73 65 6c 66 2e 6f 73 38 5f 73 65 6e 64 self.os8_send
60c0: 5f 63 74 72 6c 28 27 63 27 29 0a 20 20 20 20 73 _ctrl('c'). s
60d0: 65 6c 66 2e 6f 73 38 5f 6b 62 64 5f 64 65 6c 61 elf.os8_kbd_dela
60e0: 79 28 29 0a 20 20 20 20 73 65 6c 66 2e 6f 73 38 y(). self.os8
60f0: 5f 73 65 6e 64 5f 73 74 72 28 27 5c 72 5c 6e 27 _send_str('\r\n'
6100: 29 0a 20 20 0a 0a 20 20 23 23 23 23 20 6f 73 38 ). .. #### os8
6110: 5f 72 65 73 74 61 72 74 20 23 23 23 23 23 23 23 _restart #######
6120: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
6130: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
6140: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
6150: 0a 20 20 23 20 43 61 6c 6c 65 64 20 77 68 69 6c . # Called whil
6160: 65 20 69 6e 20 74 68 65 20 53 49 4d 48 20 63 6f e in the SIMH co
6170: 6d 6d 61 6e 64 20 70 72 6f 6d 70 74 2c 20 74 68 mmand prompt, th
6180: 69 73 20 72 65 73 74 61 72 74 73 20 4f 53 2f 38 is restarts OS/8
6190: 2e 0a 20 20 23 0a 20 20 23 20 54 68 69 73 20 6f .. #. # This o
61a0: 6e 65 2d 6c 69 6e 65 20 66 75 6e 63 74 69 6f 6e ne-line function
61b0: 20 65 78 69 73 74 73 20 74 6f 20 61 62 73 74 72 exists to abstr
61c0: 61 63 74 20 74 68 65 20 6d 65 74 68 6f 64 20 77 act the method w
61d0: 65 20 75 73 65 20 61 6e 64 20 74 6f 0a 20 20 23 e use and to. #
61e0: 20 64 6f 63 75 6d 65 6e 74 20 74 68 65 20 72 65 document the re
61f0: 61 73 6f 6e 20 77 65 20 64 6f 20 69 74 20 74 68 ason we do it th
6200: 69 73 20 77 61 79 2e 0a 20 20 23 0a 20 20 23 20 is way.. #. #
6210: 43 75 72 72 65 6e 74 6c 79 20 77 65 20 64 6f 20 Currently we do
6220: 74 68 69 73 20 62 79 20 63 61 6c 6c 69 6e 67 20 this by calling
6230: 74 68 65 20 4f 53 2f 38 20 63 6f 6d 6d 61 6e 64 the OS/8 command
6240: 20 65 6e 74 72 79 20 70 6f 69 6e 74 2c 20 77 68 entry point, wh
6250: 69 63 68 0a 20 20 23 20 68 61 73 20 74 68 65 20 ich. # has the
6260: 76 69 72 74 75 65 20 74 68 61 74 20 69 74 20 66 virtue that it f
6270: 6f 72 63 65 73 20 61 6e 6f 74 68 65 72 20 2e 20 orces another .
6280: 70 72 6f 6d 70 74 2c 20 77 68 69 63 68 20 6b 65 prompt, which ke
6290: 65 70 73 20 74 68 65 0a 20 20 23 20 73 65 6e 64 eps the. # send
62a0: 2f 65 78 70 65 63 74 20 73 65 71 75 65 6e 63 69 /expect sequenci
62b0: 6e 67 20 73 69 6d 70 6c 65 20 77 68 65 6e 20 73 ng simple when s
62c0: 77 69 74 63 68 69 6e 67 20 62 65 74 77 65 65 6e witching between
62d0: 20 4f 53 2f 38 20 61 6e 64 20 53 49 4d 48 0a 20 OS/8 and SIMH.
62e0: 20 23 20 63 6f 6d 6d 61 6e 64 20 6d 6f 64 65 73 # command modes
62f0: 2e 0a 20 20 23 0a 20 20 23 20 54 68 61 74 20 69 .. #. # That i
6300: 73 20 77 68 79 20 77 65 20 64 6f 6e 27 74 20 75 s why we don't u
6310: 73 65 20 22 63 6f 6e 74 22 20 68 65 72 65 20 69 se "cont" here i
6320: 6e 73 74 65 61 64 3a 20 69 74 20 72 65 71 75 69 nstead: it requi
6330: 72 65 73 20 74 68 61 74 20 74 68 65 0a 20 20 23 res that the. #
6340: 20 63 61 6c 6c 65 72 20 61 6c 77 61 79 73 20 62 caller always b
6350: 65 20 61 77 61 72 65 20 6f 66 20 77 68 65 6e 20 e aware of when
6360: 74 68 65 20 2e 20 70 72 6f 6d 70 74 20 77 65 6e the . prompt wen
6370: 74 20 6f 75 74 3b 20 63 6f 6d 70 6c 69 63 61 74 t out; complicat
6380: 65 64 2e 0a 20 20 23 0a 20 20 23 20 41 6e 6f 74 ed.. #. # Anot
6390: 68 65 72 20 73 69 6d 70 6c 65 20 61 6c 74 65 72 her simple alter
63a0: 6e 61 74 69 76 65 20 69 73 20 22 62 6f 6f 74 20 native is "boot
63b0: 72 6b 30 22 2c 20 77 68 69 63 68 20 61 63 74 75 rk0", which actu
63c0: 61 6c 6c 79 20 62 65 6e 63 68 6d 61 72 6b 73 0a ally benchmarks.
63d0: 20 20 23 20 61 20 73 6d 69 64 67 65 20 66 61 73 # a smidge fas
63e0: 74 65 72 20 68 65 72 65 2e 20 20 57 65 20 63 68 ter here. We ch
63f0: 6f 6f 73 65 20 74 68 69 73 20 6d 65 74 68 6f 64 oose this method
6400: 20 69 6e 73 74 65 61 64 20 62 65 63 61 75 73 65 instead because
6410: 20 77 65 0a 20 20 23 20 65 78 70 65 63 74 20 74 we. # expect t
6420: 68 61 74 20 73 6f 6d 65 20 6f 66 20 6f 75 72 20 hat some of our
6430: 63 61 6c 6c 65 72 73 20 77 69 6c 6c 20 77 61 6e callers will wan
6440: 74 20 74 6f 20 64 6f 20 73 65 76 65 72 61 6c 20 t to do several
6450: 64 69 66 66 65 72 65 6e 74 0a 20 20 23 20 74 68 different. # th
6460: 69 6e 67 73 20 69 6e 20 61 20 73 69 6e 67 6c 65 ings in a single
6470: 20 4f 53 2f 38 20 73 65 73 73 69 6f 6e 2c 20 77 OS/8 session, w
6480: 68 69 63 68 20 72 65 62 6f 6f 74 69 6e 67 20 77 hich rebooting w
6490: 6f 75 6c 64 20 73 63 72 65 77 20 75 70 2e 0a 0a ould screw up...
64a0: 20 20 64 65 66 20 6f 73 38 5f 72 65 73 74 61 72 def os8_restar
64b0: 74 20 28 73 65 6c 66 29 3a 0a 20 20 20 20 73 65 t (self):. se
64c0: 6c 66 2e 73 65 6e 64 5f 63 6d 64 20 28 22 67 6f lf.send_cmd ("go
64d0: 20 37 36 30 30 22 29 0a 0a 0a 20 20 23 23 23 23 7600")... ####
64e0: 20 6f 73 38 5f 73 71 75 69 73 68 20 23 23 23 23 os8_squish ####
64f0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
6500: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
6510: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
6520: 23 23 23 23 0a 20 20 23 20 57 72 61 70 73 20 74 ####. # Wraps t
6530: 68 65 20 4f 53 2f 38 20 53 51 55 49 53 48 20 63 he OS/8 SQUISH c
6540: 6f 6d 6d 61 6e 64 20 66 6f 72 20 61 20 67 69 76 ommand for a giv
6550: 65 6e 20 64 65 76 69 63 65 2e 0a 0a 20 20 64 65 en device... de
6560: 66 20 6f 73 38 5f 73 71 75 69 73 68 20 28 73 65 f os8_squish (se
6570: 6c 66 2c 20 64 65 76 69 63 65 29 3a 0a 20 20 20 lf, device):.
6580: 20 73 65 6c 66 2e 6f 73 38 5f 73 65 6e 64 5f 63 self.os8_send_c
6590: 6d 64 20 28 27 5c 5c 2e 27 2c 20 22 53 51 55 49 md ('\\.', "SQUI
65a0: 53 48 20 22 20 2b 20 64 65 76 69 63 65 20 2b 20 SH " + device +
65b0: 22 3a 22 29 0a 20 20 20 20 73 65 6c 66 2e 6f 73 ":"). self.os
65c0: 38 5f 6b 62 64 5f 64 65 6c 61 79 20 28 29 0a 20 8_kbd_delay ().
65d0: 20 20 20 73 65 6c 66 2e 5f 63 68 69 6c 64 2e 73 self._child.s
65e0: 65 6e 64 20 28 22 59 5c 72 22 29 3b 0a 0a 0a 20 end ("Y\r");...
65f0: 20 23 23 23 23 20 6f 73 38 5f 7a 65 72 6f 5f 63 #### os8_zero_c
6600: 6f 72 65 20 23 23 23 23 23 23 23 23 23 23 23 23 ore ############
6610: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
6620: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
6630: 23 23 23 23 23 23 23 0a 20 20 23 20 53 74 61 72 #######. # Star
6640: 74 69 6e 67 20 66 72 6f 6d 20 4f 53 2f 38 20 63 ting from OS/8 c
6650: 6f 6e 74 65 78 74 2c 20 62 6f 75 6e 63 65 20 6f ontext, bounce o
6660: 75 74 20 74 6f 20 53 49 4d 48 20 63 6f 6e 74 65 ut to SIMH conte
6670: 78 74 20 61 6e 64 20 7a 65 72 6f 20 61 6c 6c 0a xt and zero all.
6680: 20 20 23 20 6f 66 20 63 6f 72 65 20 65 78 63 65 # of core exce
6690: 70 74 69 6e 67 3a 0a 20 20 23 0a 20 20 23 20 30 pting:. #. # 0
66a0: 2e 20 7a 65 72 6f 20 70 61 67 65 20 2d 20 6d 61 . zero page - ma
66b0: 6e 79 20 61 70 70 73 20 70 75 74 20 74 65 6d 70 ny apps put temp
66c0: 6f 72 61 72 79 20 64 61 74 61 20 68 65 72 65 0a orary data here.
66d0: 20 20 23 20 31 2e 20 74 68 65 20 74 6f 70 20 70 # 1. the top p
66e0: 61 67 65 73 20 6f 66 20 66 69 65 6c 64 73 20 31 ages of fields 1
66f0: 20 26 20 32 20 2d 20 4f 53 2f 38 20 69 73 20 72 & 2 - OS/8 is r
6700: 65 73 69 64 65 6e 74 20 68 65 72 65 0a 20 20 23 esident here. #
6710: 20 32 2e 20 74 68 65 20 74 6f 70 20 70 61 67 65 2. the top page
6720: 20 6f 66 20 66 69 65 6c 64 20 32 20 2d 20 4f 53 of field 2 - OS
6730: 2f 38 27 73 20 54 44 38 45 20 64 72 69 76 65 72 /8's TD8E driver
6740: 20 28 69 66 20 61 6e 79 29 20 6c 69 76 65 73 20 (if any) lives
6750: 68 65 72 65 0a 20 20 23 0a 20 20 23 20 57 65 20 here. #. # We
6760: 74 68 65 6e 20 72 65 73 74 61 72 74 20 4f 53 2f then restart OS/
6770: 38 2c 20 77 68 69 63 68 20 6d 65 61 6e 73 20 77 8, which means w
6780: 65 20 61 62 73 6f 6c 75 74 65 6c 79 20 6e 65 65 e absolutely nee
6790: 64 20 74 6f 20 64 6f 20 23 31 20 61 6e 64 0a 20 d to do #1 and.
67a0: 20 23 20 6d 61 79 20 6e 65 65 64 20 74 6f 20 64 # may need to d
67b0: 6f 20 23 32 2e 20 20 57 65 20 63 6f 75 6c 64 20 o #2. We could
67c0: 70 72 6f 62 61 62 6c 79 20 67 65 74 20 61 77 61 probably get awa
67d0: 79 20 77 69 74 68 20 7a 65 72 6f 69 6e 67 20 70 y with zeroing p
67e0: 61 67 65 20 30 2e 0a 20 20 23 0a 20 20 23 20 41 age 0.. #. # A
67f0: 6c 6c 20 6f 66 20 74 68 65 20 61 62 6f 76 65 20 ll of the above
6800: 65 78 70 6c 61 69 6e 73 20 77 68 79 20 77 65 20 explains why we
6810: 68 61 76 65 20 74 68 69 73 20 73 70 65 63 69 61 have this specia
6820: 6c 20 4f 53 2f 38 20 61 6c 74 65 72 6e 61 74 69 l OS/8 alternati
6830: 76 65 0a 20 20 23 20 74 6f 20 74 68 65 20 7a 65 ve. # to the ze
6840: 72 6f 5f 63 6f 72 65 28 29 20 6d 65 74 68 6f 64 ro_core() method
6850: 2e 0a 0a 20 20 64 65 66 20 6f 73 38 5f 7a 65 72 ... def os8_zer
6860: 6f 5f 63 6f 72 65 20 28 73 65 6c 66 29 3a 0a 20 o_core (self):.
6870: 20 20 20 73 65 6c 66 2e 62 61 63 6b 5f 74 6f 5f self.back_to_
6880: 63 6d 64 20 28 27 5c 5c 2e 27 29 0a 20 20 20 20 cmd ('\\.').
6890: 73 65 6c 66 2e 73 65 6e 64 5f 63 6d 64 20 28 27 self.send_cmd ('
68a0: 64 65 20 30 30 32 30 30 2d 30 37 35 37 37 20 30 de 00200-07577 0
68b0: 27 29 0a 20 20 20 20 73 65 6c 66 2e 73 65 6e 64 '). self.send
68c0: 5f 63 6d 64 20 28 27 64 65 20 31 30 30 30 30 2d _cmd ('de 10000-
68d0: 31 37 35 37 37 20 30 27 29 0a 20 20 20 20 73 65 17577 0'). se
68e0: 6c 66 2e 73 65 6e 64 5f 63 6d 64 20 28 27 64 65 lf.send_cmd ('de
68f0: 20 32 30 30 30 30 2d 32 37 35 37 37 20 30 27 29 20000-27577 0')
6900: 0a 20 20 20 20 73 65 6c 66 2e 73 65 6e 64 5f 63 . self.send_c
6910: 6d 64 20 28 27 64 65 20 33 30 30 30 30 2d 37 37 md ('de 30000-77
6920: 37 37 37 20 30 27 29 0a 20 20 20 20 73 65 6c 66 777 0'). self
6930: 2e 6f 73 38 5f 72 65 73 74 61 72 74 20 28 29 0a .os8_restart ().
6940: 0a 0a 20 20 23 23 23 23 20 71 75 69 74 20 23 23 .. #### quit ##
6950: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
6960: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
6970: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
6980: 23 23 23 23 23 23 23 23 23 23 0a 20 20 23 20 51 ##########. # Q
6990: 75 69 74 73 20 74 68 65 20 73 69 6d 75 6c 61 74 uits the simulat
69a0: 6f 72 20 61 6e 64 20 77 61 69 74 73 20 66 6f 72 or and waits for
69b0: 20 69 74 20 74 6f 20 65 78 69 74 0a 0a 20 20 64 it to exit.. d
69c0: 65 66 20 71 75 69 74 20 28 73 65 6c 66 29 3a 0a ef quit (self):.
69d0: 20 20 20 20 73 65 6c 66 2e 73 65 6e 64 5f 63 6d self.send_cm
69e0: 64 20 28 22 71 22 29 0a 20 20 20 20 73 65 6c 66 d ("q"). self
69f0: 2e 5f 63 68 69 6c 64 2e 65 78 70 65 63 74 20 28 ._child.expect (
6a00: 70 65 78 70 65 63 74 2e 45 4f 46 29 0a 0a 0a 20 pexpect.EOF)...
6a10: 20 23 23 23 23 20 72 65 61 64 5f 74 61 69 6c 20 #### read_tail
6a20: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
6a30: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
6a40: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
6a50: 23 23 23 23 23 23 23 0a 20 20 23 20 57 61 74 63 #######. # Watc
6a60: 68 20 66 6f 72 20 61 20 6c 69 74 65 72 61 6c 20 h for a literal
6a70: 73 74 72 69 6e 67 2c 20 74 68 65 6e 20 67 65 74 string, then get
6a80: 20 77 68 61 74 20 66 6f 6c 6c 6f 77 73 20 6f 6e what follows on
6a90: 20 74 68 61 74 20 6c 69 6e 65 2e 0a 0a 20 20 64 that line... d
6aa0: 65 66 20 72 65 61 64 5f 74 61 69 6c 20 28 73 65 ef read_tail (se
6ab0: 6c 66 2c 20 68 65 61 64 2c 20 74 69 6d 65 6f 75 lf, head, timeou
6ac0: 74 20 3d 20 2d 31 29 3a 0a 20 20 20 20 73 65 6c t = -1):. sel
6ad0: 66 2e 5f 63 68 69 6c 64 2e 65 78 70 65 63 74 5f f._child.expect_
6ae0: 65 78 61 63 74 20 28 5b 68 65 61 64 5d 2c 20 74 exact ([head], t
6af0: 69 6d 65 6f 75 74 29 0a 20 20 20 20 72 65 74 75 imeout). retu
6b00: 72 6e 20 73 65 6c 66 2e 5f 63 68 69 6c 64 2e 72 rn self._child.r
6b10: 65 61 64 6c 69 6e 65 20 28 29 0a 0a 0a 20 20 23 eadline ()... #
6b20: 23 23 23 20 73 65 6e 64 5f 63 6d 64 20 23 23 23 ### send_cmd ###
6b30: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
6b40: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
6b50: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
6b60: 23 23 23 23 23 0a 20 20 23 20 57 61 69 74 20 66 #####. # Wait f
6b70: 6f 72 20 61 20 53 49 4d 48 20 63 6f 6d 6d 61 6e or a SIMH comman
6b80: 64 20 70 72 6f 6d 70 74 20 61 6e 64 20 74 68 65 d prompt and the
6b90: 6e 20 73 65 6e 64 20 74 68 65 20 67 69 76 65 6e n send the given
6ba0: 20 63 6f 6d 6d 61 6e 64 2e 0a 20 20 23 20 49 66 command.. # If
6bb0: 20 77 65 20 61 72 65 20 6e 6f 74 20 69 6e 20 74 we are not in t
6bc0: 68 65 20 73 69 6d 68 20 63 6f 6e 74 65 78 74 20 he simh context
6bd0: 73 65 6e 64 20 5e 65 20 61 6e 64 20 73 65 74 20 send ^e and set
6be0: 63 6f 6e 74 65 78 74 20 22 73 69 6d 68 22 2e 0a context "simh"..
6bf0: 20 20 23 20 49 66 20 77 65 20 61 72 65 20 6e 6f # If we are no
6c00: 74 20 69 6e 20 73 69 6d 68 20 63 6f 6e 74 65 78 t in simh contex
6c10: 74 2c 20 73 65 6e 64 20 5e 65 20 73 65 74 20 63 t, send ^e set c
6c20: 6f 6e 74 65 78 74 20 22 73 69 6d 68 22 0a 20 20 ontext "simh".
6c30: 23 20 20 20 20 61 6e 64 20 68 6f 70 65 20 66 6f # and hope fo
6c40: 72 20 74 68 65 20 62 65 73 74 2e 0a 20 20 23 20 r the best.. #
6c50: 49 66 20 77 65 20 69 73 73 75 65 20 61 20 63 6f If we issue a co
6c60: 6d 6d 61 6e 64 20 74 68 61 74 20 65 6e 74 65 72 mmand that enter
6c70: 73 20 6f 73 38 20 63 6f 6e 74 65 78 74 2c 20 73 s os8 context, s
6c80: 65 74 20 63 6f 6e 74 65 78 74 20 22 6f 73 38 22 et context "os8"
6c90: 2e 0a 20 20 23 20 4e 6f 74 65 20 65 78 69 74 69 .. # Note exiti
6ca0: 6e 67 20 6f 75 74 20 6f 66 20 4f 53 2f 38 20 69 ng out of OS/8 i
6cb0: 6e 74 6f 20 74 68 65 20 53 49 4d 48 20 63 6f 6e nto the SIMH con
6cc0: 74 65 78 74 20 69 73 20 61 20 62 69 74 20 6f 66 text is a bit of
6cd0: 20 61 0a 20 20 23 20 74 72 61 70 20 64 6f 6f 72 a. # trap door
6ce0: 2e 20 52 65 73 79 6e 63 68 72 6f 6e 69 7a 69 6e . Resynchronizin
6cf0: 67 20 77 69 74 68 20 70 79 74 68 6f 6e 20 65 78 g with python ex
6d00: 70 65 63 74 20 72 65 71 75 69 72 65 73 20 70 72 pect requires pr
6d10: 6f 76 6f 6b 69 6e 67 0a 20 20 23 20 61 20 70 72 ovoking. # a pr
6d20: 6f 6d 70 74 2c 20 61 6e 64 20 70 72 6f 6d 70 74 ompt, and prompt
6d30: 73 20 61 72 65 20 63 6f 6e 74 65 78 74 20 73 70 s are context sp
6d40: 65 63 69 66 69 63 2e 0a 20 20 23 20 50 65 72 68 ecific.. # Perh
6d50: 61 70 73 20 77 65 20 73 68 6f 75 6c 64 20 72 65 aps we should re
6d60: 71 75 69 72 65 20 73 65 70 61 72 61 74 65 20 61 quire separate a
6d70: 6e 64 20 65 78 70 6c 69 63 69 74 20 63 6f 6d 6d nd explicit comm
6d80: 61 6e 64 73 20 74 6f 0a 20 20 23 20 65 73 63 61 ands to. # esca
6d90: 70 65 20 74 6f 20 53 49 4d 48 2e 20 42 75 74 20 pe to SIMH. But
6da0: 66 6f 72 20 6e 6f 77 2c 20 6a 75 73 74 20 62 65 for now, just be
6db0: 20 63 61 72 65 66 75 6c 20 74 6f 20 75 73 65 20 careful to use
6dc0: 6f 73 38 5f 72 65 73 75 6d 65 0a 20 20 23 20 61 os8_resume. # a
6dd0: 66 74 65 72 20 63 61 6c 6c 69 6e 67 20 73 65 6e fter calling sen
6de0: 64 5f 63 6d 64 2e 0a 20 20 0a 20 20 64 65 66 20 d_cmd.. . def
6df0: 73 65 6e 64 5f 63 6d 64 20 28 73 65 6c 66 2c 20 send_cmd (self,
6e00: 63 6d 64 29 3a 0a 20 20 20 20 69 66 20 73 65 6c cmd):. if sel
6e10: 66 2e 5f 63 6f 6e 74 65 78 74 20 3d 3d 20 22 6f f._context == "o
6e20: 73 38 22 3a 0a 20 20 20 20 20 20 73 65 6c 66 2e s8":. self.
6e30: 5f 63 68 69 6c 64 2e 65 78 70 65 63 74 20 28 22 _child.expect ("
6e40: 5c 6e 5c 5c 2e 24 22 29 0a 20 20 20 20 20 20 73 \n\\.$"). s
6e50: 65 6c 66 2e 5f 63 68 69 6c 64 2e 73 65 6e 64 63 elf._child.sendc
6e60: 6f 6e 74 72 6f 6c 20 28 27 65 27 29 0a 20 20 20 ontrol ('e').
6e70: 20 20 20 73 65 6c 66 2e 5f 63 6f 6e 74 65 78 74 self._context
6e80: 20 3d 20 22 73 69 6d 68 22 0a 20 20 20 20 65 6c = "simh". el
6e90: 69 66 20 73 65 6c 66 2e 5f 63 6f 6e 74 65 78 74 if self._context
6ea0: 20 21 3d 20 22 73 69 6d 68 22 3a 0a 20 20 20 20 != "simh":.
6eb0: 20 20 73 65 6c 66 2e 5f 63 68 69 6c 64 2e 73 65 self._child.se
6ec0: 6e 64 63 6f 6e 74 72 6f 6c 20 28 27 65 27 29 0a ndcontrol ('e').
6ed0: 20 20 20 20 20 20 73 65 6c 66 2e 5f 63 6f 6e 74 self._cont
6ee0: 65 78 74 20 3d 20 22 73 69 6d 68 22 0a 20 20 20 ext = "simh".
6ef0: 20 20 20 0a 20 20 20 20 73 65 6c 66 2e 5f 63 68 . self._ch
6f00: 69 6c 64 2e 65 78 70 65 63 74 20 28 22 73 69 6d ild.expect ("sim
6f10: 3e 20 24 22 29 0a 20 20 20 20 73 65 6c 66 2e 5f > $"). self._
6f20: 63 68 69 6c 64 2e 73 65 6e 64 6c 69 6e 65 20 28 child.sendline (
6f30: 63 6d 64 29 0a 20 20 20 20 6d 20 3d 20 72 65 2e cmd). m = re.
6f40: 6d 61 74 63 68 20 28 73 65 6c 66 2e 5f 73 69 6d match (self._sim
6f50: 68 5f 63 6f 6d 6d 5f 72 65 2c 20 63 6d 64 29 0a h_comm_re, cmd).
6f60: 20 20 20 20 69 66 20 6d 20 21 3d 20 4e 6f 6e 65 if m != None
6f70: 20 61 6e 64 20 6d 2e 67 72 6f 75 70 28 31 29 5b and m.group(1)[
6f80: 3a 31 5d 2e 75 70 70 65 72 28 29 20 69 6e 20 73 :1].upper() in s
6f90: 65 6c 66 2e 5f 65 6e 74 65 72 73 5f 6f 73 38 5f elf._enters_os8_
6fa0: 63 6f 6e 74 65 78 74 3a 0a 20 20 20 20 20 20 73 context:. s
6fb0: 65 6c 66 2e 5f 63 6f 6e 74 65 78 74 20 3d 20 22 elf._context = "
6fc0: 6f 73 38 22 0a 0a 0a 20 20 23 23 23 23 20 73 65 os8"... #### se
6fd0: 6e 64 5f 6c 69 6e 65 20 23 23 23 23 23 23 23 23 nd_line ########
6fe0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
6ff0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
7000: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0a ###############.
7010: 20 20 23 20 53 65 6e 64 73 20 74 68 65 20 67 69 # Sends the gi
7020: 76 65 6e 20 6c 69 6e 65 20 22 62 6c 69 6e 64 22 ven line "blind"
7030: 2c 20 77 69 74 68 6f 75 74 20 77 61 69 74 69 6e , without waitin
7040: 67 20 66 6f 72 20 61 20 70 72 6f 6d 70 74 2e 0a g for a prompt..
7050: 0a 20 20 64 65 66 20 73 65 6e 64 5f 6c 69 6e 65 . def send_line
7060: 20 28 73 65 6c 66 2c 20 6c 69 6e 65 29 3a 0a 20 (self, line):.
7070: 20 20 20 73 65 6c 66 2e 5f 63 68 69 6c 64 2e 73 self._child.s
7080: 65 6e 64 6c 69 6e 65 20 28 6c 69 6e 65 29 0a 0a endline (line)..
7090: 0a 20 20 23 23 23 23 20 73 65 74 5f 6c 6f 67 66 . #### set_logf
70a0: 69 6c 65 20 23 23 23 23 23 23 23 23 23 23 23 23 ile ############
70b0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
70c0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
70d0: 23 23 23 23 23 23 23 23 23 0a 0a 20 20 64 65 66 #########.. def
70e0: 20 73 65 74 5f 6c 6f 67 66 69 6c 65 20 28 73 65 set_logfile (se
70f0: 6c 66 2c 20 6c 66 29 3a 0a 20 20 20 20 73 65 6c lf, lf):. sel
7100: 66 2e 5f 63 68 69 6c 64 2e 6c 6f 67 66 69 6c 65 f._child.logfile
7110: 20 3d 20 6c 66 0a 0a 0a 20 20 23 23 23 23 20 73 = lf... #### s
7120: 70 69 6e 20 23 23 23 23 23 23 23 23 23 23 23 23 pin ############
7130: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
7140: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
7150: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
7160: 0a 20 20 23 20 4c 65 74 20 63 68 69 6c 64 20 72 . # Let child r
7170: 75 6e 20 77 69 74 68 6f 75 74 20 61 73 6b 69 6e un without askin
7180: 67 20 61 6e 79 74 68 69 6e 67 20 6d 6f 72 65 20 g anything more
7190: 66 72 6f 6d 20 69 74 2c 20 77 69 74 68 20 61 6e from it, with an
71a0: 20 6f 70 74 69 6f 6e 61 6c 0a 20 20 23 20 74 69 optional. # ti
71b0: 6d 65 6f 75 74 20 76 61 6c 75 65 2e 20 20 49 66 meout value. If
71c0: 20 6e 6f 20 76 61 6c 75 65 20 69 73 20 67 69 76 no value is giv
71d0: 65 6e 2c 20 6c 65 74 73 20 63 68 69 6c 64 20 72 en, lets child r
71e0: 75 6e 20 69 6e 64 65 66 69 6e 69 74 65 6c 79 2e un indefinitely.
71f0: 0a 0a 20 20 64 65 66 20 73 70 69 6e 20 28 73 65 .. def spin (se
7200: 6c 66 2c 20 74 69 6d 65 6f 75 74 20 3d 20 4e 6f lf, timeout = No
7210: 6e 65 29 3a 0a 20 20 20 20 73 65 6c 66 2e 5f 63 ne):. self._c
7220: 68 69 6c 64 2e 65 78 70 65 63 74 20 28 70 65 78 hild.expect (pex
7230: 70 65 63 74 2e 45 4f 46 2c 20 74 69 6d 65 6f 75 pect.EOF, timeou
7240: 74 20 3d 20 74 69 6d 65 6f 75 74 29 0a 0a 0a 20 t = timeout)...
7250: 20 23 23 23 23 20 74 72 79 5f 77 61 69 74 20 23 #### try_wait #
7260: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
7270: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
7280: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
7290: 23 23 23 23 23 23 23 0a 20 20 23 20 41 20 77 72 #######. # A wr
72a0: 61 70 70 65 72 20 61 72 6f 75 6e 64 20 73 65 6c apper around sel
72b0: 66 2e 5f 63 68 69 6c 64 2e 65 78 70 65 63 74 20 f._child.expect
72c0: 77 68 69 63 68 20 63 61 74 63 68 65 73 20 65 78 which catches ex
72d0: 63 65 70 74 69 6f 6e 73 20 61 6e 64 0a 20 20 23 ceptions and. #
72e0: 20 72 65 74 75 72 6e 73 20 66 61 6c 73 65 20 6f returns false o
72f0: 6e 20 70 65 78 70 65 63 74 20 74 69 6d 65 6f 75 n pexpect timeou
7300: 74 2e 20 20 49 66 20 79 6f 75 20 70 61 73 73 20 t. If you pass
7310: 61 20 6c 69 73 74 20 69 6e 73 74 65 61 64 20 6f a list instead o
7320: 66 20 61 0a 20 20 23 20 73 74 72 69 6e 67 2c 20 f a. # string,
7330: 69 74 20 61 6c 73 6f 20 72 65 74 75 72 6e 73 20 it also returns
7340: 74 72 75 65 20 69 66 20 74 68 65 20 6d 61 74 63 true if the matc
7350: 68 20 77 61 73 6e 27 74 20 66 6f 72 20 74 68 65 h wasn't for the
7360: 20 66 69 72 73 74 0a 20 20 23 20 65 6c 65 6d 65 first. # eleme
7370: 6e 74 2c 20 73 6f 20 79 6f 75 20 63 61 6e 20 70 nt, so you can p
7380: 61 73 73 20 5b 73 75 63 63 65 73 73 2c 20 66 61 ass [success, fa
7390: 69 6c 75 72 65 31 2c 20 66 61 69 6c 75 72 65 32 ilure1, failure2
73a0: 2c 20 65 74 63 2e 5d 20 74 6f 0a 20 20 23 20 63 , etc.] to. # c
73b0: 68 65 63 6b 20 66 6f 72 20 61 20 6b 6e 6f 77 6e heck for a known
73c0: 2d 73 75 63 63 65 73 73 20 63 61 73 65 20 61 6e -success case an
73d0: 64 20 6f 6e 65 20 6f 72 20 6d 6f 72 65 20 66 61 d one or more fa
73e0: 69 6c 75 72 65 20 63 61 73 65 73 2e 0a 0a 20 20 ilure cases...
73f0: 64 65 66 20 74 72 79 5f 77 61 69 74 20 28 73 65 def try_wait (se
7400: 6c 66 2c 20 6d 61 74 63 68 65 73 2c 20 74 69 6d lf, matches, tim
7410: 65 6f 75 74 20 3d 20 2d 31 29 3a 0a 20 20 20 20 eout = -1):.
7420: 74 72 79 3a 0a 20 20 20 20 20 20 72 65 74 75 72 try:. retur
7430: 6e 20 73 65 6c 66 2e 5f 63 68 69 6c 64 2e 65 78 n self._child.ex
7440: 70 65 63 74 20 28 6d 61 74 63 68 65 73 2c 20 74 pect (matches, t
7450: 69 6d 65 6f 75 74 20 3d 20 74 69 6d 65 6f 75 74 imeout = timeout
7460: 29 20 3d 3d 20 30 0a 20 20 20 20 65 78 63 65 70 ) == 0. excep
7470: 74 20 70 65 78 70 65 63 74 2e 65 78 63 65 70 74 t pexpect.except
7480: 69 6f 6e 73 2e 54 49 4d 45 4f 55 54 3a 0a 20 20 ions.TIMEOUT:.
7490: 20 20 20 20 73 79 73 2e 73 74 64 65 72 72 2e 77 sys.stderr.w
74a0: 72 69 74 65 20 28 22 45 78 63 65 65 64 65 64 20 rite ("Exceeded
74b0: 22 20 2b 20 73 74 72 28 74 69 6d 65 6f 75 74 29 " + str(timeout)
74c0: 20 2b 20 22 20 73 65 63 20 74 69 6d 65 6f 75 74 + " sec timeout
74d0: 20 22 20 2b 0a 20 20 20 20 20 20 20 20 20 20 22 " +. "
74e0: 77 61 69 74 69 6e 67 20 66 6f 72 20 22 20 2b 20 waiting for " +
74f0: 73 74 72 28 6d 61 74 63 68 65 73 29 20 2b 20 22 str(matches) + "
7500: 5c 6e 22 29 0a 20 20 20 20 20 20 72 65 74 75 72 \n"). retur
7510: 6e 20 46 61 6c 73 65 0a 20 20 20 20 65 78 63 65 n False. exce
7520: 70 74 3a 0a 20 20 20 20 20 20 73 79 73 2e 73 74 pt:. sys.st
7530: 64 65 72 72 2e 77 72 69 74 65 20 28 22 46 61 69 derr.write ("Fai
7540: 6c 65 64 20 74 6f 20 6d 61 74 63 68 20 22 20 2b led to match " +
7550: 20 73 74 72 28 6d 61 74 63 68 65 73 29 20 2b 20 str(matches) +
7560: 0a 20 20 20 20 20 20 20 20 20 20 22 3a 20 75 6e . ": un
7570: 6b 6e 6f 77 6e 20 65 78 63 65 70 74 69 6f 6e 2e known exception.
7580: 5c 6e 22 29 0a 20 20 20 20 20 20 72 65 74 75 72 \n"). retur
7590: 6e 20 46 61 6c 73 65 0a 0a 0a 20 20 23 23 23 23 n False... ####
75a0: 20 7a 65 72 6f 5f 63 6f 72 65 20 23 23 23 23 23 zero_core #####
75b0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
75c0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
75d0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
75e0: 23 23 0a 20 20 23 20 46 72 6f 6d 20 53 49 4d 48 ##. # From SIMH
75f0: 20 63 6f 6e 74 65 78 74 2c 20 7a 65 72 6f 20 74 context, zero t
7600: 68 65 20 65 6e 74 69 72 65 20 63 6f 6e 74 65 6e he entire conten
7610: 74 73 20 6f 66 20 63 6f 72 65 2c 20 77 68 69 63 ts of core, whic
7620: 68 20 69 73 0a 20 20 23 20 61 73 73 75 6d 65 64 h is. # assumed
7630: 20 74 6f 20 62 65 20 33 32 20 6b 57 6f 72 64 73 to be 32 kWords
7640: 2e 0a 20 20 23 0a 20 20 23 20 53 49 4d 48 27 73 .. #. # SIMH's
7650: 20 50 44 50 2d 38 20 73 69 6d 75 6c 61 74 6f 72 PDP-8 simulator
7660: 20 64 6f 65 73 6e 27 74 20 73 74 61 72 74 20 77 doesn't start w
7670: 69 74 68 20 63 6f 72 65 20 7a 65 72 6f 65 64 2c ith core zeroed,
7680: 20 6f 6e 20 70 75 72 70 6f 73 65 2c 0a 20 20 23 on purpose,. #
7690: 20 62 65 63 61 75 73 65 20 74 68 65 20 61 63 74 because the act
76a0: 75 61 6c 20 68 61 72 64 77 61 72 65 20 64 69 64 ual hardware did
76b0: 20 6e 6f 74 20 64 6f 20 74 68 61 74 2e 20 20 53 not do that. S
76c0: 49 4d 48 20 64 6f 65 73 20 6e 6f 74 20 61 74 74 IMH does not att
76d0: 65 6d 70 74 0a 20 20 23 20 74 6f 20 73 69 6d 75 empt. # to simu
76e0: 6c 61 74 65 20 74 68 65 20 70 65 72 73 69 73 74 late the persist
76f0: 65 6e 63 65 20 6f 66 20 63 6f 72 65 20 6d 65 6d ence of core mem
7700: 6f 72 79 20 62 79 20 73 61 76 69 6e 67 20 69 74 ory by saving it
7710: 20 74 6f 20 64 69 73 6b 0a 20 20 23 20 62 65 74 to disk. # bet
7720: 77 65 65 6e 20 72 75 6e 73 2c 20 62 75 74 20 74 ween runs, but t
7730: 68 65 20 53 49 4d 48 20 64 65 76 65 6c 6f 70 65 he SIMH develope
7740: 72 73 20 61 72 65 20 72 69 67 68 74 20 74 6f 20 rs are right to
7750: 72 65 66 75 73 65 20 74 6f 20 64 6f 20 74 68 69 refuse to do thi
7760: 73 0a 20 20 23 20 62 79 20 64 65 66 61 75 6c 74 s. # by default
7770: 3a 20 79 6f 75 20 63 61 6e 6e 6f 74 20 74 72 75 : you cannot tru
7780: 73 74 20 74 68 65 20 70 72 69 6f 72 20 73 74 61 st the prior sta
7790: 74 65 20 6f 66 20 61 20 50 44 50 2d 38 27 73 20 te of a PDP-8's
77a0: 63 6f 72 65 0a 20 20 23 20 6d 65 6d 6f 72 79 20 core. # memory
77b0: 62 65 66 6f 72 65 20 69 6e 69 74 69 61 6c 69 7a before initializ
77c0: 69 6e 67 20 69 74 20 79 6f 75 72 73 65 6c 66 2e ing it yourself.
77d0: 0a 20 20 23 0a 20 20 23 20 53 65 65 20 6f 73 38 . #. # See os8
77e0: 5f 7a 65 72 6f 5f 63 6f 72 65 20 28 29 20 66 6f _zero_core () fo
77f0: 72 20 61 20 6c 65 73 73 20 68 65 61 76 79 2d 68 r a less heavy-h
7800: 61 6e 64 65 64 20 61 6c 74 65 72 6e 61 74 69 76 anded alternativ
7810: 65 20 66 6f 72 20 75 73 65 0a 20 20 23 20 77 68 e for use. # wh
7820: 65 6e 20 72 75 6e 6e 69 6e 67 20 75 6e 64 65 72 en running under
7830: 20 4f 53 2f 38 2e 0a 0a 20 20 64 65 66 20 7a 65 OS/8... def ze
7840: 72 6f 5f 63 6f 72 65 20 28 73 65 6c 66 29 3a 0a ro_core (self):.
7850: 20 20 20 20 73 65 6c 66 2e 73 65 6e 64 5f 63 6d self.send_cm
7860: 64 20 28 27 64 65 20 61 6c 6c 20 30 27 29 0a 20 d ('de all 0').
7870: 20 0a 0a 20 20 23 23 23 23 20 64 65 73 63 72 69 .. #### descri
7880: 62 65 5f 64 65 76 5f 63 6f 6e 66 69 67 20 23 23 be_dev_config ##
7890: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
78a0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
78b0: 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 23 20 ###########. #
78c0: 57 65 20 70 72 6f 76 69 64 65 20 61 6e 20 69 6e We provide an in
78d0: 74 65 72 66 61 63 65 20 74 6f 20 61 6c 74 65 72 terface to alter
78e0: 20 53 49 4d 48 20 64 65 76 69 63 65 20 63 6f 6e SIMH device con
78f0: 66 69 67 75 72 61 74 69 6f 6e 73 20 66 6f 72 0a figurations for.
7900: 20 20 23 20 73 70 65 63 69 66 69 63 20 70 61 72 # specific par
7910: 61 6d 65 74 65 72 73 20 61 6e 64 20 73 70 65 63 ameters and spec
7920: 69 66 69 63 20 64 65 76 69 63 65 73 0a 20 20 23 ific devices. #
7930: 0a 20 20 23 20 64 65 76 20 63 6f 6e 66 69 67 73 . # dev configs
7940: 20 73 75 70 70 6f 72 74 65 64 3a 20 20 72 78 2c supported: rx,
7950: 20 74 74 69 2c 20 74 61 70 65 0a 20 20 23 0a 20 tti, tape. #.
7960: 20 23 20 72 78 3a 20 20 20 20 20 52 58 38 45 2c # rx: RX8E,
7970: 20 52 58 32 38 20 20 20 52 58 38 45 20 69 73 20 RX28 RX8E is
7980: 74 68 65 20 73 69 6d 68 20 6e 61 6d 65 20 66 6f the simh name fo
7990: 72 20 52 58 30 31 20 73 75 70 70 6f 72 74 2e 0a r RX01 support..
79a0: 20 20 23 20 20 20 20 20 20 20 20 20 20 20 20 20 #
79b0: 20 20 20 20 20 20 20 20 20 52 58 32 38 20 69 73 RX28 is
79c0: 20 74 68 65 20 73 69 6d 68 20 6e 61 6d 65 20 66 the simh name f
79d0: 6f 72 20 52 58 30 32 20 73 75 70 70 6f 72 74 2e or RX02 support.
79e0: 0a 20 20 23 20 74 74 69 3a 20 20 20 20 4b 53 52 . # tti: KSR
79f0: 2c 20 37 62 20 20 20 20 20 20 37 62 20 69 73 20 , 7b 7b is
7a00: 66 75 6c 6c 20 6b 65 79 62 6f 61 72 64 20 73 75 full keyboard su
7a10: 70 70 6f 72 74 2e 0a 20 20 23 20 20 20 20 20 20 pport.. #
7a20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
7a30: 4b 53 52 20 66 6f 72 63 65 73 20 75 70 63 61 73 KSR forces upcas
7a40: 65 20 6f 66 20 6c 6f 77 65 72 20 63 61 73 65 20 e of lower case
7a50: 6b 65 79 73 20 6f 6e 20 69 6e 70 75 74 2e 0a 20 keys on input..
7a60: 20 23 20 74 61 70 65 3a 20 20 20 74 64 2c 20 64 # tape: td, d
7a70: 74 20 20 20 20 20 20 20 74 64 20 69 73 20 74 68 t td is th
7a80: 65 20 54 44 38 45 20 44 45 43 74 61 70 65 20 64 e TD8E DECtape d
7a90: 65 76 69 63 65 0a 20 20 23 20 20 20 20 20 20 20 evice. #
7aa0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 d
7ab0: 74 20 69 73 20 74 68 65 20 54 43 30 38 20 44 45 t is the TC08 DE
7ac0: 43 74 61 70 65 20 64 65 76 69 63 65 0a 0a 20 20 Ctape device..
7ad0: 64 65 66 20 64 65 73 63 72 69 62 65 5f 64 65 76 def describe_dev
7ae0: 5f 63 6f 6e 66 69 67 20 28 73 65 6c 66 2c 20 6e _config (self, n
7af0: 61 6d 65 29 3a 0a 20 20 20 20 69 66 20 6e 61 6d ame):. if nam
7b00: 65 20 3d 3d 20 22 74 61 70 65 22 3a 0a 20 20 20 e == "tape":.
7b10: 20 20 20 6c 69 6e 65 73 20 3d 20 73 65 6c 66 2e lines = self.
7b20: 64 6f 5f 73 69 6d 68 5f 73 68 6f 77 28 22 64 74 do_simh_show("dt
7b30: 22 29 0a 20 20 20 20 20 20 64 65 76 5f 73 74 61 "). dev_sta
7b40: 74 75 73 20 3d 20 73 65 6c 66 2e 70 61 72 73 65 tus = self.parse
7b50: 5f 73 68 6f 77 5f 74 61 70 65 5f 64 65 76 28 6c _show_tape_dev(l
7b60: 69 6e 65 73 29 0a 0a 20 20 20 20 20 20 69 66 20 ines).. if
7b70: 64 65 76 5f 73 74 61 74 75 73 20 3d 3d 20 22 64 dev_status == "d
7b80: 74 22 3a 20 72 65 74 75 72 6e 20 22 64 74 22 0a t": return "dt".
7b90: 20 20 20 20 20 20 65 6c 73 65 3a 0a 20 20 20 20 else:.
7ba0: 20 20 20 20 6c 69 6e 65 73 20 3d 20 73 65 6c 66 lines = self
7bb0: 2e 64 6f 5f 73 69 6d 68 5f 73 68 6f 77 28 22 74 .do_simh_show("t
7bc0: 64 22 29 0a 20 20 20 20 20 20 20 20 72 65 74 75 d"). retu
7bd0: 72 6e 20 73 65 6c 66 2e 70 61 72 73 65 5f 73 68 rn self.parse_sh
7be0: 6f 77 5f 74 61 70 65 5f 64 65 76 28 6c 69 6e 65 ow_tape_dev(line
7bf0: 73 29 0a 20 20 20 20 65 6c 69 66 20 6e 61 6d 65 s). elif name
7c00: 20 3d 3d 20 22 72 78 22 3a 0a 20 20 20 20 20 20 == "rx":.
7c10: 6c 69 6e 65 73 20 3d 20 73 65 6c 66 2e 64 6f 5f lines = self.do_
7c20: 73 69 6d 68 5f 73 68 6f 77 28 22 72 78 22 29 0a simh_show("rx").
7c30: 20 20 20 20 20 20 72 65 74 75 72 6e 20 73 65 6c return sel
7c40: 66 2e 70 61 72 73 65 5f 73 68 6f 77 5f 72 78 5f f.parse_show_rx_
7c50: 64 65 76 28 6c 69 6e 65 73 29 0a 20 20 20 20 65 dev(lines). e
7c60: 6c 69 66 20 6e 61 6d 65 20 3d 3d 20 22 74 74 69 lif name == "tti
7c70: 22 3a 0a 20 20 20 20 20 20 6c 69 6e 65 73 20 3d ":. lines =
7c80: 20 73 65 6c 66 2e 64 6f 5f 73 69 6d 68 5f 73 68 self.do_simh_sh
7c90: 6f 77 28 22 74 74 69 22 29 0a 20 20 20 20 20 20 ow("tti").
7ca0: 72 65 74 75 72 6e 20 73 65 6c 66 2e 70 61 72 73 return self.pars
7cb0: 65 5f 73 68 6f 77 5f 74 74 69 28 6c 69 6e 65 73 e_show_tti(lines
7cc0: 29 0a 20 20 20 20 65 6c 73 65 3a 20 72 65 74 75 ). else: retu
7cd0: 72 6e 20 4e 6f 6e 65 0a 0a 20 20 20 20 20 20 0a rn None.. .
7ce0: 20 20 23 23 23 23 20 64 6f 5f 73 69 6d 68 5f 73 #### do_simh_s
7cf0: 68 6f 77 20 20 23 23 23 23 23 23 23 23 23 23 23 how ###########
7d00: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
7d10: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
7d20: 23 23 23 23 23 23 23 23 0a 20 20 23 20 43 61 6c ########. # Cal
7d30: 6c 73 20 73 68 6f 77 20 6f 6e 20 74 68 65 20 64 ls show on the d
7d40: 65 76 69 63 65 20 6e 61 6d 65 2e 0a 20 20 23 20 evice name.. #
7d50: 52 65 74 75 72 6e 73 20 61 72 72 61 79 20 6f 66 Returns array of
7d60: 20 6c 69 6e 65 73 20 66 72 6f 6d 20 6f 75 74 70 lines from outp
7d70: 75 74 2e 0a 0a 20 20 64 65 66 20 64 6f 5f 73 69 ut... def do_si
7d80: 6d 68 5f 73 68 6f 77 20 28 73 65 6c 66 2c 20 6e mh_show (self, n
7d90: 61 6d 65 29 3a 0a 20 20 20 20 73 75 70 70 6f 72 ame):. suppor
7da0: 74 65 64 5f 73 68 6f 77 73 20 3d 20 5b 22 64 74 ted_shows = ["dt
7db0: 22 2c 20 22 74 64 22 2c 20 22 74 74 69 22 2c 20 ", "td", "tti",
7dc0: 22 72 78 22 5d 0a 20 20 20 20 69 66 20 6e 61 6d "rx"]. if nam
7dd0: 65 20 6e 6f 74 20 69 6e 20 73 75 70 70 6f 72 74 e not in support
7de0: 65 64 5f 73 68 6f 77 73 3a 20 72 65 74 75 72 6e ed_shows: return
7df0: 20 4e 6f 6e 65 0a 20 20 20 20 0a 20 20 20 20 75 None. . u
7e00: 63 6e 61 6d 65 20 3d 20 6e 61 6d 65 2e 75 70 70 cname = name.upp
7e10: 65 72 28 29 0a 20 20 20 20 73 65 6c 66 2e 73 65 er(). self.se
7e20: 6e 64 5f 63 6d 64 28 22 73 68 6f 77 20 22 20 2b nd_cmd("show " +
7e30: 20 6e 61 6d 65 29 0a 20 20 20 20 73 65 6c 66 2e name). self.
7e40: 5f 63 68 69 6c 64 2e 65 78 70 65 63 74 28 75 63 _child.expect(uc
7e50: 6e 61 6d 65 20 2b 20 22 5c 73 2b 28 2e 2b 29 5c name + "\s+(.+)\
7e60: 72 22 29 0a 20 20 20 20 6c 69 6e 65 73 20 3d 20 r"). lines =
7e70: 73 65 6c 66 2e 5f 63 68 69 6c 64 2e 61 66 74 65 self._child.afte
7e80: 72 2e 73 70 6c 69 74 20 28 22 5c 72 22 29 0a 20 r.split ("\r").
7e90: 20 20 20 72 65 74 75 72 6e 20 6c 69 6e 65 73 0a return lines.
7ea0: 0a 0a 20 20 23 23 23 23 20 70 61 72 73 65 5f 73 .. #### parse_s
7eb0: 68 6f 77 5f 74 61 70 65 5f 64 65 76 20 20 23 23 how_tape_dev ##
7ec0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
7ed0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
7ee0: 23 23 23 23 23 23 23 23 23 23 0a 20 20 23 20 52 ##########. # R
7ef0: 65 74 75 72 6e 73 20 63 75 72 72 65 6e 74 20 73 eturns current s
7f00: 74 61 74 65 20 6f 66 20 44 45 43 74 61 70 65 20 tate of DECtape
7f10: 73 75 70 70 6f 72 74 2e 0a 20 20 23 20 4f 6e 65 support.. # One
7f20: 20 6f 66 3a 20 64 69 73 61 62 6c 65 64 2c 20 74 of: disabled, t
7f30: 64 2c 20 64 74 2c 20 6f 72 20 4e 6f 6e 65 20 69 d, dt, or None i
7f40: 66 20 70 61 72 73 65 20 66 61 69 6c 73 2e 0a 0a f parse fails...
7f50: 20 20 64 65 66 20 70 61 72 73 65 5f 73 68 6f 77 def parse_show
7f60: 5f 74 61 70 65 5f 64 65 76 20 28 73 65 6c 66 2c _tape_dev (self,
7f70: 20 6c 69 6e 65 73 29 3a 0a 20 20 20 20 69 66 20 lines):. if
7f80: 6c 69 6e 65 73 20 3d 3d 20 4e 6f 6e 65 3a 20 72 lines == None: r
7f90: 65 74 75 72 6e 20 4e 6f 6e 65 0a 20 20 20 20 69 eturn None. i
7fa0: 73 5f 65 6e 61 62 6c 65 64 5f 72 65 20 3d 20 72 s_enabled_re = r
7fb0: 65 2e 63 6f 6d 70 69 6c 65 28 22 5e 28 54 44 7c e.compile("^(TD|
7fc0: 44 54 29 5c 73 2b 28 64 69 73 61 62 6c 65 64 7c DT)\s+(disabled|
7fd0: 28 64 65 76 6e 6f 3d 5c 53 2b 2c 5c 73 28 5c 64 (devno=\S+,\s(\d
7fe0: 29 5c 73 2b 75 6e 69 74 73 29 29 24 22 29 0a 20 )\s+units))$").
7ff0: 20 20 20 6d 20 3d 20 72 65 2e 6d 61 74 63 68 28 m = re.match(
8000: 69 73 5f 65 6e 61 62 6c 65 64 5f 72 65 2c 20 6c is_enabled_re, l
8010: 69 6e 65 73 5b 30 5d 29 0a 0a 20 20 20 20 69 66 ines[0]).. if
8020: 20 6d 20 3d 3d 20 4e 6f 6e 65 20 6f 72 20 6d 2e m == None or m.
8030: 67 72 6f 75 70 28 31 29 20 3d 3d 20 4e 6f 6e 65 group(1) == None
8040: 20 6f 72 20 6d 2e 67 72 6f 75 70 28 32 29 20 3d or m.group(2) =
8050: 3d 20 4e 6f 6e 65 3a 20 72 65 74 75 72 6e 20 4e = None: return N
8060: 6f 6e 65 0a 20 20 20 20 69 66 20 6d 2e 67 72 6f one. if m.gro
8070: 75 70 28 32 29 20 3d 3d 20 22 64 69 73 61 62 6c up(2) == "disabl
8080: 65 64 22 3a 20 72 65 74 75 72 6e 20 22 64 69 73 ed": return "dis
8090: 61 62 6c 65 64 22 0a 20 20 20 20 65 6c 69 66 20 abled". elif
80a0: 6d 2e 67 72 6f 75 70 28 31 29 20 3d 3d 20 22 54 m.group(1) == "T
80b0: 44 22 3a 20 72 65 74 75 72 6e 20 22 74 64 22 0a D": return "td".
80c0: 20 20 20 20 65 6c 69 66 20 6d 2e 67 72 6f 75 70 elif m.group
80d0: 28 31 29 20 3d 3d 20 22 44 54 22 3a 20 72 65 74 (1) == "DT": ret
80e0: 75 72 6e 20 22 64 74 22 0a 20 20 20 20 65 6c 73 urn "dt". els
80f0: 65 3a 20 72 65 74 75 72 6e 20 4e 6f 6e 65 0a 0a e: return None..
8100: 0a 20 20 23 23 23 23 20 70 61 72 73 65 5f 73 68 . #### parse_sh
8110: 6f 77 5f 74 61 70 65 5f 61 74 74 61 63 68 65 64 ow_tape_attached
8120: 20 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ##############
8130: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
8140: 23 23 23 23 23 23 23 23 23 23 0a 20 20 23 20 52 ##########. # R
8150: 65 74 75 72 6e 73 20 61 6e 20 6f 72 64 65 72 65 eturns an ordere
8160: 64 20 6c 69 73 74 20 6f 66 20 66 69 6c 65 73 20 d list of files
8170: 61 74 74 61 63 68 65 64 20 6f 72 20 4e 6f 6e 65 attached or None
8180: 20 69 66 20 64 69 73 61 62 6c 65 64 2e 0a 20 20 if disabled..
8190: 64 65 66 20 70 61 72 73 65 5f 73 68 6f 77 5f 74 def parse_show_t
81a0: 61 70 65 5f 61 74 74 61 63 68 65 64 20 28 73 65 ape_attached (se
81b0: 6c 66 2c 20 6c 69 6e 65 73 29 3a 0a 20 20 20 20 lf, lines):.
81c0: 69 66 20 6c 69 6e 65 73 20 3d 3d 20 4e 6f 6e 65 if lines == None
81d0: 3a 20 72 65 74 75 72 6e 20 4e 6f 6e 65 0a 20 20 : return None.
81e0: 20 20 69 66 20 6c 65 6e 28 6c 69 6e 65 73 29 20 if len(lines)
81f0: 3c 20 32 3a 20 72 65 74 75 72 6e 20 4e 6f 6e 65 < 2: return None
8200: 0a 20 20 20 20 61 74 74 61 63 68 65 64 20 3d 20 . attached =
8210: 7b 7d 0a 20 20 20 20 61 74 74 61 63 68 6d 65 6e {}. attachmen
8220: 74 5f 72 65 20 3d 20 72 65 2e 63 6f 6d 70 69 6c t_re = re.compil
8230: 65 28 22 5e 5c 73 2b 28 28 28 44 54 7c 54 44 29 e("^\s+(((DT|TD)
8240: 28 5c 64 29 28 2e 2b 29 2c 5c 73 2b 28 6e 6f 74 (\d)(.+),\s+(not
8250: 5c 73 2b 61 74 74 61 63 68 65 64 7c 61 74 74 61 \s+attached|atta
8260: 63 68 65 64 5c 73 2b 74 6f 5c 73 2b 28 5c 53 2b ched\s+to\s+(\S+
8270: 29 29 2c 28 2e 2b 29 29 7c 31 32 62 29 24 22 29 )),(.+))|12b)$")
8280: 0a 20 20 20 20 66 6f 72 20 6c 69 6e 65 20 69 6e . for line in
8290: 20 6c 69 6e 65 73 5b 31 3a 5d 3a 0a 20 20 20 20 lines[1:]:.
82a0: 20 20 6d 20 3d 20 72 65 2e 6d 61 74 63 68 28 61 m = re.match(a
82b0: 74 74 61 63 68 6d 65 6e 74 5f 72 65 2c 20 6c 69 ttachment_re, li
82c0: 6e 65 29 0a 20 20 20 20 20 20 69 66 20 6d 20 3d ne). if m =
82d0: 3d 20 4e 6f 6e 65 20 6f 72 20 6d 2e 67 72 6f 75 = None or m.grou
82e0: 70 28 31 29 20 3d 3d 20 4e 6f 6e 65 20 6f 72 20 p(1) == None or
82f0: 6d 2e 67 72 6f 75 70 28 31 29 20 3d 3d 20 22 31 m.group(1) == "1
8300: 32 62 22 3a 20 63 6f 6e 74 69 6e 75 65 0a 20 20 2b": continue.
8310: 20 20 20 20 66 69 6c 65 6e 61 6d 65 20 3d 20 6d filename = m
8320: 2e 67 72 6f 75 70 28 37 29 0a 20 20 20 20 20 20 .group(7).
8330: 69 66 20 66 69 6c 65 6e 61 6d 65 20 3d 3d 20 4e if filename == N
8340: 6f 6e 65 3a 20 66 69 6c 65 6e 61 6d 65 20 3d 20 one: filename =
8350: 22 22 0a 20 20 20 20 20 20 61 74 74 61 63 68 65 "". attache
8360: 64 5b 6d 2e 67 72 6f 75 70 28 34 29 5d 20 3d 20 d[m.group(4)] =
8370: 66 69 6c 65 6e 61 6d 65 0a 20 20 20 20 72 65 74 filename. ret
8380: 75 72 6e 20 61 74 74 61 63 68 65 64 0a 0a 20 20 urn attached..
8390: 23 23 23 23 20 64 6f 5f 70 72 69 6e 74 5f 6c 69 #### do_print_li
83a0: 6e 65 73 20 23 23 23 23 23 23 23 23 23 23 23 23 nes ############
83b0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
83c0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
83d0: 23 23 23 23 23 23 23 0a 20 20 23 20 44 65 62 75 #######. # Debu
83e0: 67 67 69 6e 67 20 61 69 64 2e 20 50 72 69 6e 74 gging aid. Print
83f0: 73 20 77 68 61 74 20 77 65 20 70 61 72 73 65 64 s what we parsed
8400: 20 6f 75 74 20 6f 66 20 5f 63 68 69 6c 64 2e 61 out of _child.a
8410: 66 74 65 72 2e 0a 20 20 64 65 66 20 64 6f 5f 70 fter.. def do_p
8420: 72 69 6e 74 5f 6c 69 6e 65 73 20 28 73 65 6c 66 rint_lines (self
8430: 2c 20 6c 69 6e 65 73 29 3a 0a 20 20 20 20 66 6f , lines):. fo
8440: 72 20 6c 69 6e 65 20 69 6e 20 6c 69 6e 65 73 3a r line in lines:
8450: 0a 20 20 20 20 20 20 70 72 69 6e 74 20 6c 69 6e . print lin
8460: 65 0a 0a 20 20 23 23 23 23 20 73 69 6d 68 5f 63 e.. #### simh_c
8470: 6f 6e 66 69 67 75 72 65 20 72 6f 75 74 69 6e 65 onfigure routine
8480: 73 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23 s ##############
8490: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
84a0: 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 23 20 ###########. #
84b0: 54 68 65 73 65 20 72 6f 75 74 69 6e 65 73 20 61 These routines a
84c0: 66 66 65 63 74 20 74 68 65 20 73 74 61 74 65 20 ffect the state
84d0: 6f 66 20 64 65 76 69 63 65 20 63 6f 6e 66 69 67 of device config
84e0: 75 72 61 74 69 6f 6e 20 69 6e 20 53 49 4d 48 2e uration in SIMH.
84f0: 0a 20 20 23 20 54 68 65 79 20 61 72 65 20 69 6e . # They are in
8500: 74 65 6e 64 65 64 20 61 73 20 72 6f 62 75 73 74 tended as robust
8510: 20 77 61 79 73 20 74 6f 20 74 6f 67 67 6c 65 20 ways to toggle
8520: 62 65 74 77 65 65 6e 20 69 6e 63 6f 6d 70 61 74 between incompat
8530: 69 62 6c 65 0a 20 20 23 20 63 6f 6e 66 69 67 75 ible. # configu
8540: 72 61 74 69 6f 6e 73 20 6f 66 20 53 49 4d 48 3a rations of SIMH:
8550: 0a 20 20 23 20 43 68 6f 69 63 65 20 6f 66 20 54 . # Choice of T
8560: 44 38 45 20 6f 72 20 54 43 30 38 20 44 45 43 74 D8E or TC08 DECt
8570: 61 70 65 20 28 53 49 4d 48 20 74 64 20 61 6e 64 ape (SIMH td and
8580: 20 64 74 20 64 65 76 69 63 65 73 29 2e 0a 20 20 dt devices)..
8590: 23 20 43 68 6f 69 63 65 20 6f 66 20 52 58 30 31 # Choice of RX01
85a0: 20 6f 72 20 52 58 30 32 20 46 6c 6f 70 70 79 20 or RX02 Floppy
85b0: 65 6d 75 6c 61 74 69 6f 6e 2e 0a 20 20 23 20 54 emulation.. # T
85c0: 68 65 20 53 49 4d 48 20 72 78 20 64 65 76 69 63 he SIMH rx devic
85d0: 65 20 73 65 74 73 20 52 58 38 45 20 66 6f 72 20 e sets RX8E for
85e0: 52 58 30 31 2c 20 61 6e 64 20 52 58 32 38 20 66 RX01, and RX28 f
85f0: 6f 72 20 52 58 30 32 2e 20 20 0a 20 20 23 20 43 or RX02. . # C
8600: 68 6f 69 63 65 20 6f 66 20 4b 53 52 20 6f 72 20 hoice of KSR or
8610: 37 62 69 74 20 63 6f 6e 73 6f 6c 65 20 63 6f 6e 7bit console con
8620: 66 69 67 75 72 61 74 69 6f 6e 2e 0a 20 20 23 0a figuration.. #.
8630: 20 20 23 20 57 68 65 6e 20 72 65 2d 63 6f 6e 66 # When re-conf
8640: 69 67 75 72 69 6e 67 20 64 74 2c 20 64 74 2c 20 iguring dt, dt,
8650: 61 6e 64 20 72 78 20 64 65 76 69 63 65 73 2c 20 and rx devices,
8660: 61 6e 79 20 61 74 74 61 63 68 65 64 0a 20 20 23 any attached. #
8670: 20 69 6d 61 67 65 73 20 61 72 65 20 64 65 74 61 images are deta
8680: 63 68 65 64 20 62 65 66 6f 72 65 20 72 65 63 6f ched before reco
8690: 6e 66 69 67 75 72 61 74 69 6f 6e 20 69 73 20 61 nfiguration is a
86a0: 74 74 65 6d 70 74 65 64 2e 0a 20 20 23 20 28 53 ttempted.. # (S
86b0: 49 4d 48 20 65 72 72 6f 72 73 20 6f 75 74 20 69 IMH errors out i
86c0: 66 20 79 6f 75 20 64 6f 6e 27 74 20 64 65 74 61 f you don't deta
86d0: 63 68 20 74 68 65 6d 2e 29 0a 20 20 23 0a 20 20 ch them.). #.
86e0: 23 20 54 68 65 20 63 68 65 63 6b 20 74 6f 20 73 # The check to s
86f0: 65 65 20 69 66 20 74 68 65 20 63 68 61 6e 67 65 ee if the change
8700: 20 69 73 20 75 6e 6e 65 63 65 73 73 61 72 79 2e is unnecessary.
8710: 0a 20 20 23 20 46 6f 72 20 6e 6f 77 20 74 68 65 . # For now the
8720: 79 20 72 65 74 75 72 6e 20 4e 6f 6e 65 20 69 66 y return None if
8730: 20 6e 6f 20 63 68 61 6e 67 65 20 6e 65 63 65 73 no change neces
8740: 73 61 72 79 2e 0a 20 20 23 0a 20 20 23 20 41 66 sary.. #. # Af
8750: 74 65 72 20 72 65 2d 63 6f 6e 66 69 67 75 72 69 ter re-configuri
8760: 6e 67 20 74 68 65 20 64 65 76 69 63 65 2c 20 74 ng the device, t
8770: 68 65 20 53 49 4d 48 20 73 68 6f 77 20 63 6f 6d he SIMH show com
8780: 6d 61 6e 64 20 69 73 20 75 73 65 64 0a 20 20 23 mand is used. #
8790: 20 74 6f 20 63 6f 6e 66 69 72 6d 20 74 68 65 20 to confirm the
87a0: 72 65 2d 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e re-configuration
87b0: 20 77 61 73 20 73 75 63 63 65 73 73 66 75 6c 2e was successful.
87c0: 0a 20 20 23 0a 20 20 23 20 49 6e 20 66 75 74 75 . #. # In futu
87d0: 72 65 2c 20 77 65 20 73 68 6f 75 6c 64 20 61 64 re, we should ad
87e0: 64 20 65 78 63 65 70 74 69 6f 6e 20 68 61 6e 64 d exception hand
87f0: 6c 69 6e 67 20 66 6f 72 20 6e 6f 20 63 68 61 6e ling for no chan
8800: 67 65 20 6e 65 63 65 73 73 61 72 79 2e 0a 20 20 ge necessary..
8810: 23 20 46 6f 72 20 6e 6f 77 2c 20 72 65 74 75 72 # For now, retur
8820: 6e 20 54 72 75 65 20 69 66 20 74 68 65 20 63 68 n True if the ch
8830: 61 6e 67 65 20 77 61 73 20 73 75 63 63 65 73 73 ange was success
8840: 66 75 6c 20 61 6e 64 20 46 61 6c 73 65 20 69 66 ful and False if
8850: 20 6e 6f 74 2e 0a 0a 0a 20 20 64 65 66 20 73 65 not.... def se
8860: 74 5f 74 61 70 65 5f 63 6f 6e 66 69 67 20 28 73 t_tape_config (s
8870: 65 6c 66 2c 20 74 6f 5f 74 61 70 65 29 3a 0a 20 elf, to_tape):.
8880: 20 20 20 69 66 20 74 6f 5f 74 61 70 65 20 3d 3d if to_tape ==
8890: 20 22 64 74 22 3a 20 66 72 6f 6d 5f 74 61 70 65 "dt": from_tape
88a0: 20 3d 20 22 74 64 22 0a 20 20 20 20 65 6c 69 66 = "td". elif
88b0: 20 74 6f 5f 74 61 70 65 20 3d 3d 20 22 74 64 22 to_tape == "td"
88c0: 3a 20 66 72 6f 6d 5f 74 61 70 65 20 3d 20 22 64 : from_tape = "d
88d0: 74 22 0a 20 20 20 20 65 6c 73 65 3a 0a 20 20 20 t". else:.
88e0: 20 20 20 70 72 69 6e 74 20 22 43 61 6e 6e 6f 74 print "Cannot
88f0: 20 73 65 74 5f 74 61 70 65 5f 63 6f 6e 66 69 67 set_tape_config
8900: 20 66 6f 72 20 22 20 2b 20 74 6f 5f 74 61 70 65 for " + to_tape
8910: 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 46 61 . return Fa
8920: 6c 73 65 0a 0a 20 20 20 20 69 66 20 73 65 6c 66 lse.. if self
8930: 2e 76 65 72 62 6f 73 65 3a 20 70 72 69 6e 74 20 .verbose: print
8940: 22 44 69 73 61 62 6c 65 3a 20 22 20 2b 20 66 72 "Disable: " + fr
8950: 6f 6d 5f 74 61 70 65 20 2b 20 22 2c 20 61 6e 64 om_tape + ", and
8960: 20 65 6e 61 62 6c 65 3a 20 22 20 2b 20 74 6f 5f enable: " + to_
8970: 74 61 70 65 0a 20 20 20 20 0a 20 20 20 20 6c 69 tape. . li
8980: 6e 65 73 20 3d 20 73 65 6c 66 2e 64 6f 5f 73 69 nes = self.do_si
8990: 6d 68 5f 73 68 6f 77 28 66 72 6f 6d 5f 74 61 70 mh_show(from_tap
89a0: 65 29 0a 20 20 20 20 66 72 6f 6d 5f 73 74 61 74 e). from_stat
89b0: 75 73 20 3d 20 73 65 6c 66 2e 70 61 72 73 65 5f us = self.parse_
89c0: 73 68 6f 77 5f 74 61 70 65 5f 64 65 76 28 6c 69 show_tape_dev(li
89d0: 6e 65 73 29 0a 0a 20 20 20 20 69 66 20 66 72 6f nes).. if fro
89e0: 6d 5f 73 74 61 74 75 73 20 3d 3d 20 4e 6f 6e 65 m_status == None
89f0: 3a 0a 20 20 20 20 20 20 70 72 69 6e 74 20 22 64 :. print "d
8a00: 6f 5f 74 61 70 65 5f 63 68 61 6e 67 65 3a 20 54 o_tape_change: T
8a10: 72 6f 75 62 6c 65 20 70 61 72 73 69 6e 67 20 5c rouble parsing \
8a20: 27 73 68 6f 77 20 22 20 2b 20 66 72 6f 6d 5f 74 'show " + from_t
8a30: 61 70 65 20 2b 20 22 5c 27 20 6f 75 74 70 75 74 ape + "\' output
8a40: 20 66 72 6f 6d 20 73 69 6d 68 2e 20 47 69 76 69 from simh. Givi
8a50: 6e 67 20 75 70 20 6f 6e 3a 22 0a 20 20 20 20 20 ng up on:".
8a60: 20 73 65 6c 66 2e 64 6f 5f 70 72 69 6e 74 5f 6c self.do_print_l
8a70: 69 6e 65 73 20 28 6c 69 6e 65 73 29 0a 20 20 20 ines (lines).
8a80: 20 20 20 72 65 74 75 72 6e 20 46 61 6c 73 65 0a return False.
8a90: 0a 20 20 20 20 69 66 20 66 72 6f 6d 5f 73 74 61 . if from_sta
8aa0: 74 75 73 20 3d 3d 20 22 64 69 73 61 62 6c 65 64 tus == "disabled
8ab0: 22 3a 20 70 72 69 6e 74 20 66 72 6f 6d 5f 74 61 ": print from_ta
8ac0: 70 65 20 2b 20 22 20 61 6c 72 65 61 64 79 20 69 pe + " already i
8ad0: 73 20 64 69 73 61 62 6c 65 64 2e 22 0a 20 20 20 s disabled.".
8ae0: 20 65 6c 73 65 3a 0a 20 20 20 20 20 20 61 74 74 else:. att
8af0: 61 63 68 65 64 5f 66 72 6f 6d 20 3d 20 73 65 6c ached_from = sel
8b00: 66 2e 70 61 72 73 65 5f 73 68 6f 77 5f 74 61 70 f.parse_show_tap
8b10: 65 5f 61 74 74 61 63 68 65 64 28 6c 69 6e 65 73 e_attached(lines
8b20: 29 0a 20 20 20 20 20 20 69 66 20 61 74 74 61 63 ). if attac
8b30: 68 65 64 5f 66 72 6f 6d 20 3d 3d 20 4e 6f 6e 65 hed_from == None
8b40: 3a 0a 20 20 20 20 20 20 20 20 70 72 69 6e 74 20 :. print
8b50: 22 64 6f 5f 74 61 70 65 5f 63 68 61 6e 67 65 3a "do_tape_change:
8b60: 20 54 72 6f 75 62 6c 65 20 70 61 72 73 69 6e 67 Trouble parsing
8b70: 20 5c 27 73 68 6f 77 20 22 20 2b 20 66 72 6f 6d \'show " + from
8b80: 5f 74 61 70 65 20 2b 20 22 5c 27 20 6f 75 74 70 _tape + "\' outp
8b90: 75 74 20 66 72 6f 6d 20 73 69 6d 68 2e 20 47 69 ut from simh. Gi
8ba0: 76 69 6e 67 20 75 70 20 6f 6e 3a 22 0a 20 20 20 ving up on:".
8bb0: 20 20 20 20 20 73 65 6c 66 2e 64 6f 5f 70 72 69 self.do_pri
8bc0: 6e 74 5f 6c 69 6e 65 73 20 28 6c 69 6e 65 73 29 nt_lines (lines)
8bd0: 0a 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 . return
8be0: 46 61 6c 73 65 0a 20 20 20 20 20 20 65 6c 73 65 False. else
8bf0: 3a 0a 20 20 20 20 20 20 20 20 66 6f 72 20 75 6e :. for un
8c00: 69 74 20 69 6e 20 61 74 74 61 63 68 65 64 5f 66 it in attached_f
8c10: 72 6f 6d 2e 6b 65 79 73 28 29 3a 0a 20 20 20 20 rom.keys():.
8c20: 20 20 20 20 20 20 69 66 20 61 74 74 61 63 68 65 if attache
8c30: 64 5f 66 72 6f 6d 5b 75 6e 69 74 5d 20 21 3d 20 d_from[unit] !=
8c40: 22 22 3a 0a 20 20 20 20 20 20 20 20 20 20 20 20 "":.
8c50: 64 65 74 5f 63 6f 6d 6d 20 3d 20 22 64 65 74 20 det_comm = "det
8c60: 22 20 2b 20 66 72 6f 6d 5f 74 61 70 65 20 2b 20 " + from_tape +
8c70: 75 6e 69 74 0a 20 20 20 20 20 20 20 20 20 20 20 unit.
8c80: 20 69 66 20 73 65 6c 66 2e 76 65 72 62 6f 73 65 if self.verbose
8c90: 3a 20 70 72 69 6e 74 20 64 65 74 5f 63 6f 6d 6d : print det_comm
8ca0: 20 2b 20 22 28 48 61 64 3a 20 22 20 2b 20 61 74 + "(Had: " + at
8cb0: 74 61 63 68 65 64 5f 66 72 6f 6d 5b 75 6e 69 74 tached_from[unit
8cc0: 5d 20 2b 20 22 29 22 0a 20 20 20 20 20 20 20 20 ] + ")".
8cd0: 20 20 20 20 73 65 6c 66 2e 73 65 6e 64 5f 63 6d self.send_cm
8ce0: 64 28 64 65 74 5f 63 6f 6d 6d 29 0a 20 20 20 20 d(det_comm).
8cf0: 20 20 20 20 73 65 6c 66 2e 73 65 6e 64 5f 63 6d self.send_cm
8d00: 64 28 22 73 65 74 20 22 20 2b 20 66 72 6f 6d 5f d("set " + from_
8d10: 74 61 70 65 20 2b 20 22 20 64 69 73 61 62 6c 65 tape + " disable
8d20: 64 22 29 0a 0a 20 20 20 20 6c 69 6e 65 73 20 3d d").. lines =
8d30: 20 73 65 6c 66 2e 64 6f 5f 73 69 6d 68 5f 73 68 self.do_simh_sh
8d40: 6f 77 28 74 6f 5f 74 61 70 65 29 0a 20 20 20 20 ow(to_tape).
8d50: 74 6f 5f 73 74 61 74 75 73 20 3d 20 73 65 6c 66 to_status = self
8d60: 2e 70 61 72 73 65 5f 73 68 6f 77 5f 74 61 70 65 .parse_show_tape
8d70: 5f 64 65 76 28 6c 69 6e 65 73 29 0a 0a 20 20 20 _dev(lines)..
8d80: 20 69 66 20 74 6f 5f 73 74 61 74 75 73 20 3d 3d if to_status ==
8d90: 20 4e 6f 6e 65 3a 0a 20 20 20 20 20 20 70 72 69 None:. pri
8da0: 6e 74 20 22 64 6f 5f 74 61 70 65 5f 63 68 61 6e nt "do_tape_chan
8db0: 67 65 3a 20 54 72 6f 75 62 6c 65 20 70 61 72 73 ge: Trouble pars
8dc0: 69 6e 67 20 5c 27 73 68 6f 77 20 22 20 2b 20 74 ing \'show " + t
8dd0: 6f 5f 74 61 70 65 20 2b 20 22 5c 27 20 6f 75 74 o_tape + "\' out
8de0: 70 75 74 20 66 72 6f 6d 20 73 69 6d 68 2e 20 47 put from simh. G
8df0: 69 76 69 6e 67 20 75 70 20 6f 6e 3a 22 0a 20 20 iving up on:".
8e00: 20 20 20 20 73 65 6c 66 2e 64 6f 5f 70 72 69 6e self.do_prin
8e10: 74 5f 6c 69 6e 65 73 20 28 6c 69 6e 65 73 29 0a t_lines (lines).
8e20: 20 20 20 20 20 20 72 65 74 75 72 6e 20 46 61 6c return Fal
8e30: 73 65 0a 20 20 20 20 65 6c 69 66 20 74 6f 5f 73 se. elif to_s
8e40: 74 61 74 75 73 20 21 3d 20 22 64 69 73 61 62 6c tatus != "disabl
8e50: 65 64 22 3a 20 70 72 69 6e 74 20 74 6f 5f 74 61 ed": print to_ta
8e60: 70 65 20 2b 20 22 20 61 6c 72 65 61 64 79 20 69 pe + " already i
8e70: 73 20 65 6e 61 62 6c 65 64 2e 22 0a 20 20 20 20 s enabled.".
8e80: 65 6c 73 65 3a 0a 20 20 20 20 20 20 73 65 6c 66 else:. self
8e90: 2e 73 65 6e 64 5f 63 6d 64 28 22 73 65 74 20 22 .send_cmd("set "
8ea0: 20 2b 20 74 6f 5f 74 61 70 65 20 2b 20 22 20 65 + to_tape + " e
8eb0: 6e 61 62 6c 65 64 22 29 20 20 20 20 0a 0a 20 20 nabled") ..
8ec0: 20 20 23 20 54 65 73 74 20 74 6f 20 63 6f 6e 66 # Test to conf
8ed0: 69 72 6d 20 74 6f 5f 74 61 70 65 20 69 73 20 6e irm to_tape is n
8ee0: 6f 77 20 65 6e 61 62 6c 65 64 2e 0a 0a 20 20 20 ow enabled...
8ef0: 20 6c 69 6e 65 73 20 3d 20 73 65 6c 66 2e 64 6f lines = self.do
8f00: 5f 73 69 6d 68 5f 73 68 6f 77 28 74 6f 5f 74 61 _simh_show(to_ta
8f10: 70 65 29 0a 20 20 20 20 74 6f 5f 73 74 61 74 75 pe). to_statu
8f20: 73 20 3d 20 73 65 6c 66 2e 70 61 72 73 65 5f 73 s = self.parse_s
8f30: 68 6f 77 5f 74 61 70 65 5f 64 65 76 28 6c 69 6e how_tape_dev(lin
8f40: 65 73 29 0a 0a 20 20 20 20 69 66 20 74 6f 5f 73 es).. if to_s
8f50: 74 61 74 75 73 20 3d 3d 20 4e 6f 6e 65 3a 0a 20 tatus == None:.
8f60: 20 20 20 20 20 70 72 69 6e 74 20 22 46 61 69 6c print "Fail
8f70: 65 64 20 65 6e 61 62 6c 65 20 6f 66 20 22 20 2b ed enable of " +
8f80: 20 74 6f 5f 74 61 70 65 20 2b 20 22 2e 20 50 61 to_tape + ". Pa
8f90: 72 73 65 20 66 61 69 6c 20 6f 6e 20 5c 27 73 68 rse fail on \'sh
8fa0: 6f 77 20 22 20 2b 20 74 6f 5f 74 61 70 65 20 2b ow " + to_tape +
8fb0: 20 22 5c 27 2e 20 47 6f 74 3a 22 0a 20 20 20 20 "\'. Got:".
8fc0: 20 20 73 65 6c 66 2e 64 6f 5f 70 72 69 6e 74 5f self.do_print_
8fd0: 6c 69 6e 65 73 20 28 6c 69 6e 65 73 29 0a 20 20 lines (lines).
8fe0: 20 20 20 20 72 65 74 75 72 6e 20 46 61 6c 73 65 return False
8ff0: 0a 20 20 20 20 65 6c 69 66 20 74 6f 5f 73 74 61 . elif to_sta
9000: 74 75 73 20 3d 3d 20 22 64 69 73 61 62 6c 65 64 tus == "disabled
9010: 22 3a 0a 20 20 20 20 20 20 70 72 69 6e 74 20 22 ":. print "
9020: 46 61 69 6c 65 64 20 65 6e 61 62 6c 65 20 6f 66 Failed enable of
9030: 20 22 20 2b 20 74 6f 5f 74 61 70 65 20 2b 20 22 " + to_tape + "
9040: 2e 20 44 65 76 69 63 65 20 73 74 69 6c 6c 20 64 . Device still d
9050: 69 73 61 62 6c 65 64 2e 22 0a 20 20 20 20 20 20 isabled.".
9060: 72 65 74 75 72 6e 20 46 61 6c 73 65 0a 20 20 20 return False.
9070: 20 65 6c 73 65 3a 20 0a 20 20 20 20 20 20 72 65 else: . re
9080: 74 75 72 6e 20 54 72 75 65 0a 0a 0a 20 20 23 23 turn True... ##
9090: 23 23 20 70 61 72 73 65 5f 73 68 6f 77 5f 72 78 ## parse_show_rx
90a0: 5f 64 65 76 20 23 23 23 23 23 23 23 23 23 23 23 _dev ###########
90b0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
90c0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
90d0: 23 23 23 23 0a 20 20 23 20 53 68 6f 77 20 74 68 ####. # Show th
90e0: 65 20 72 78 20 64 65 76 69 63 65 20 63 6f 6e 66 e rx device conf
90f0: 69 67 75 72 61 74 69 6f 6e 2e 0a 0a 20 20 64 65 iguration... de
9100: 66 20 70 61 72 73 65 5f 73 68 6f 77 5f 72 78 5f f parse_show_rx_
9110: 64 65 76 20 28 73 65 6c 66 2c 20 6c 69 6e 65 73 dev (self, lines
9120: 29 3a 0a 20 20 20 20 69 66 20 6c 69 6e 65 73 20 ):. if lines
9130: 3d 3d 20 4e 6f 6e 65 3a 20 72 65 74 75 72 6e 20 == None: return
9140: 4e 6f 6e 65 0a 20 20 20 20 69 73 5f 65 6e 61 62 None. is_enab
9150: 6c 65 64 5f 72 65 20 3d 20 72 65 2e 63 6f 6d 70 led_re = re.comp
9160: 69 6c 65 28 22 5e 5c 73 2a 28 52 58 29 5c 73 2b ile("^\s*(RX)\s+
9170: 28 64 69 73 61 62 6c 65 64 7c 28 28 52 58 38 45 (disabled|((RX8E
9180: 7c 52 58 32 38 29 2c 5c 73 2b 64 65 76 6e 6f 3d |RX28),\s+devno=
9190: 5c 53 2b 2c 5c 73 2b 28 5c 64 29 5c 73 2b 75 6e \S+,\s+(\d)\s+un
91a0: 69 74 73 29 29 24 22 29 0a 20 20 20 20 6d 20 3d its))$"). m =
91b0: 20 72 65 2e 6d 61 74 63 68 28 69 73 5f 65 6e 61 re.match(is_ena
91c0: 62 6c 65 64 5f 72 65 2c 20 6c 69 6e 65 73 5b 30 bled_re, lines[0
91d0: 5d 29 0a 20 20 20 20 69 66 20 6d 20 3d 3d 20 4e ]). if m == N
91e0: 6f 6e 65 20 6f 72 20 6d 2e 67 72 6f 75 70 28 32 one or m.group(2
91f0: 29 20 3d 3d 20 4e 6f 6e 65 3a 20 72 65 74 75 72 ) == None: retur
9200: 6e 20 4e 6f 6e 65 0a 20 20 20 20 69 66 20 6d 2e n None. if m.
9210: 67 72 6f 75 70 28 32 29 20 3d 3d 20 22 64 69 73 group(2) == "dis
9220: 61 62 6c 65 64 22 3a 20 72 65 74 75 72 6e 20 22 abled": return "
9230: 64 69 73 61 62 6c 65 64 22 0a 20 20 20 20 72 65 disabled". re
9240: 74 75 72 6e 20 6d 2e 67 72 6f 75 70 28 34 29 0a turn m.group(4).
9250: 0a 0a 20 20 20 23 23 23 23 20 70 61 72 73 65 5f .. #### parse_
9260: 73 68 6f 77 5f 72 78 5f 61 74 74 61 63 68 65 64 show_rx_attached
9270: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ###############
9280: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
9290: 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 23 20 ###########. #
92a0: 52 65 74 75 72 6e 73 20 61 6e 20 6f 72 64 65 72 Returns an order
92b0: 65 64 20 6c 69 73 74 20 6f 66 20 66 69 6c 65 73 ed list of files
92c0: 20 61 74 74 61 63 68 65 64 20 6f 72 20 4e 6f 6e attached or Non
92d0: 65 20 69 66 20 64 69 73 61 62 6c 65 64 2e 0a 0a e if disabled...
92e0: 20 20 64 65 66 20 70 61 72 73 65 5f 73 68 6f 77 def parse_show
92f0: 5f 72 78 5f 61 74 74 61 63 68 65 64 20 28 73 65 _rx_attached (se
9300: 6c 66 2c 20 6c 69 6e 65 73 29 3a 0a 20 20 20 20 lf, lines):.
9310: 69 66 20 6c 65 6e 28 6c 69 6e 65 73 29 20 3c 20 if len(lines) <
9320: 32 3a 20 72 65 74 75 72 6e 20 4e 6f 6e 65 0a 20 2: return None.
9330: 20 20 20 61 74 74 61 63 68 65 64 20 3d 20 7b 7d attached = {}
9340: 0a 20 20 20 20 61 74 74 61 63 68 6d 65 6e 74 5f . attachment_
9350: 72 65 20 3d 20 72 65 2e 63 6f 6d 70 69 6c 65 28 re = re.compile(
9360: 22 5e 5c 73 2b 28 28 28 52 58 29 28 5c 64 29 28 "^\s+(((RX)(\d)(
9370: 2e 2b 29 2c 5c 73 2b 28 6e 6f 74 5c 73 2b 61 74 .+),\s+(not\s+at
9380: 74 61 63 68 65 64 7c 61 74 74 61 63 68 65 64 5c tached|attached\
9390: 73 2b 74 6f 5c 73 2b 28 5c 53 2b 29 29 2c 28 2e s+to\s+(\S+)),(.
93a0: 2b 29 29 7c 61 75 74 6f 73 69 7a 65 29 24 22 29 +))|autosize)$")
93b0: 0a 20 20 20 20 66 6f 72 20 6c 69 6e 65 20 69 6e . for line in
93c0: 20 6c 69 6e 65 73 5b 31 3a 5d 3a 0a 20 20 20 20 lines[1:]:.
93d0: 20 20 6d 20 3d 20 72 65 2e 6d 61 74 63 68 28 61 m = re.match(a
93e0: 74 74 61 63 68 6d 65 6e 74 5f 72 65 2c 20 6c 69 ttachment_re, li
93f0: 6e 65 29 0a 20 20 20 20 20 20 69 66 20 6d 20 3d ne). if m =
9400: 3d 20 4e 6f 6e 65 20 6f 72 20 6d 2e 67 72 6f 75 = None or m.grou
9410: 70 28 31 29 20 3d 3d 20 4e 6f 6e 65 20 6f 72 20 p(1) == None or
9420: 6d 2e 67 72 6f 75 70 28 31 29 20 3d 3d 20 22 61 m.group(1) == "a
9430: 75 74 6f 73 69 7a 65 22 3a 20 63 6f 6e 74 69 6e utosize": contin
9440: 75 65 0a 20 20 20 20 20 20 66 69 6c 65 6e 61 6d ue. filenam
9450: 65 20 3d 20 6d 2e 67 72 6f 75 70 28 37 29 0a 20 e = m.group(7).
9460: 20 20 20 20 20 69 66 20 66 69 6c 65 6e 61 6d 65 if filename
9470: 20 3d 3d 20 4e 6f 6e 65 3a 20 66 69 6c 65 6e 61 == None: filena
9480: 6d 65 20 3d 20 22 22 0a 20 20 20 20 20 20 61 74 me = "". at
9490: 74 61 63 68 65 64 5b 6d 2e 67 72 6f 75 70 28 34 tached[m.group(4
94a0: 29 5d 20 3d 20 66 69 6c 65 6e 61 6d 65 0a 20 20 )] = filename.
94b0: 20 20 72 65 74 75 72 6e 20 61 74 74 61 63 68 65 return attache
94c0: 64 0a 0a 0a 20 20 23 23 23 23 20 73 65 74 5f 72 d... #### set_r
94d0: 78 5f 63 6f 6e 66 69 67 20 23 23 23 23 23 23 23 x_config #######
94e0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
94f0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
9500: 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 #############.
9510: 0a 20 20 64 65 66 20 73 65 74 5f 72 78 5f 63 6f . def set_rx_co
9520: 6e 66 69 67 20 28 73 65 6c 66 2c 20 74 6f 5f 72 nfig (self, to_r
9530: 78 29 3a 0a 20 20 20 20 74 6f 5f 72 78 20 3d 20 x):. to_rx =
9540: 74 6f 5f 72 78 2e 6c 6f 77 65 72 28 29 0a 20 20 to_rx.lower().
9550: 20 20 69 66 20 74 6f 5f 72 78 20 3d 3d 20 22 72 if to_rx == "r
9560: 78 38 65 22 3a 20 66 72 6f 6d 5f 72 78 20 3d 20 x8e": from_rx =
9570: 22 72 78 32 38 22 0a 20 20 20 20 65 6c 69 66 20 "rx28". elif
9580: 74 6f 5f 72 78 20 3d 3d 20 22 72 78 30 31 22 3a to_rx == "rx01":
9590: 0a 20 20 20 20 20 20 74 6f 5f 72 78 20 3d 20 22 . to_rx = "
95a0: 72 78 38 65 22 0a 20 20 20 20 20 20 66 72 6f 6d rx8e". from
95b0: 5f 72 78 20 3d 20 22 72 78 32 38 22 0a 20 20 20 _rx = "rx28".
95c0: 20 65 6c 69 66 20 74 6f 5f 72 78 20 3d 3d 20 22 elif to_rx == "
95d0: 72 78 32 38 22 3a 20 66 72 6f 6d 5f 72 78 20 3d rx28": from_rx =
95e0: 20 22 72 78 38 65 22 0a 20 20 20 20 65 6c 69 66 "rx8e". elif
95f0: 20 74 6f 5f 72 78 20 3d 3d 20 22 72 78 30 32 22 to_rx == "rx02"
9600: 3a 0a 20 20 20 20 20 20 74 6f 5f 72 78 20 3d 20 :. to_rx =
9610: 22 72 78 32 38 22 0a 20 20 20 20 20 20 66 72 6f "rx28". fro
9620: 6d 5f 72 78 20 3d 20 22 72 78 38 65 22 0a 20 20 m_rx = "rx8e".
9630: 20 20 65 6c 73 65 3a 0a 20 20 20 20 20 20 70 72 else:. pr
9640: 69 6e 74 20 22 43 61 6e 6e 6f 74 20 73 65 74 5f int "Cannot set_
9650: 72 78 5f 63 6f 6e 66 69 67 20 66 6f 72 20 22 20 rx_config for "
9660: 2b 20 74 6f 5f 72 78 0a 20 20 20 20 20 20 72 65 + to_rx. re
9670: 74 75 72 6e 20 46 61 6c 73 65 0a 20 20 20 20 20 turn False.
9680: 20 0a 20 20 20 20 69 66 20 73 65 6c 66 2e 76 65 . if self.ve
9690: 72 62 6f 73 65 3a 20 70 72 69 6e 74 20 22 53 77 rbose: print "Sw
96a0: 69 74 63 68 20 72 78 20 64 72 69 76 65 72 3a 20 itch rx driver:
96b0: 22 20 2b 20 66 72 6f 6d 5f 72 78 20 2b 20 22 2c " + from_rx + ",
96c0: 20 74 6f 3a 20 22 20 2b 20 74 6f 5f 72 78 0a 20 to: " + to_rx.
96d0: 20 20 20 6c 69 6e 65 73 20 3d 20 73 65 6c 66 2e lines = self.
96e0: 64 6f 5f 73 69 6d 68 5f 73 68 6f 77 28 22 72 78 do_simh_show("rx
96f0: 22 29 0a 0a 20 20 20 20 72 78 5f 74 79 70 65 20 ").. rx_type
9700: 3d 20 73 65 6c 66 2e 70 61 72 73 65 5f 73 68 6f = self.parse_sho
9710: 77 5f 72 78 5f 64 65 76 20 28 6c 69 6e 65 73 29 w_rx_dev (lines)
9720: 0a 20 20 20 20 69 66 20 72 78 5f 74 79 70 65 20 . if rx_type
9730: 3d 3d 20 4e 6f 6e 65 3a 0a 20 20 20 20 20 20 70 == None:. p
9740: 72 69 6e 74 20 22 64 6f 5f 72 78 5f 63 68 61 6e rint "do_rx_chan
9750: 67 65 3a 20 54 72 6f 75 62 6c 65 20 70 61 72 73 ge: Trouble pars
9760: 69 6e 67 20 5c 27 73 68 6f 77 20 72 78 5c 27 20 ing \'show rx\'
9770: 6f 75 74 70 75 74 20 66 72 6f 6d 20 73 69 6d 68 output from simh
9780: 2e 20 47 69 76 69 6e 67 20 75 70 20 6f 6e 3a 22 . Giving up on:"
9790: 0a 20 20 20 20 20 20 73 65 6c 66 2e 64 6f 5f 70 . self.do_p
97a0: 72 69 6e 74 5f 6c 69 6e 65 73 28 6c 69 6e 65 73 rint_lines(lines
97b0: 29 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 46 ). return F
97c0: 61 6c 73 65 0a 20 20 20 20 65 6c 69 66 20 72 78 alse. elif rx
97d0: 5f 74 79 70 65 20 3d 3d 20 22 64 69 73 61 62 6c _type == "disabl
97e0: 65 64 22 3a 0a 20 20 20 20 20 20 69 66 20 73 65 ed":. if se
97f0: 6c 66 2e 76 65 72 62 6f 73 65 3a 20 70 72 69 6e lf.verbose: prin
9800: 74 20 22 72 78 20 69 73 20 64 69 73 61 62 6c 65 t "rx is disable
9810: 64 2e 20 45 6e 61 62 6c 69 6e 67 2e 2e 2e 22 0a d. Enabling...".
9820: 20 20 20 20 20 20 73 65 6c 66 2e 73 65 6e 64 5f self.send_
9830: 63 6d 64 28 22 73 65 74 20 72 78 20 65 6e 61 62 cmd("set rx enab
9840: 6c 65 64 22 29 0a 20 20 20 20 20 20 23 20 52 65 led"). # Re
9850: 74 72 79 20 67 65 74 74 69 6e 67 20 72 78 20 69 try getting rx i
9860: 6e 66 6f 0a 20 20 20 20 20 20 6c 69 6e 65 73 20 nfo. lines
9870: 3d 20 73 65 6c 66 2e 64 6f 5f 73 69 6d 68 5f 73 = self.do_simh_s
9880: 68 6f 77 28 22 72 78 22 29 0a 20 20 20 20 20 20 how("rx").
9890: 72 78 5f 74 79 70 65 20 3d 20 73 65 6c 66 2e 70 rx_type = self.p
98a0: 61 72 73 65 5f 73 68 6f 77 5f 72 78 5f 64 65 76 arse_show_rx_dev
98b0: 20 28 6c 69 6e 65 73 29 0a 20 20 20 20 20 20 69 (lines). i
98c0: 66 20 72 78 5f 74 79 70 65 20 3d 3d 20 4e 6f 6e f rx_type == Non
98d0: 65 3a 0a 20 20 20 20 20 20 20 20 70 72 69 6e 74 e:. print
98e0: 20 22 64 6f 5f 72 78 5f 63 68 61 6e 67 65 20 61 "do_rx_change a
98f0: 66 74 65 72 20 72 65 2d 65 6e 61 62 6c 65 3a 20 fter re-enable:
9900: 54 72 6f 75 62 6c 65 20 70 61 72 73 69 6e 67 20 Trouble parsing
9910: 5c 60 73 68 6f 77 20 72 78 5c 60 20 6f 75 74 70 \`show rx\` outp
9920: 75 74 20 66 72 6f 6d 20 73 69 6d 68 2e 20 47 69 ut from simh. Gi
9930: 76 69 6e 67 20 75 70 20 6f 6e 3a 22 0a 20 20 20 ving up on:".
9940: 20 20 20 20 20 73 65 6c 66 2e 64 6f 5f 70 72 69 self.do_pri
9950: 6e 74 5f 6c 69 6e 65 73 28 6c 69 6e 65 73 29 0a nt_lines(lines).
9960: 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 46 return F
9970: 61 6c 73 65 0a 20 20 20 20 20 20 65 6c 69 66 20 alse. elif
9980: 72 78 5f 74 79 70 65 20 3d 3d 20 22 64 69 73 61 rx_type == "disa
9990: 62 6c 65 64 22 3a 0a 20 20 20 20 20 20 20 20 70 bled":. p
99a0: 72 69 6e 74 20 22 64 6f 5f 72 78 5f 63 68 61 6e rint "do_rx_chan
99b0: 67 65 20 72 65 2d 65 6e 61 62 6c 65 20 6f 66 20 ge re-enable of
99c0: 72 78 20 66 61 69 6c 65 64 2e 20 47 69 76 69 6e rx failed. Givin
99d0: 67 20 75 70 2e 22 0a 20 20 20 20 20 20 20 20 72 g up.". r
99e0: 65 74 75 72 6e 20 46 61 6c 73 65 0a 0a 20 20 20 eturn False..
99f0: 20 69 66 20 72 78 5f 74 79 70 65 2e 6c 6f 77 65 if rx_type.lowe
9a00: 72 28 29 20 3d 3d 20 74 6f 5f 72 78 3a 0a 20 20 r() == to_rx:.
9a10: 20 20 20 20 70 72 69 6e 74 20 22 72 78 20 64 65 print "rx de
9a20: 76 69 63 65 20 69 73 20 61 6c 72 65 61 64 79 20 vice is already
9a30: 73 65 74 20 74 6f 20 22 20 2b 20 74 6f 5f 72 78 set to " + to_rx
9a40: 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 4e 6f . return No
9a50: 6e 65 0a 20 20 20 20 20 20 0a 20 20 20 20 61 74 ne. . at
9a60: 74 61 63 68 65 64 5f 72 78 3d 20 73 65 6c 66 2e tached_rx= self.
9a70: 70 61 72 73 65 5f 73 68 6f 77 5f 72 78 5f 61 74 parse_show_rx_at
9a80: 74 61 63 68 65 64 28 6c 69 6e 65 73 29 0a 20 20 tached(lines).
9a90: 20 20 69 66 20 61 74 74 61 63 68 65 64 5f 72 78 if attached_rx
9aa0: 20 3d 3d 20 4e 6f 6e 65 3a 0a 20 20 20 20 20 20 == None:.
9ab0: 70 72 69 6e 74 20 22 64 6f 5f 72 78 5f 63 68 61 print "do_rx_cha
9ac0: 6e 67 65 3a 20 54 72 6f 75 62 6c 65 20 70 61 72 nge: Trouble par
9ad0: 73 69 6e 67 20 2f 27 73 68 6f 77 20 72 78 5c 27 sing /'show rx\'
9ae0: 20 66 72 6f 6d 20 73 69 6d 68 20 74 6f 20 66 69 from simh to fi
9af0: 6e 64 20 72 78 20 61 74 74 61 63 68 6d 65 6e 74 nd rx attachment
9b00: 73 2e 20 47 6f 74 3a 22 0a 20 20 20 20 20 20 73 s. Got:". s
9b10: 65 6c 66 2e 64 6f 5f 70 72 69 6e 74 5f 6c 69 6e elf.do_print_lin
9b20: 65 73 28 6c 69 6e 65 73 29 0a 20 20 20 20 65 6c es(lines). el
9b30: 73 65 3a 0a 20 20 20 20 20 20 66 6f 72 20 75 6e se:. for un
9b40: 69 74 20 69 6e 20 61 74 74 61 63 68 65 64 5f 72 it in attached_r
9b50: 78 2e 6b 65 79 73 28 29 3a 0a 20 20 20 20 20 20 x.keys():.
9b60: 20 20 69 66 20 61 74 74 61 63 68 65 64 5f 72 78 if attached_rx
9b70: 5b 75 6e 69 74 5d 20 21 3d 20 22 22 3a 0a 20 20 [unit] != "":.
9b80: 20 20 20 20 20 20 20 20 64 65 74 5f 63 6f 6d 6d det_comm
9b90: 20 3d 20 22 64 65 74 20 72 78 22 20 2b 20 75 6e = "det rx" + un
9ba0: 69 74 0a 20 20 20 20 20 20 20 20 20 20 69 66 20 it. if
9bb0: 73 65 6c 66 2e 76 65 72 62 6f 73 65 3a 20 70 72 self.verbose: pr
9bc0: 69 6e 74 20 64 65 74 5f 63 6f 6d 6d 20 2b 20 22 int det_comm + "
9bd0: 28 48 61 64 3a 20 22 20 2b 20 61 74 74 61 63 68 (Had: " + attach
9be0: 65 64 5f 72 78 5b 75 6e 69 74 5d 20 2b 20 22 29 ed_rx[unit] + ")
9bf0: 22 0a 20 20 20 20 20 20 20 20 20 20 73 65 6c 66 ". self
9c00: 2e 73 65 6e 64 5f 63 6d 64 28 64 65 74 5f 63 6f .send_cmd(det_co
9c10: 6d 6d 29 0a 0a 20 20 20 20 73 65 6c 66 2e 73 65 mm).. self.se
9c20: 6e 64 5f 63 6d 64 28 22 73 65 74 20 72 78 20 22 nd_cmd("set rx "
9c30: 20 2b 20 74 6f 5f 72 78 29 0a 0a 20 20 20 20 23 + to_rx).. #
9c40: 20 54 65 73 74 20 74 6f 20 63 6f 6e 66 69 72 6d Test to confirm
9c50: 20 6e 65 77 20 73 65 74 74 69 6e 67 20 6f 66 20 new setting of
9c60: 52 58 0a 20 20 20 20 6c 69 6e 65 73 20 3d 20 73 RX. lines = s
9c70: 65 6c 66 2e 64 6f 5f 73 69 6d 68 5f 73 68 6f 77 elf.do_simh_show
9c80: 28 22 72 78 22 29 0a 20 20 20 20 72 78 5f 74 79 ("rx"). rx_ty
9c90: 70 65 20 3d 20 73 65 6c 66 2e 70 61 72 73 65 5f pe = self.parse_
9ca0: 73 68 6f 77 5f 72 78 5f 64 65 76 20 28 6c 69 6e show_rx_dev (lin
9cb0: 65 73 29 0a 0a 20 20 20 20 69 66 20 72 78 5f 74 es).. if rx_t
9cc0: 79 70 65 20 3d 3d 20 4e 6f 6e 65 3a 0a 20 20 20 ype == None:.
9cd0: 20 20 20 70 72 69 6e 74 20 22 46 61 69 6c 65 64 print "Failed
9ce0: 20 63 68 61 6e 67 65 20 6f 66 20 72 78 20 74 6f change of rx to
9cf0: 20 22 20 2b 20 74 6f 5f 72 78 20 2b 20 22 2e 20 " + to_rx + ".
9d00: 50 61 72 73 65 20 66 61 69 6c 20 6f 6e 20 5c 27 Parse fail on \'
9d10: 73 68 6f 77 20 72 78 5c 27 2e 22 0a 20 20 20 20 show rx\'.".
9d20: 20 20 72 65 74 75 72 6e 20 46 61 6c 73 65 0a 20 return False.
9d30: 20 20 20 65 6c 69 66 20 72 78 5f 74 79 70 65 2e elif rx_type.
9d40: 6c 6f 77 65 72 28 29 20 21 3d 20 74 6f 5f 72 78 lower() != to_rx
9d50: 3a 20 0a 20 20 20 20 20 20 70 72 69 6e 74 20 22 : . print "
9d60: 46 61 69 6c 65 64 20 63 68 61 6e 67 65 20 6f 66 Failed change of
9d70: 20 72 78 20 74 6f 20 22 20 2b 20 74 6f 5f 72 78 rx to " + to_rx
9d80: 20 2b 20 22 2e 20 49 6e 73 74 65 61 64 20 67 6f + ". Instead go
9d90: 74 3a 20 22 20 2b 20 72 78 5f 74 79 70 65 0a 20 t: " + rx_type.
9da0: 20 20 20 20 20 72 65 74 75 72 6e 20 46 61 6c 73 return Fals
9db0: 65 0a 20 20 20 20 72 65 74 75 72 6e 20 54 72 75 e. return Tru
9dc0: 65 0a 0a 0a 20 20 23 23 23 23 20 67 65 74 5f 74 e... #### get_t
9dd0: 74 69 20 23 23 23 23 23 23 23 23 23 23 23 23 23 ti #############
9de0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
9df0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
9e00: 23 23 23 23 23 0a 20 20 23 20 52 65 74 75 72 6e #####. # Return
9e10: 73 20 61 6e 20 6f 72 64 65 72 65 64 20 6c 69 73 s an ordered lis
9e20: 74 20 6f 66 20 66 69 6c 65 73 20 61 74 74 61 63 t of files attac
9e30: 68 65 64 20 6f 72 20 4e 6f 6e 65 20 69 66 20 64 hed or None if d
9e40: 69 73 61 62 6c 65 64 2e 0a 20 20 64 65 66 20 70 isabled.. def p
9e50: 61 72 73 65 5f 73 68 6f 77 5f 74 74 69 20 28 73 arse_show_tti (s
9e60: 65 6c 66 2c 20 6c 69 6e 65 73 29 3a 0a 20 20 20 elf, lines):.
9e70: 20 69 66 20 6c 69 6e 65 73 20 3d 3d 20 4e 6f 6e if lines == Non
9e80: 65 3a 20 72 65 74 75 72 6e 20 4e 6f 6e 65 0a 20 e: return None.
9e90: 20 20 20 69 73 5f 65 6e 61 62 6c 65 64 5f 72 65 is_enabled_re
9ea0: 20 3d 20 72 65 2e 63 6f 6d 70 69 6c 65 28 22 5e = re.compile("^
9eb0: 28 4b 53 52 7c 37 62 29 24 22 29 0a 20 20 20 20 (KSR|7b)$").
9ec0: 69 66 20 6c 65 6e 28 6c 69 6e 65 73 29 20 3c 20 if len(lines) <
9ed0: 32 3a 20 72 65 74 75 72 6e 20 4e 6f 6e 65 0a 0a 2: return None..
9ee0: 20 20 20 20 23 20 54 68 61 74 20 73 65 63 6f 6e # That secon
9ef0: 64 20 6c 69 6e 65 20 6f 66 20 6f 75 74 70 75 74 d line of output
9f00: 20 63 6f 6e 74 61 69 6e 73 20 65 6d 62 65 64 64 contains embedd
9f10: 65 64 20 6e 65 77 6c 69 6e 65 73 2e 0a 20 20 20 ed newlines..
9f20: 20 6d 20 3d 20 72 65 2e 6d 61 74 63 68 28 69 73 m = re.match(is
9f30: 5f 65 6e 61 62 6c 65 64 5f 72 65 2c 20 6c 69 6e _enabled_re, lin
9f40: 65 73 5b 31 5d 2e 73 74 72 69 70 28 29 29 0a 20 es[1].strip()).
9f50: 20 20 20 69 66 20 6d 20 3d 3d 20 4e 6f 6e 65 20 if m == None
9f60: 6f 72 20 6d 2e 67 72 6f 75 70 28 31 29 20 3d 3d or m.group(1) ==
9f70: 20 4e 6f 6e 65 3a 20 72 65 74 75 72 6e 20 4e 6f None: return No
9f80: 6e 65 0a 20 20 20 20 72 65 74 75 72 6e 20 6d 2e ne. return m.
9f90: 67 72 6f 75 70 28 31 29 0a 0a 0a 0a 20 20 23 23 group(1).... ##
9fa0: 23 23 20 64 6f 5f 74 74 69 5f 63 68 61 6e 67 65 ## do_tti_change
9fb0: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ###############
9fc0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
9fd0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
9fe0: 23 23 23 23 0a 0a 20 20 64 65 66 20 73 65 74 5f ####.. def set_
9ff0: 74 74 69 5f 63 6f 6e 66 69 67 20 28 73 65 6c 66 tti_config (self
a000: 2c 20 74 6f 5f 74 74 69 29 3a 0a 20 20 20 20 69 , to_tti):. i
a010: 66 20 74 6f 5f 74 74 69 20 3d 3d 20 22 4b 53 52 f to_tti == "KSR
a020: 22 3a 20 66 72 6f 6d 5f 74 74 69 20 3d 20 22 37 ": from_tti = "7
a030: 62 22 0a 20 20 20 20 65 6c 69 66 20 74 6f 5f 74 b". elif to_t
a040: 74 69 20 3d 3d 20 22 37 62 22 3a 20 66 72 6f 6d ti == "7b": from
a050: 5f 74 74 69 20 3d 20 22 4b 53 52 22 0a 20 20 20 _tti = "KSR".
a060: 20 65 6c 73 65 3a 0a 20 20 20 20 20 20 70 72 69 else:. pri
a070: 6e 74 20 22 43 61 6e 6e 6f 74 20 73 65 74 5f 74 nt "Cannot set_t
a080: 74 69 5f 63 6f 6e 66 69 67 20 74 6f 20 22 20 2b ti_config to " +
a090: 20 74 6f 5f 74 74 69 0a 20 20 20 20 20 20 72 65 to_tti. re
a0a0: 74 75 72 6e 0a 20 20 20 20 0a 20 20 20 20 69 66 turn. . if
a0b0: 20 73 65 6c 66 2e 76 65 72 62 6f 73 65 3a 20 70 self.verbose: p
a0c0: 72 69 6e 74 20 22 53 77 69 74 63 68 20 74 74 69 rint "Switch tti
a0d0: 20 64 72 69 76 65 72 20 66 72 6f 6d 3a 20 22 20 driver from: "
a0e0: 2b 20 66 72 6f 6d 5f 74 74 69 20 2b 20 22 2c 20 + from_tti + ",
a0f0: 74 6f 3a 20 22 20 2b 20 74 6f 5f 74 74 69 0a 0a to: " + to_tti..
a100: 20 20 20 20 6c 69 6e 65 73 20 3d 20 73 65 6c 66 lines = self
a110: 2e 64 6f 5f 73 69 6d 68 5f 73 68 6f 77 28 22 74 .do_simh_show("t
a120: 74 69 22 29 0a 20 20 20 20 74 74 69 5f 74 79 70 ti"). tti_typ
a130: 65 20 3d 20 73 65 6c 66 2e 70 61 72 73 65 5f 73 e = self.parse_s
a140: 68 6f 77 5f 74 74 69 20 28 6c 69 6e 65 73 29 0a how_tti (lines).
a150: 20 20 20 20 69 66 20 74 74 69 5f 74 79 70 65 20 if tti_type
a160: 3d 3d 20 4e 6f 6e 65 3a 0a 20 20 20 20 20 20 70 == None:. p
a170: 72 69 6e 74 20 22 64 6f 5f 74 74 69 5f 63 68 61 rint "do_tti_cha
a180: 6e 67 65 3a 20 54 72 6f 75 62 6c 65 20 70 61 72 nge: Trouble par
a190: 73 69 6e 67 20 5c 27 73 68 6f 77 20 74 74 69 5c sing \'show tti\
a1a0: 27 20 6f 75 74 70 75 74 20 66 72 6f 6d 20 73 69 ' output from si
a1b0: 6d 68 2e 20 47 69 76 69 6e 67 20 75 70 20 6f 6e mh. Giving up on
a1c0: 3a 22 0a 20 20 20 20 20 20 73 65 6c 66 2e 64 6f :". self.do
a1d0: 5f 70 72 69 6e 74 5f 6c 69 6e 65 73 28 6c 69 6e _print_lines(lin
a1e0: 65 73 29 0a 20 20 20 20 20 20 72 65 74 75 72 6e es). return
a1f0: 20 46 61 6c 73 65 0a 20 20 20 20 65 6c 69 66 20 False. elif
a200: 74 74 69 5f 74 79 70 65 20 3d 3d 20 74 6f 5f 74 tti_type == to_t
a210: 74 69 3a 0a 20 20 20 20 20 20 70 72 69 6e 74 20 ti:. print
a220: 22 74 74 69 20 64 65 76 69 63 65 20 69 73 20 61 "tti device is a
a230: 6c 72 65 61 64 79 20 73 65 74 20 74 6f 20 22 20 lready set to "
a240: 2b 20 74 6f 5f 74 74 69 0a 20 20 20 20 20 20 72 + to_tti. r
a250: 65 74 75 72 6e 20 4e 6f 6e 65 0a 0a 20 20 20 20 eturn None..
a260: 73 65 6c 66 2e 73 65 6e 64 5f 63 6d 64 28 22 73 self.send_cmd("s
a270: 65 74 20 74 74 69 20 22 20 2b 20 74 6f 5f 74 74 et tti " + to_tt
a280: 69 29 0a 0a 20 20 20 20 23 20 54 65 73 74 20 74 i).. # Test t
a290: 6f 20 63 6f 6e 66 69 72 6d 20 6e 65 77 20 73 65 o confirm new se
a2a0: 74 74 69 6e 67 20 6f 66 20 74 74 69 0a 20 20 20 tting of tti.
a2b0: 20 6c 69 6e 65 73 20 3d 20 73 65 6c 66 2e 64 6f lines = self.do
a2c0: 5f 73 69 6d 68 5f 73 68 6f 77 28 22 74 74 69 22 _simh_show("tti"
a2d0: 29 0a 20 20 20 20 74 74 69 5f 74 79 70 65 20 3d ). tti_type =
a2e0: 20 73 65 6c 66 2e 70 61 72 73 65 5f 73 68 6f 77 self.parse_show
a2f0: 5f 74 74 69 20 28 6c 69 6e 65 73 29 0a 20 20 20 _tti (lines).
a300: 20 0a 20 20 20 20 69 66 20 74 74 69 5f 74 79 70 . if tti_typ
a310: 65 20 3d 3d 20 4e 6f 6e 65 3a 0a 20 20 20 20 20 e == None:.
a320: 20 70 72 69 6e 74 20 22 46 61 69 6c 65 64 20 63 print "Failed c
a330: 68 61 6e 67 65 20 6f 66 20 74 74 69 20 74 6f 20 hange of tti to
a340: 22 20 2b 20 74 6f 5f 74 74 69 20 2b 20 22 2e 20 " + to_tti + ".
a350: 50 61 72 73 65 20 66 61 69 6c 20 6f 6e 20 5c 27 Parse fail on \'
a360: 73 68 6f 77 20 74 74 69 5c 27 2e 22 0a 20 20 20 show tti\'.".
a370: 20 20 20 72 65 74 75 72 6e 20 46 61 6c 73 65 0a return False.
a380: 20 20 20 20 65 6c 69 66 20 74 74 69 5f 74 79 70 elif tti_typ
a390: 65 20 21 3d 20 74 6f 5f 74 74 69 3a 20 0a 20 20 e != to_tti: .
a3a0: 20 20 20 20 70 72 69 6e 74 20 22 46 61 69 6c 65 print "Faile
a3b0: 64 20 63 68 61 6e 67 65 20 6f 66 20 74 74 69 20 d change of tti
a3c0: 74 6f 20 22 20 2b 20 74 6f 5f 74 74 69 20 2b 20 to " + to_tti +
a3d0: 22 2e 20 49 6e 73 74 65 61 64 20 67 6f 74 3a 20 ". Instead got:
a3e0: 22 20 2b 20 74 74 69 5f 74 79 70 65 0a 20 20 20 " + tti_type.
a3f0: 20 20 20 72 65 74 75 72 6e 20 46 61 6c 73 65 0a return False.
a400: 20 20 20 20 65 6c 73 65 3a 0a 20 20 20 20 20 20 else:.
a410: 72 65 74 75 72 6e 20 54 72 75 65 0a 0a 0a return True...