0000: 23 21 2f 75 73 72 2f 62 69 6e 2f 65 6e 76 20 40 #!/usr/bin/env @
0010: 50 59 43 4d 44 40 0a 23 20 2d 2a 2d 20 63 6f 64 PYCMD@.# -*- cod
0020: 69 6e 67 3a 20 75 74 66 2d 38 20 2d 2a 2d 0a 23 ing: 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 23 0a 23 20 73 69 6d 68 2f 5f #######.# simh/_
0080: 5f 69 6e 69 74 5f 5f 2e 70 79 20 2d 20 41 20 77 _init__.py - A w
0090: 72 61 70 70 65 72 20 63 6c 61 73 73 20 61 72 6f rapper class aro
00a0: 75 6e 64 20 70 65 78 70 65 63 74 20 66 6f 72 20 und pexpect for
00b0: 63 6f 6d 6d 75 6e 69 63 61 74 69 6e 67 0a 23 20 communicating.#
00c0: 20 20 77 69 74 68 20 61 6e 20 69 6e 73 74 61 6e with an instan
00d0: 63 65 20 6f 66 20 74 68 65 20 50 69 44 50 2d 38 ce of the PiDP-8
00e0: 2f 49 20 53 49 4d 48 20 73 69 6d 75 6c 61 74 6f /I SIMH simulato
00f0: 72 20 72 75 6e 6e 69 6e 67 20 4f 53 2f 38 2e 0a r running OS/8..
0100: 23 0a 23 20 20 20 53 65 65 20 2e 2e 2f 64 6f 63 #.# See ../doc
0110: 2f 63 6c 61 73 73 2d 73 69 6d 68 2e 6d 64 20 66 /class-simh.md f
0120: 6f 72 20 61 20 75 73 61 67 65 20 74 75 74 6f 72 or a usage tutor
0130: 69 61 6c 2e 0a 23 0a 23 20 43 6f 70 79 72 69 67 ial..#.# Copyrig
0140: 68 74 20 c2 a9 20 32 30 31 37 20 62 79 20 4a 6f ht © 2017 by Jo
0150: 6e 61 74 68 61 6e 20 54 72 69 74 65 73 2c 20 c2 nathan Trites, Â
0160: a9 20 32 30 31 37 2d 32 30 32 30 20 62 79 20 57 © 2017-2020 by W
0170: 69 6c 6c 69 61 6d 20 43 61 74 74 65 79 0a 23 20 illiam Cattey.#
0180: 61 6e 64 20 57 61 72 72 65 6e 20 59 6f 75 6e 67 and Warren Young
0190: 2e 0a 23 0a 23 20 50 65 72 6d 69 73 73 69 6f 6e ..#.# Permission
01a0: 20 69 73 20 68 65 72 65 62 79 20 67 72 61 6e 74 is hereby grant
01b0: 65 64 2c 20 66 72 65 65 20 6f 66 20 63 68 61 72 ed, free of char
01c0: 67 65 2c 20 74 6f 20 61 6e 79 20 70 65 72 73 6f ge, to any perso
01d0: 6e 20 6f 62 74 61 69 6e 69 6e 67 0a 23 20 61 20 n obtaining.# a
01e0: 63 6f 70 79 20 6f 66 20 74 68 69 73 20 73 6f 66 copy of this sof
01f0: 74 77 61 72 65 20 61 6e 64 20 61 73 73 6f 63 69 tware and associ
0200: 61 74 65 64 20 64 6f 63 75 6d 65 6e 74 61 74 69 ated documentati
0210: 6f 6e 20 66 69 6c 65 73 20 28 74 68 65 0a 23 20 on files (the.#
0220: 22 53 6f 66 74 77 61 72 65 22 29 2c 20 74 6f 20 "Software"), to
0230: 64 65 61 6c 20 69 6e 20 74 68 65 20 53 6f 66 74 deal in the Soft
0240: 77 61 72 65 20 77 69 74 68 6f 75 74 20 72 65 73 ware without res
0250: 74 72 69 63 74 69 6f 6e 2c 20 69 6e 63 6c 75 64 triction, includ
0260: 69 6e 67 0a 23 20 77 69 74 68 6f 75 74 20 6c 69 ing.# without li
0270: 6d 69 74 61 74 69 6f 6e 20 74 68 65 20 72 69 67 mitation the rig
0280: 68 74 73 20 74 6f 20 75 73 65 2c 20 63 6f 70 79 hts to use, copy
0290: 2c 20 6d 6f 64 69 66 79 2c 20 6d 65 72 67 65 2c , modify, merge,
02a0: 20 70 75 62 6c 69 73 68 2c 0a 23 20 64 69 73 74 publish,.# dist
02b0: 72 69 62 75 74 65 2c 20 73 75 62 6c 69 63 65 6e ribute, sublicen
02c0: 73 65 2c 20 61 6e 64 2f 6f 72 20 73 65 6c 6c 20 se, and/or sell
02d0: 63 6f 70 69 65 73 20 6f 66 20 74 68 65 20 53 6f copies of the So
02e0: 66 74 77 61 72 65 2c 20 61 6e 64 20 74 6f 0a 23 ftware, and to.#
02f0: 20 70 65 72 6d 69 74 20 70 65 72 73 6f 6e 73 20 permit persons
0300: 74 6f 20 77 68 6f 6d 20 74 68 65 20 53 6f 66 74 to whom the Soft
0310: 77 61 72 65 20 69 73 20 66 75 72 6e 69 73 68 65 ware is furnishe
0320: 64 20 74 6f 20 64 6f 20 73 6f 2c 20 73 75 62 6a d to do so, subj
0330: 65 63 74 20 74 6f 0a 23 20 74 68 65 20 66 6f 6c ect to.# the fol
0340: 6c 6f 77 69 6e 67 20 63 6f 6e 64 69 74 69 6f 6e lowing condition
0350: 73 3a 0a 23 0a 23 20 54 68 65 20 61 62 6f 76 65 s:.#.# The above
0360: 20 63 6f 70 79 72 69 67 68 74 20 6e 6f 74 69 63 copyright notic
0370: 65 20 61 6e 64 20 74 68 69 73 20 70 65 72 6d 69 e and this permi
0380: 73 73 69 6f 6e 20 6e 6f 74 69 63 65 20 73 68 61 ssion notice sha
0390: 6c 6c 20 62 65 0a 23 20 69 6e 63 6c 75 64 65 64 ll be.# included
03a0: 20 69 6e 20 61 6c 6c 20 63 6f 70 69 65 73 20 6f in all copies o
03b0: 72 20 73 75 62 73 74 61 6e 74 69 61 6c 20 70 6f r substantial po
03c0: 72 74 69 6f 6e 73 20 6f 66 20 74 68 65 20 53 6f rtions of the So
03d0: 66 74 77 61 72 65 2e 0a 23 0a 23 20 54 48 45 20 ftware..#.# THE
03e0: 53 4f 46 54 57 41 52 45 20 49 53 20 50 52 4f 56 SOFTWARE IS PROV
03f0: 49 44 45 44 20 22 41 53 20 49 53 22 2c 20 57 49 IDED "AS IS", WI
0400: 54 48 4f 55 54 20 57 41 52 52 41 4e 54 59 20 4f THOUT WARRANTY O
0410: 46 20 41 4e 59 20 4b 49 4e 44 2c 0a 23 20 45 58 F ANY KIND,.# EX
0420: 50 52 45 53 53 20 4f 52 20 49 4d 50 4c 49 45 44 PRESS OR IMPLIED
0430: 2c 20 49 4e 43 4c 55 44 49 4e 47 20 42 55 54 20 , INCLUDING BUT
0440: 4e 4f 54 20 4c 49 4d 49 54 45 44 20 54 4f 20 54 NOT LIMITED TO T
0450: 48 45 20 57 41 52 52 41 4e 54 49 45 53 20 4f 46 HE WARRANTIES OF
0460: 0a 23 20 4d 45 52 43 48 41 4e 54 41 42 49 4c 49 .# MERCHANTABILI
0470: 54 59 2c 20 46 49 54 4e 45 53 53 20 46 4f 52 20 TY, FITNESS FOR
0480: 41 20 50 41 52 54 49 43 55 4c 41 52 20 50 55 52 A PARTICULAR PUR
0490: 50 4f 53 45 20 41 4e 44 20 4e 4f 4e 49 4e 46 52 POSE AND NONINFR
04a0: 49 4e 47 45 4d 45 4e 54 2e 0a 23 20 49 4e 20 4e INGEMENT..# IN N
04b0: 4f 20 45 56 45 4e 54 20 53 48 41 4c 4c 20 54 48 O EVENT SHALL TH
04c0: 45 20 41 55 54 48 4f 52 53 20 4c 49 53 54 45 44 E AUTHORS LISTED
04d0: 20 41 42 4f 56 45 20 42 45 20 4c 49 41 42 4c 45 ABOVE BE LIABLE
04e0: 20 46 4f 52 20 41 4e 59 20 43 4c 41 49 4d 2c 0a FOR ANY CLAIM,.
04f0: 23 20 44 41 4d 41 47 45 53 20 4f 52 20 4f 54 48 # DAMAGES OR OTH
0500: 45 52 20 4c 49 41 42 49 4c 49 54 59 2c 20 57 48 ER LIABILITY, WH
0510: 45 54 48 45 52 20 49 4e 20 41 4e 20 41 43 54 49 ETHER IN AN ACTI
0520: 4f 4e 20 4f 46 20 43 4f 4e 54 52 41 43 54 2c 20 ON OF CONTRACT,
0530: 54 4f 52 54 0a 23 20 4f 52 20 4f 54 48 45 52 57 TORT.# OR OTHERW
0540: 49 53 45 2c 20 41 52 49 53 49 4e 47 20 46 52 4f ISE, ARISING FRO
0550: 4d 2c 20 4f 55 54 20 4f 46 20 4f 52 20 49 4e 20 M, OUT OF OR IN
0560: 43 4f 4e 4e 45 43 54 49 4f 4e 20 57 49 54 48 20 CONNECTION WITH
0570: 54 48 45 20 53 4f 46 54 57 41 52 45 0a 23 20 4f THE SOFTWARE.# O
0580: 52 20 54 48 45 20 55 53 45 20 4f 52 20 4f 54 48 R THE USE OR OTH
0590: 45 52 20 44 45 41 4c 49 4e 47 53 20 49 4e 20 54 ER DEALINGS IN T
05a0: 48 45 20 53 4f 46 54 57 41 52 45 2e 0a 23 0a 23 HE SOFTWARE..#.#
05b0: 20 45 78 63 65 70 74 20 61 73 20 63 6f 6e 74 61 Except as conta
05c0: 69 6e 65 64 20 69 6e 20 74 68 69 73 20 6e 6f 74 ined in this not
05d0: 69 63 65 2c 20 74 68 65 20 6e 61 6d 65 73 20 6f ice, the names o
05e0: 66 20 74 68 65 20 61 75 74 68 6f 72 73 20 61 62 f the authors ab
05f0: 6f 76 65 0a 23 20 73 68 61 6c 6c 20 6e 6f 74 20 ove.# shall not
0600: 62 65 20 75 73 65 64 20 69 6e 20 61 64 76 65 72 be used in adver
0610: 74 69 73 69 6e 67 20 6f 72 20 6f 74 68 65 72 77 tising or otherw
0620: 69 73 65 20 74 6f 20 70 72 6f 6d 6f 74 65 20 74 ise to promote t
0630: 68 65 20 73 61 6c 65 2c 0a 23 20 75 73 65 20 6f he sale,.# use o
0640: 72 20 6f 74 68 65 72 20 64 65 61 6c 69 6e 67 73 r other dealings
0650: 20 69 6e 20 74 68 69 73 20 53 6f 66 74 77 61 72 in this Softwar
0660: 65 20 77 69 74 68 6f 75 74 20 70 72 69 6f 72 20 e without prior
0670: 77 72 69 74 74 65 6e 0a 23 20 61 75 74 68 6f 72 written.# author
0680: 69 7a 61 74 69 6f 6e 20 66 72 6f 6d 20 74 68 6f ization from tho
0690: 73 65 20 61 75 74 68 6f 72 73 2e 0a 23 23 23 23 se 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 23 0a 0a 69 6d 70 6f 72 74 20 6f 73 0a ####..import os.
06f0: 69 6d 70 6f 72 74 20 70 65 78 70 65 63 74 0a 69 import pexpect.i
0700: 6d 70 6f 72 74 20 70 6b 67 5f 72 65 73 6f 75 72 mport pkg_resour
0710: 63 65 73 0a 69 6d 70 6f 72 74 20 73 75 62 70 72 ces.import subpr
0720: 6f 63 65 73 73 0a 69 6d 70 6f 72 74 20 74 65 6d ocess.import tem
0730: 70 66 69 6c 65 0a 69 6d 70 6f 72 74 20 74 69 6d pfile.import tim
0740: 65 0a 69 6d 70 6f 72 74 20 72 65 0a 69 6d 70 6f e.import re.impo
0750: 72 74 20 73 79 73 0a 0a 69 6d 70 6f 72 74 20 70 rt sys..import p
0760: 69 64 70 38 69 0a 0a 23 23 23 23 20 73 69 6d 68 idp8i..#### simh
0770: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ###############
0780: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
0790: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
07a0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 23 ##############.#
07b0: 20 4f 62 6a 65 63 74 20 74 6f 20 6d 61 6e 61 67 Object to manag
07c0: 65 20 61 20 72 75 6e 6e 69 6e 67 20 53 49 4d 48 e a running SIMH
07d0: 20 70 72 6f 63 65 73 73 20 70 72 6f 67 72 61 6d process program
07e0: 6d 61 74 69 63 61 6c 6c 79 20 77 69 74 68 20 70 matically with p
07f0: 65 78 70 65 63 74 2e 0a 23 20 46 75 6e 63 74 69 expect..# Functi
0800: 6f 6e 73 20 69 6e 20 74 68 69 73 20 66 69 6c 65 ons in this file
0810: 20 61 72 65 20 6f 72 67 61 6e 69 7a 65 64 20 66 are organized f
0820: 72 6f 6d 20 6c 6f 77 65 72 20 6c 65 76 65 6c 20 rom lower level
0830: 74 6f 20 68 69 67 68 65 72 0a 23 20 6c 65 76 65 to higher.# leve
0840: 6c 20 77 68 65 72 65 20 70 6f 73 73 69 62 6c 65 l where possible
0850: 2e 0a 0a 0a 23 23 23 23 20 50 72 69 76 61 74 65 ....#### Private
0860: 20 66 75 6e 63 74 69 6f 6e 73 20 23 23 23 23 23 functions #####
0870: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
0880: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
0890: 23 23 23 23 23 23 23 23 23 23 23 0a 0a 0a 23 23 ###########...##
08a0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
08b0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
08c0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
08d0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
08e0: 23 23 23 23 23 0a 23 20 20 73 69 6d 68 20 63 6c #####.# simh cl
08f0: 61 73 73 0a 0a 63 6c 61 73 73 20 73 69 6d 68 3a ass..class simh:
0900: 0a 20 20 23 23 23 23 20 63 6f 6e 73 74 61 6e 74 . #### constant
0910: 73 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23 s ##############
0920: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
0930: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
0940: 23 23 23 23 23 23 23 23 0a 20 20 23 20 70 65 78 ########. # pex
0950: 70 65 63 74 20 6f 62 6a 65 63 74 20 69 6e 73 74 pect object inst
0960: 61 6e 63 65 2c 20 73 65 74 20 62 79 20 63 74 6f ance, set by cto
0970: 72 0a 20 20 5f 63 68 69 6c 64 20 3d 20 4e 6f 6e r. _child = Non
0980: 65 0a 0a 20 20 23 20 43 6f 6e 73 74 61 6e 74 20 e.. # Constant
0990: 75 73 65 64 20 62 79 20 6f 73 38 5f 6b 62 64 5f used by os8_kbd_
09a0: 64 65 6c 61 79 2c 20 61 73 73 65 6d 62 6c 65 64 delay, assembled
09b0: 20 69 6e 20 73 74 61 67 65 73 3a 0a 20 20 23 0a in stages:. #.
09c0: 20 20 23 20 31 2e 20 50 44 50 2d 38 20 52 53 2d # 1. PDP-8 RS-
09d0: 32 33 32 20 62 69 74 73 20 70 65 72 20 63 68 61 232 bits per cha
09e0: 72 61 63 74 65 72 3a 20 37 2d 62 69 74 20 41 53 racter: 7-bit AS
09f0: 43 49 49 20 70 6c 75 73 20 6e 65 63 65 73 73 61 CII plus necessa
0a00: 72 79 0a 20 20 23 20 20 20 20 73 74 61 72 74 2c ry. # start,
0a10: 20 73 74 6f 70 2c 20 61 6e 64 20 70 61 72 69 74 stop, and parit
0a20: 79 20 62 69 74 73 2e 0a 20 20 23 0a 20 20 23 20 y bits.. #. #
0a30: 32 2e 20 54 68 65 20 72 61 74 69 6f 20 6f 66 20 2. The ratio of
0a40: 74 68 65 20 69 6e 73 74 72 75 63 74 69 6f 6e 73 the instructions
0a50: 20 70 65 72 20 73 65 63 6f 6e 64 20 72 61 74 69 per second rati
0a60: 6f 73 20 6f 66 20 61 20 50 44 50 2d 38 2f 49 20 os of a PDP-8/I
0a70: 74 6f 0a 20 20 23 20 20 20 20 74 68 61 74 20 6f to. # that o
0a80: 66 20 74 68 65 20 68 6f 73 74 20 68 61 72 64 77 f the host hardw
0a90: 61 72 65 20 72 75 6e 6e 69 6e 67 20 74 68 65 20 are running the
0aa0: 73 69 6d 75 6c 61 74 6f 72 2e 20 20 54 68 65 20 simulator. The
0ab0: 66 6f 72 6d 65 72 20 69 73 0a 20 20 23 20 20 20 former is. #
0ac0: 20 61 6e 20 61 70 70 72 6f 78 69 6d 61 74 65 20 an approximate
0ad0: 76 61 6c 75 65 3b 20 73 65 65 20 6c 69 62 2f 70 value; see lib/p
0ae0: 69 64 70 38 69 2f 69 70 73 2e 70 79 2e 69 6e 20 idp8i/ips.py.in
0af0: 66 6f 72 20 74 68 65 20 76 61 6c 75 65 20 61 6e for the value an
0b00: 64 0a 20 20 23 20 20 20 20 69 74 73 20 64 65 66 d. # its def
0b10: 65 6e 73 65 2e 20 20 54 68 65 20 6c 61 74 74 65 ense. The latte
0b20: 72 20 69 73 20 65 69 74 68 65 72 20 74 68 65 20 r is either the
0b30: 49 50 53 20 72 61 74 65 20 66 6f 72 3a 0a 20 20 IPS rate for:.
0b40: 23 0a 20 20 23 20 20 20 20 61 29 20 61 20 52 61 #. # a) a Ra
0b50: 73 70 62 65 72 72 79 20 50 69 20 4d 6f 64 65 6c spberry Pi Model
0b60: 20 42 2b 2c 20 74 68 61 74 20 62 65 69 6e 67 20 B+, that being
0b70: 74 68 65 20 73 6c 6f 77 65 73 74 20 68 6f 73 74 the slowest host
0b80: 20 73 79 73 74 65 6d 0a 20 20 23 20 20 20 20 20 system. #
0b90: 20 20 77 65 20 72 75 6e 20 74 68 69 73 20 73 69 we run this si
0ba0: 6d 75 6c 61 74 6f 72 20 6f 6e 3b 20 6f 72 0a 20 mulator on; or.
0bb0: 20 23 0a 20 20 23 20 20 20 20 62 29 20 74 68 65 #. # b) the
0bc0: 20 49 50 53 20 72 61 74 65 20 6f 66 20 74 68 65 IPS rate of the
0bd0: 20 61 63 74 75 61 6c 20 68 6f 73 74 20 68 61 72 actual host har
0be0: 64 77 61 72 65 20 69 66 20 79 6f 75 20 68 61 76 dware if you hav
0bf0: 65 20 72 75 6e 20 74 68 65 0a 20 20 23 20 20 20 e run the. #
0c00: 20 20 20 20 22 62 69 6e 2f 74 65 63 6f 2d 70 69 "bin/teco-pi
0c10: 2d 64 65 6d 6f 20 2d 62 22 20 62 65 6e 63 68 6d -demo -b" benchm
0c20: 61 72 6b 20 6f 6e 20 69 74 2e 0a 20 20 23 0a 20 ark on it.. #.
0c30: 20 23 20 32 2e 20 54 68 65 20 66 61 63 74 20 74 # 2. The fact t
0c40: 68 61 74 20 72 65 61 6c 20 50 44 50 2d 38 73 20 hat real PDP-8s
0c50: 72 61 6e 20 4f 53 2f 38 20 72 65 6c 69 61 62 6c ran OS/8 reliabl
0c60: 79 20 61 74 20 33 30 30 20 62 70 73 2c 20 61 6e y at 300 bps, an
0c70: 64 20 68 61 76 65 0a 20 20 23 20 20 20 20 62 65 d have. # be
0c80: 65 6e 20 63 6c 61 69 6d 65 64 20 74 6f 20 67 65 en claimed to ge
0c90: 74 20 66 6c 61 6b 79 20 61 73 20 65 61 72 6c 79 t flaky as early
0ca0: 20 61 73 20 36 30 30 20 62 70 73 20 62 79 20 73 as 600 bps by s
0cb0: 6f 6d 65 2e 20 20 28 4f 74 68 65 72 73 0a 20 20 ome. (Others.
0cc0: 23 20 20 20 20 63 6c 61 69 6d 20 74 6f 20 68 61 # claim to ha
0cd0: 76 65 20 72 75 6e 20 74 68 65 6d 20 75 70 20 74 ve run them up t
0ce0: 6f 20 39 2c 36 30 30 20 62 70 73 2e 29 0a 20 20 o 9,600 bps.).
0cf0: 23 0a 20 20 23 20 33 2e 20 54 68 65 20 22 73 61 #. # 3. The "sa
0d00: 66 65 20 42 50 53 22 20 76 61 6c 75 65 20 69 73 fe BPS" value is
0d10: 20 74 68 65 20 66 61 73 74 65 73 74 20 62 69 74 the fastest bit
0d20: 20 70 65 72 20 73 65 63 6f 6e 64 20 73 70 65 65 per second spee
0d30: 64 20 61 63 74 75 61 6c 0a 20 20 23 20 20 20 20 d actual. #
0d40: 50 44 50 2d 38 20 68 61 72 64 77 61 72 65 20 77 PDP-8 hardware w
0d50: 61 73 20 6b 6e 6f 77 6e 20 74 6f 20 72 75 6e 20 as known to run
0d60: 4f 53 2f 38 20 74 65 72 6d 69 6e 61 6c 20 49 2f OS/8 terminal I/
0d70: 4f 20 61 74 2e 20 20 49 6e 20 74 68 69 73 0a 20 O at. In this.
0d80: 20 23 20 20 20 20 63 61 73 65 2c 20 69 74 20 69 # case, it i
0d90: 73 20 74 68 65 20 68 69 67 68 2d 73 70 65 65 64 s the high-speed
0da0: 20 74 61 70 65 20 72 65 61 64 65 72 2e 0a 20 20 tape reader..
0db0: 23 0a 20 20 23 20 20 20 20 54 4f 44 4f 3a 20 57 #. # TODO: W
0dc0: 65 20 6d 61 79 20 62 65 20 61 62 6c 65 20 74 6f e may be able to
0dd0: 20 69 6e 63 72 65 61 73 65 20 74 68 69 73 2e 0a increase this..
0de0: 20 20 23 0a 20 20 23 20 20 20 20 57 65 20 68 61 #. # We ha
0df0: 76 65 20 6f 6e 65 20 72 65 70 6f 72 74 20 74 68 ve one report th
0e00: 61 74 20 4f 53 2f 38 20 77 61 73 20 74 65 73 74 at OS/8 was test
0e10: 65 64 20 77 69 74 68 20 74 65 72 6d 69 6e 61 6c ed with terminal
0e20: 73 20 75 70 20 74 6f 0a 20 20 23 20 20 20 20 61 s up to. # a
0e30: 62 6f 75 74 20 7e 36 30 30 20 62 70 73 20 62 65 bout ~600 bps be
0e40: 66 6f 72 65 20 62 65 63 6f 6d 69 6e 67 20 75 6e fore becoming un
0e50: 72 65 6c 69 61 62 6c 65 2e 0a 20 20 23 0a 20 20 reliable.. #.
0e60: 23 20 20 20 20 57 65 20 68 61 76 65 20 61 6e 6f # We have ano
0e70: 74 68 65 72 20 72 65 70 6f 72 74 20 74 68 61 74 ther report that
0e80: 20 4f 53 2f 38 20 63 6f 75 6c 64 20 72 75 6e 20 OS/8 could run
0e90: 75 6e 64 65 72 20 45 54 4f 53 20 77 69 74 68 0a under ETOS with.
0ea0: 20 20 23 20 20 20 20 39 2c 36 30 30 20 62 70 73 # 9,600 bps
0eb0: 20 74 65 72 6d 69 6e 61 6c 73 2c 20 62 75 74 20 terminals, but
0ec0: 77 65 20 64 6f 6e 27 74 20 6b 6e 6f 77 20 69 66 we don't know if
0ed0: 20 74 68 61 74 20 74 65 6c 6c 73 20 75 73 20 61 that tells us a
0ee0: 6e 79 74 68 69 6e 67 0a 20 20 23 20 20 20 20 61 nything. # a
0ef0: 62 6f 75 74 20 4f 53 2f 38 20 72 75 6e 6e 69 6e bout OS/8 runnin
0f00: 67 20 77 69 74 68 6f 75 74 20 74 68 65 20 45 54 g without the ET
0f10: 4f 53 20 6d 75 6c 74 69 74 61 73 6b 69 6e 67 20 OS multitasking
0f20: 68 61 72 64 77 61 72 65 2e 0a 20 20 23 0a 20 20 hardware.. #.
0f30: 23 20 34 2e 20 47 69 76 65 6e 20 61 62 6f 76 65 # 4. Given above
0f40: 2c 20 63 61 6c 63 75 6c 61 74 65 20 73 61 66 65 , calculate safe
0f50: 20 63 68 61 72 61 63 74 65 72 73 20 70 65 72 20 characters per
0f60: 73 65 63 6f 6e 64 20 66 6f 72 20 68 6f 73 74 20 second for host
0f70: 48 57 2e 0a 20 20 23 0a 20 20 23 20 35 2e 20 49 HW.. #. # 5. I
0f80: 6e 76 65 72 74 20 74 6f 20 67 65 74 20 73 65 63 nvert to get sec
0f90: 6f 6e 64 73 20 70 65 72 20 63 68 61 72 61 63 74 onds per charact
0fa0: 65 72 2c 20 74 68 61 74 20 62 65 69 6e 67 20 74 er, that being t
0fb0: 68 65 20 64 65 6c 61 79 20 76 61 6c 75 65 2e 0a he delay value..
0fc0: 20 20 5f 62 70 63 20 3d 20 37 20 2b 20 31 20 2b _bpc = 7 + 1 +
0fd0: 20 31 20 2b 20 31 20 20 20 20 20 20 20 20 20 20 1 + 1
0fe0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0ff0: 20 20 20 20 20 20 20 20 20 20 20 20 20 23 20 5b # [
1000: 31 5d 0a 20 20 5f 69 70 73 5f 72 61 74 69 6f 20 1]. _ips_ratio
1010: 3d 20 66 6c 6f 61 74 20 28 70 69 64 70 38 69 2e = float (pidp8i.
1020: 69 70 73 2e 63 75 72 72 65 6e 74 29 20 2f 20 70 ips.current) / p
1030: 69 64 70 38 69 2e 69 70 73 2e 70 64 70 38 69 20 idp8i.ips.pdp8i
1040: 23 20 5b 32 5d 0a 20 20 5f 70 64 70 38 69 5f 73 # [2]. _pdp8i_s
1050: 61 66 65 5f 62 70 73 20 3d 20 33 30 30 20 20 20 afe_bps = 300
1060: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1070: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1080: 20 20 20 23 20 5b 33 5d 0a 20 20 5f 68 6f 73 74 # [3]. _host
1090: 5f 73 61 66 65 5f 63 70 73 20 3d 20 5f 70 64 70 _safe_cps = _pdp
10a0: 38 69 5f 73 61 66 65 5f 62 70 73 20 2a 20 5f 69 8i_safe_bps * _i
10b0: 70 73 5f 72 61 74 69 6f 20 2f 20 5f 62 70 63 20 ps_ratio / _bpc
10c0: 20 20 20 20 20 20 23 20 5b 34 5d 0a 20 20 5f 6f # [4]. _o
10d0: 73 38 5f 6b 62 64 5f 64 65 6c 61 79 20 3d 20 31 s8_kbd_delay = 1
10e0: 20 2f 20 5f 68 6f 73 74 5f 73 61 66 65 5f 63 70 / _host_safe_cp
10f0: 73 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 s
1100: 20 20 20 20 20 20 20 20 20 23 20 5b 35 5d 0a 0a # [5]..
1110: 0a 20 20 23 23 23 23 20 5f 73 69 6d 68 5f 72 65 . #### _simh_re
1120: 70 6c 69 65 73 20 23 23 23 23 23 23 23 23 23 23 plies ##########
1130: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
1140: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
1150: 23 23 23 23 23 23 23 0a 20 20 23 20 41 72 72 61 #######. # Arra
1160: 79 20 6f 66 20 69 74 65 6d 73 20 74 68 61 74 20 y of items that
1170: 64 65 73 63 72 69 62 65 20 72 65 70 6c 69 65 73 describe replies
1180: 20 6f 6e 65 20 6d 69 67 68 74 20 67 65 74 20 66 one might get f
1190: 72 6f 6d 20 53 49 4d 48 2e 0a 20 20 23 20 45 61 rom SIMH.. # Ea
11a0: 63 68 20 69 74 65 6d 20 69 73 20 61 20 32 20 65 ch item is a 2 e
11b0: 6c 65 6d 65 6e 74 20 61 72 72 61 79 20 63 6f 6e lement array con
11c0: 73 69 73 74 69 6e 67 20 6f 66 3a 0a 20 20 23 20 sisting of:. #
11d0: 20 20 20 5b 30 5d 20 41 20 68 65 6c 70 20 73 74 [0] A help st
11e0: 72 69 6e 67 20 74 68 61 74 20 64 65 73 63 72 69 ring that descri
11f0: 62 65 73 20 74 68 65 20 72 65 70 6c 79 2e 0a 20 bes the reply..
1200: 20 23 20 20 20 20 20 20 20 20 4d 61 74 63 68 20 # Match
1210: 61 67 61 69 6e 73 74 20 74 68 69 73 20 73 74 72 against this str
1220: 69 6e 67 20 77 68 65 6e 20 74 65 73 74 69 6e 67 ing when testing
1230: 20 65 72 72 6f 72 20 76 61 6c 75 65 73 2e 0a 20 error values..
1240: 20 23 20 20 20 20 20 20 20 20 54 68 69 73 20 76 # This v
1250: 61 6c 75 65 20 6d 61 79 20 6e 6f 74 20 62 65 20 alue may not be
1260: 75 6e 69 71 75 65 2e 20 57 68 65 6e 20 6e 6f 74 unique. When not
1270: 20 75 6e 69 71 75 65 0a 20 20 23 20 20 20 20 20 unique. #
1280: 20 20 20 74 68 65 20 6d 75 6c 74 69 70 6c 65 20 the multiple
1290: 76 61 6c 75 65 73 20 73 68 6f 75 6c 64 20 72 65 values should re
12a0: 70 72 65 73 65 6e 74 20 74 68 65 20 73 61 6d 65 present the same
12b0: 20 65 72 72 6f 72 2e 0a 20 20 23 0a 20 20 23 20 error.. #. #
12c0: 20 20 20 5b 31 5d 20 41 20 72 65 67 75 6c 61 72 [1] A regular
12d0: 20 65 78 70 72 65 73 73 69 6f 6e 20 66 6f 72 20 expression for
12e0: 70 65 78 70 65 63 74 20 74 6f 20 75 73 65 20 74 pexpect to use t
12f0: 6f 20 6d 61 74 63 68 20 6f 6e 20 69 74 2e 0a 20 o match on it..
1300: 20 23 20 20 20 20 20 20 20 20 49 74 20 69 73 20 # It is
1310: 61 20 67 6f 6f 64 20 69 64 65 61 20 74 6f 20 74 a good idea to t
1320: 65 72 6d 69 6e 61 74 65 20 73 74 61 74 75 73 20 erminate status
1330: 6d 65 73 73 61 67 65 73 20 77 69 74 68 20 22 5c messages with "\
1340: 72 22 0a 20 20 23 20 20 20 20 20 20 20 20 69 6e r". # in
1350: 20 6f 72 64 65 72 20 74 6f 20 63 6f 6e 66 69 72 order to confir
1360: 6d 20 77 65 27 76 65 20 67 6f 74 20 74 68 65 20 m we've got the
1370: 77 68 6f 6c 65 20 6c 69 6e 65 2c 0a 20 20 23 20 whole line,. #
1380: 20 20 20 20 20 20 20 61 6e 64 20 70 72 6f 6d 70 and promp
1390: 74 73 20 77 69 74 68 20 22 24 22 20 74 6f 20 74 ts with "$" to t
13a0: 65 72 6d 69 6e 61 74 65 20 74 68 65 20 73 65 61 erminate the sea
13b0: 72 63 68 2e 0a 20 20 23 0a 20 20 23 20 20 20 20 rch.. #. #
13c0: 20 20 20 20 46 6f 72 20 73 70 65 65 64 20 61 6e For speed an
13d0: 64 20 65 66 66 69 63 69 65 6e 63 79 20 61 6e 20 d efficiency an
13e0: 61 72 72 61 79 20 6f 66 20 63 6f 6d 70 69 6c 65 array of compile
13f0: 64 0a 20 20 23 20 20 20 20 20 20 20 20 72 65 67 d. # reg
1400: 75 6c 61 72 20 65 78 70 72 65 73 73 69 6f 6e 73 ular expressions
1410: 2c 20 69 6e 64 65 78 65 64 20 74 6f 20 5f 73 69 , indexed to _si
1420: 6d 68 5f 72 65 70 6c 69 65 73 0a 20 20 23 20 20 mh_replies. #
1430: 20 20 20 20 20 20 69 73 20 63 72 65 61 74 65 64 is created
1440: 20 62 79 20 5f 5f 69 6e 69 74 5f 5f 3a 20 73 69 by __init__: si
1450: 6d 68 5f 72 65 70 6c 69 65 73 5f 72 65 78 0a 20 mh_replies_rex.
1460: 20 0a 20 20 5f 73 69 6d 68 5f 72 65 70 6c 69 65 . _simh_replie
1470: 73 20 3d 20 5b 0a 20 20 20 20 23 20 50 72 6f 6d s = [. # Prom
1480: 70 74 73 3a 0a 20 20 20 20 5b 22 50 72 6f 6d 70 pts:. ["Promp
1490: 74 22 2c 20 22 73 69 6d 3e 20 24 22 5d 2c 0a 20 t", "sim> $"],.
14a0: 20 20 20 23 20 47 75 61 72 64 20 61 67 61 69 6e # Guard again
14b0: 73 74 20 63 61 73 65 20 77 65 20 75 73 65 64 20 st case we used
14c0: 74 68 65 20 73 69 6d 68 20 74 61 62 6c 65 20 77 the simh table w
14d0: 68 65 6e 20 77 65 20 6d 65 61 6e 74 20 74 68 65 hen we meant the
14e0: 20 4f 53 2f 38 20 74 61 62 6c 65 2e 20 0a 20 20 OS/8 table. .
14f0: 20 20 5b 22 4d 6f 6e 69 74 6f 72 20 50 72 6f 6d ["Monitor Prom
1500: 70 74 22 2c 20 22 5c 6e 5c 5c 2e 24 22 5d 2c 0a pt", "\n\\.$"],.
1510: 20 20 20 20 5b 22 4e 6f 6e 2d 65 78 69 73 74 65 ["Non-existe
1520: 6e 74 20 64 65 76 69 63 65 22 2c 20 22 4e 6f 6e nt device", "Non
1530: 2d 65 78 69 73 74 65 6e 74 20 64 65 76 69 63 65 -existent device
1540: 22 5d 2c 0a 20 20 20 20 5d 0a 0a 20 20 23 23 23 "],. ].. ###
1550: 23 5f 6f 73 38 5f 72 65 70 6c 69 65 73 20 23 23 #_os8_replies ##
1560: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
1570: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
1580: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
1590: 0a 20 20 23 20 53 69 6d 69 61 72 20 74 6f 20 5f . # Simiar to _
15a0: 73 69 6d 68 5f 72 65 70 6c 69 65 73 2c 20 62 75 simh_replies, bu
15b0: 74 20 64 65 73 63 72 69 62 69 6e 67 20 72 65 70 t describing rep
15c0: 6c 69 65 73 20 66 72 6f 6d 20 4f 53 2f 38 0a 20 lies from OS/8.
15d0: 20 23 20 77 68 65 6e 20 69 74 20 69 73 20 72 75 # when it is ru
15e0: 6e 6e 69 6e 67 20 75 6e 64 65 72 20 53 49 4d 48 nning under SIMH
15f0: 2e 0a 20 20 23 20 45 61 63 68 20 69 74 65 6d 20 .. # Each item
1600: 69 73 20 61 20 33 20 65 6c 65 6d 65 6e 74 20 61 is a 3 element a
1610: 72 72 61 79 20 63 6f 6e 73 69 73 74 69 6e 67 20 rray consisting
1620: 6f 66 3a 0a 20 20 23 20 20 20 20 5b 30 5d 20 41 of:. # [0] A
1630: 20 68 65 6c 70 20 73 74 72 69 6e 67 20 74 68 61 help string tha
1640: 74 20 64 65 73 63 72 69 62 65 73 20 74 68 65 20 t describes the
1650: 72 65 70 6c 79 2e 0a 20 20 23 20 20 20 20 20 20 reply.. #
1660: 20 20 4d 61 74 63 68 20 61 67 61 69 6e 73 74 20 Match against
1670: 74 68 69 73 20 73 74 72 69 6e 67 20 77 68 65 6e this string when
1680: 20 74 65 73 74 69 6e 67 20 65 72 72 6f 72 20 76 testing error v
1690: 61 6c 75 65 73 2e 0a 20 20 23 20 20 20 20 20 20 alues.. #
16a0: 20 20 54 68 69 73 20 76 61 6c 75 65 20 6d 61 79 This value may
16b0: 20 6e 6f 74 20 62 65 20 75 6e 69 71 75 65 2e 20 not be unique.
16c0: 57 68 65 6e 20 6e 6f 74 20 75 6e 69 71 75 65 0a When not unique.
16d0: 20 20 23 20 20 20 20 20 20 20 20 74 68 65 20 6d # the m
16e0: 75 6c 74 69 70 6c 65 20 76 61 6c 75 65 73 20 73 ultiple values s
16f0: 68 6f 75 6c 64 20 72 65 70 72 65 73 65 6e 74 20 hould represent
1700: 74 68 65 20 73 61 6d 65 20 65 72 72 6f 72 2e 0a the same error..
1710: 20 20 23 0a 20 20 23 20 20 20 20 5b 31 5d 20 41 #. # [1] A
1720: 20 72 65 67 75 6c 61 72 20 65 78 70 72 65 73 73 regular express
1730: 69 6f 6e 20 66 6f 72 20 70 65 78 70 65 63 74 20 ion for pexpect
1740: 74 6f 20 75 73 65 20 74 6f 20 6d 61 74 63 68 20 to use to match
1750: 6f 6e 20 69 74 2e 0a 20 20 23 20 20 20 20 20 20 on it.. #
1760: 20 20 49 74 20 69 73 20 61 20 67 6f 6f 64 20 69 It is a good i
1770: 64 65 61 20 74 6f 20 74 65 72 6d 69 6e 61 74 65 dea to terminate
1780: 20 73 74 61 74 75 73 20 6d 65 73 73 61 67 65 73 status messages
1790: 20 77 69 74 68 20 22 5c 72 22 0a 20 20 23 20 20 with "\r". #
17a0: 20 20 20 20 20 20 69 6e 20 6f 72 64 65 72 20 74 in order t
17b0: 6f 20 63 6f 6e 66 69 72 6d 20 77 65 27 76 65 20 o confirm we've
17c0: 67 6f 74 20 74 68 65 20 77 68 6f 6c 65 20 6c 69 got the whole li
17d0: 6e 65 2c 0a 20 20 23 20 20 20 20 20 20 20 20 61 ne,. # a
17e0: 6e 64 20 70 72 6f 6d 70 74 73 20 77 69 74 68 20 nd prompts with
17f0: 22 24 22 20 74 6f 20 74 65 72 6d 69 6e 61 74 65 "$" to terminate
1800: 20 74 68 65 20 73 65 61 72 63 68 2e 0a 20 20 23 the search.. #
1810: 0a 20 20 23 20 20 20 20 20 20 20 20 46 6f 72 20 . # For
1820: 73 70 65 65 64 20 61 6e 64 20 65 66 66 69 63 69 speed and effici
1830: 65 6e 63 79 20 61 6e 20 61 72 72 61 79 20 6f 66 ency an array of
1840: 20 63 6f 6d 70 69 6c 65 64 0a 20 20 23 20 20 20 compiled. #
1850: 20 20 20 20 20 72 65 67 75 6c 61 72 20 65 78 70 regular exp
1860: 72 65 73 73 69 6f 6e 73 2c 20 69 6e 64 65 78 65 ressions, indexe
1870: 64 20 74 6f 20 5f 73 69 6d 68 5f 72 65 70 6c 69 d to _simh_repli
1880: 65 73 0a 20 20 23 20 20 20 20 20 20 20 20 69 73 es. # is
1890: 20 63 72 65 61 74 65 64 20 62 79 20 5f 5f 69 6e created by __in
18a0: 69 74 5f 5f 3a 20 6f 73 38 5f 72 65 70 6c 69 65 it__: os8_replie
18b0: 73 5f 72 65 78 0a 20 20 23 0a 20 20 23 20 20 20 s_rex. #. #
18c0: 20 5b 32 5d 20 41 20 54 72 75 65 2f 46 61 6c 73 [2] A True/Fals
18d0: 65 20 69 6e 64 69 63 61 74 6f 72 20 69 66 20 74 e indicator if t
18e0: 68 65 20 63 6f 6d 6d 61 6e 64 20 72 65 74 75 72 he command retur
18f0: 6e 65 64 20 74 6f 20 74 68 65 0a 20 20 23 20 20 ned to the. #
1900: 20 20 20 20 20 20 6b 65 79 62 6f 61 72 64 20 6d keyboard m
1910: 6f 6e 69 74 6f 72 2c 20 72 61 74 68 65 72 20 74 onitor, rather t
1920: 68 61 6e 20 63 6f 6e 74 69 6e 75 69 6e 67 20 69 han continuing i
1930: 6e 20 74 68 65 20 70 72 6f 67 72 61 6d 2e 20 20 n the program.
1940: 20 20 0a 0a 20 20 5f 6f 73 38 5f 72 65 70 6c 69 .. _os8_repli
1950: 65 73 20 3d 20 5b 0a 20 20 20 20 23 20 50 72 6f es = [. # Pro
1960: 6d 70 74 73 3a 0a 20 20 20 20 5b 22 4d 6f 6e 69 mpts:. ["Moni
1970: 74 6f 72 20 50 72 6f 6d 70 74 22 2c 20 22 5c 6e tor Prompt", "\n
1980: 5c 5c 2e 24 22 2c 20 54 72 75 65 5d 2c 0a 20 20 \\.$", True],.
1990: 20 20 5b 22 43 6f 6d 6d 61 6e 64 20 44 65 63 6f ["Command Deco
19a0: 64 65 72 20 50 72 6f 6d 70 74 22 2c 20 22 5c 6e der Prompt", "\n
19b0: 5c 5c 2a 24 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 \\*$", False],.
19c0: 20 20 20 5b 22 50 49 50 20 43 6f 6e 74 69 6e 75 ["PIP Continu
19d0: 65 22 2c 20 22 5c 5c 5e 24 22 2c 20 54 72 75 65 e", "\\^$", True
19e0: 5d 2c 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ],
19f0: 20 20 20 20 23 20 4e 65 77 6c 69 6e 65 20 4e 4f # Newline NO
1a00: 54 20 61 6c 77 61 79 73 20 70 72 65 73 65 6e 74 T always present
1a10: 21 20 0a 20 20 20 20 23 20 4f 53 2f 38 20 48 61 ! . # OS/8 Ha
1a20: 6e 64 62 6f 6f 6b 20 31 39 37 34 20 70 61 67 65 ndbook 1974 page
1a30: 20 31 2d 34 33 2f 38 31 20 4b 65 79 62 6f 61 72 1-43/81 Keyboar
1a40: 64 20 4d 6f 6e 69 74 6f 72 20 45 72 72 6f 72 20 d Monitor Error
1a50: 4d 65 73 73 61 67 65 73 3a 0a 20 20 20 20 5b 22 Messages:. ["
1a60: 44 69 72 65 63 74 6f 72 79 20 49 2f 4f 20 45 72 Directory I/O Er
1a70: 72 6f 72 22 2c 20 22 4d 4f 4e 49 54 4f 52 20 45 ror", "MONITOR E
1a80: 52 52 4f 52 20 32 20 41 54 20 5c 64 2b 20 5c 5c RROR 2 AT \d+ \\
1a90: 28 44 49 52 45 43 54 4f 52 59 20 49 2f 4f 20 45 (DIRECTORY I/O E
1aa0: 52 52 4f 52 5c 5c 29 22 2c 20 54 72 75 65 5d 2c RROR\\)", True],
1ab0: 0a 20 20 20 20 5b 22 49 2f 4f 20 45 72 72 6f 72 . ["I/O Error
1ac0: 20 6f 6e 20 53 59 53 22 2c 20 22 4d 4f 4e 49 54 on SYS", "MONIT
1ad0: 4f 52 20 45 52 52 4f 52 20 35 20 41 54 20 5c 64 OR ERROR 5 AT \d
1ae0: 2b 20 5c 5c 28 49 2f 4f 20 45 52 52 4f 52 20 4f + \\(I/O ERROR O
1af0: 4e 20 53 59 53 5c 5c 29 22 2c 20 54 72 75 65 5d N SYS\\)", True]
1b00: 2c 0a 20 20 20 20 5b 22 44 69 72 65 63 74 6f 72 ,. ["Director
1b10: 79 20 49 2f 4f 20 45 72 72 6f 72 22 2c 20 22 4d y I/O Error", "M
1b20: 4f 4e 49 54 4f 52 20 45 52 52 4f 52 20 36 20 41 ONITOR ERROR 6 A
1b30: 54 20 5c 64 2b 20 5c 5c 28 44 49 52 45 43 54 4f T \d+ \\(DIRECTO
1b40: 52 59 20 49 2f 4f 20 45 52 52 4f 52 5c 5c 29 5c RY I/O ERROR\\)\
1b50: 72 22 2c 20 54 72 75 65 5d 2c 0a 20 20 20 20 5b r", True],. [
1b60: 22 44 65 76 69 63 65 20 6e 6f 74 20 61 76 61 69 "Device not avai
1b70: 6c 61 62 6c 65 22 2c 20 22 28 5c 53 2b 29 20 4e lable", "(\S+) N
1b80: 4f 54 20 41 56 41 49 4c 41 42 4c 45 22 2c 20 46 OT AVAILABLE", F
1b90: 61 6c 73 65 5d 2c 0a 20 20 20 20 5b 22 46 69 6c alse],. ["Fil
1ba0: 65 20 6e 6f 74 20 66 6f 75 6e 64 22 2c 20 22 28 e not found", "(
1bb0: 5c 53 2b 29 20 4e 4f 54 20 46 4f 55 4e 44 22 2c \S+) NOT FOUND",
1bc0: 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 23 20 20 False],. #
1bd0: 4f 53 2f 38 20 48 61 6e 64 62 6f 6f 6b 20 31 39 OS/8 Handbook 19
1be0: 37 34 20 70 61 67 65 20 31 2d 35 31 2f 38 39 20 74 page 1-51/89
1bf0: 43 6f 6d 6d 61 6e 64 20 44 65 63 6f 64 65 72 20 Command Decoder
1c00: 45 72 72 6f 72 20 4d 65 73 73 61 67 65 73 0a 20 Error Messages.
1c10: 20 20 20 5b 22 49 6c 6c 65 67 61 6c 20 53 79 6e ["Illegal Syn
1c20: 74 61 78 22 2c 20 22 49 4c 4c 45 47 41 4c 20 53 tax", "ILLEGAL S
1c30: 59 4e 54 41 58 22 2c 20 46 61 6c 73 65 5d 2c 0a YNTAX", False],.
1c40: 20 20 20 20 5b 22 46 69 6c 65 20 64 6f 65 73 20 ["File does
1c50: 6e 6f 74 20 65 78 69 73 74 22 2c 20 22 28 5c 53 not exist", "(\S
1c60: 2b 29 20 44 4f 45 53 20 4e 4f 54 20 45 58 49 53 +) DOES NOT EXIS
1c70: 54 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 T", False],.
1c80: 23 20 20 5b 22 28 5c 53 2b 29 20 4e 4f 54 20 46 # ["(\S+) NOT F
1c90: 4f 55 4e 44 22 2c 20 46 61 6c 73 65 5d 2c 20 20 OUND", False],
1ca0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1cb0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 23 #
1cc0: 20 53 65 65 20 61 62 6f 76 65 0a 20 20 20 20 5b See above. [
1cd0: 22 54 6f 6f 20 6d 61 6e 79 20 66 69 6c 65 73 22 "Too many files"
1ce0: 2c 20 22 54 4f 4f 20 4d 41 4e 59 20 46 49 4c 45 , "TOO MANY FILE
1cf0: 53 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 S", False],.
1d00: 23 20 20 4f 53 2f 38 20 48 61 6e 64 62 6f 6f 6b # OS/8 Handbook
1d10: 20 31 39 37 34 20 70 61 67 65 20 31 2d 37 35 2f 1974 page 1-75/
1d20: 31 31 33 20 43 43 4c 20 45 72 72 6f 72 20 4d 65 113 CCL Error Me
1d30: 73 73 61 67 65 73 0a 20 20 20 20 5b 22 42 61 64 ssages. ["Bad
1d40: 20 44 65 76 69 63 65 22 2c 20 22 42 41 44 20 44 Device", "BAD D
1d50: 45 56 49 43 45 22 2c 20 46 61 6c 73 65 5d 2c 0a EVICE", False],.
1d60: 20 20 20 20 5b 22 42 61 64 20 45 78 74 65 6e 73 ["Bad Extens
1d70: 69 6f 6e 22 2c 20 22 42 41 44 20 45 58 54 45 4e ion", "BAD EXTEN
1d80: 53 49 4f 4e 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 SION", False],.
1d90: 20 20 20 23 22 22 2c 20 20 4f 53 2f 38 20 48 61 #"", OS/8 Ha
1da0: 6e 64 62 6f 6f 6b 20 31 39 37 34 20 70 61 67 65 ndbook 1974 page
1db0: 20 31 2d 31 30 36 2f 31 34 34 20 50 49 50 20 45 1-106/144 PIP E
1dc0: 72 72 6f 72 20 4d 65 73 73 61 67 65 73 0a 20 20 rror Messages.
1dd0: 20 20 5b 22 41 52 45 20 59 4f 55 20 53 55 52 45 ["ARE YOU SURE
1de0: 3f 22 2c 20 22 41 52 45 20 59 4f 55 20 53 55 52 ?", "ARE YOU SUR
1df0: 45 5c 5c 3f 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 E\\?", False],.
1e00: 20 20 20 5b 22 42 41 44 20 44 49 52 45 43 54 4f ["BAD DIRECTO
1e10: 52 59 20 4f 4e 20 44 45 56 49 43 45 22 2c 20 22 RY ON DEVICE", "
1e20: 42 41 44 20 44 49 52 45 43 54 4f 52 59 20 4f 4e BAD DIRECTORY ON
1e30: 20 44 45 56 49 43 45 20 23 5c 73 3f 5c 64 2b 22 DEVICE #\s?\d+"
1e40: 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 5b 22 , False],. ["
1e50: 42 41 44 20 53 59 53 54 45 4d 20 48 45 41 44 22 BAD SYSTEM HEAD"
1e60: 2c 20 22 42 41 44 20 53 59 53 54 45 4d 20 48 45 , "BAD SYSTEM HE
1e70: 41 44 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 20 AD", False],.
1e80: 20 5b 22 43 41 4e 27 54 20 4f 50 45 4e 20 4f 55 ["CAN'T OPEN OU
1e90: 54 50 55 54 20 46 49 4c 45 22 2c 20 22 43 41 4e TPUT FILE", "CAN
1ea0: 27 54 20 4f 50 45 4e 20 4f 55 54 50 55 54 20 46 'T OPEN OUTPUT F
1eb0: 49 4c 45 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 ILE", False],.
1ec0: 20 20 5b 22 44 45 56 49 43 45 20 4e 4f 54 20 41 ["DEVICE NOT A
1ed0: 20 44 49 52 45 43 54 4f 52 59 20 44 45 56 49 43 DIRECTORY DEVIC
1ee0: 45 22 2c 20 22 44 45 56 49 43 45 20 23 5c 64 2b E", "DEVICE #\d+
1ef0: 20 4e 4f 54 20 41 20 44 49 52 45 43 54 4f 52 59 NOT A DIRECTORY
1f00: 20 44 45 56 49 43 45 22 2c 20 46 61 6c 73 65 5d DEVICE", False]
1f10: 2c 0a 20 20 20 20 5b 22 44 49 52 45 43 54 4f 52 ,. ["DIRECTOR
1f20: 59 20 45 52 52 4f 52 22 2c 20 22 44 49 52 45 43 Y ERROR", "DIREC
1f30: 54 4f 52 59 20 45 52 52 4f 52 22 2c 20 46 61 6c TORY ERROR", Fal
1f40: 73 65 5d 2c 0a 20 20 20 20 5b 22 45 52 52 4f 52 se],. ["ERROR
1f50: 20 44 45 4c 45 54 49 4e 47 20 46 49 4c 45 22 2c DELETING FILE",
1f60: 20 22 45 52 52 4f 52 20 44 45 4c 45 54 49 4e 47 "ERROR DELETING
1f70: 20 46 49 4c 45 22 2c 20 46 61 6c 73 65 5d 2c 0a FILE", False],.
1f80: 20 20 20 20 5b 22 49 4c 4c 45 47 49 41 4c 20 42 ["ILLEGIAL B
1f90: 49 4e 41 52 59 20 49 4e 50 55 54 2c 20 46 49 4c INARY INPUT, FIL
1fa0: 45 22 2c 20 22 49 4c 4c 45 47 49 41 4c 20 42 49 E", "ILLEGIAL BI
1fb0: 4e 41 52 59 20 49 4e 50 55 54 2c 20 46 49 4c 45 NARY INPUT, FILE
1fc0: 20 23 5c 64 2b 22 2c 20 46 61 6c 73 65 5d 2c 0a #\d+", False],.
1fd0: 20 20 20 20 5b 22 49 4e 50 55 54 20 45 52 52 4f ["INPUT ERRO
1fe0: 52 22 2c 20 22 49 4e 50 55 54 20 45 52 52 4f 52 R", "INPUT ERROR
1ff0: 2c 20 46 49 4c 45 20 23 5c 73 3f 5c 64 2b 22 2c , FILE #\s?\d+",
2000: 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 5b 22 49 False],. ["I
2010: 4f 20 45 52 52 4f 52 2d 2d 43 4f 4e 54 49 4e 55 O ERROR--CONTINU
2020: 49 4e 47 22 2c 20 22 49 4f 20 45 52 52 4f 52 20 ING", "IO ERROR
2030: 49 4e 20 5c 5c 28 66 69 6c 65 20 6e 61 6d 65 5c IN \\(file name\
2040: 5c 29 20 2d 2d 43 4f 4e 54 49 4e 55 49 4e 47 22 \) --CONTINUING"
2050: 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 5b 22 , False],. ["
2060: 4e 4f 20 52 4f 4f 4d 20 46 4f 52 20 4f 55 54 50 NO ROOM FOR OUTP
2070: 55 54 20 46 49 4c 45 22 2c 20 22 4e 4f 20 52 4f UT FILE", "NO RO
2080: 4f 4d 20 46 4f 52 20 4f 55 54 50 55 54 20 46 49 OM FOR OUTPUT FI
2090: 4c 45 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 20 LE", False],.
20a0: 20 5b 22 4e 4f 20 52 4f 4f 4d 2d 2d 43 4f 4e 54 ["NO ROOM--CONT
20b0: 49 4e 55 49 4e 47 22 2c 20 22 4e 4f 20 52 4f 4f INUING", "NO ROO
20c0: 4d 20 49 4e 20 5c 5c 28 66 69 6c 65 20 6e 61 6d M IN \\(file nam
20d0: 65 5c 5c 29 20 2d 2d 43 4f 4e 54 49 4e 55 49 4e e\\) --CONTINUIN
20e0: 47 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 G", False],.
20f0: 5b 22 4f 55 54 50 55 54 20 45 52 52 4f 52 22 2c ["OUTPUT ERROR",
2100: 20 22 4f 55 54 50 55 54 20 45 52 52 4f 52 22 2c "OUTPUT ERROR",
2110: 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 5b 22 50 False],. ["P
2120: 52 45 4d 41 54 55 52 45 20 45 4e 44 20 4f 46 20 REMATURE END OF
2130: 46 49 4c 45 22 2c 20 22 50 52 45 4d 41 54 55 52 FILE", "PREMATUR
2140: 45 20 45 4e 44 20 4f 46 20 46 49 4c 45 2c 20 46 E END OF FILE, F
2150: 49 4c 45 20 23 5c 73 3f 5c 64 2b 22 2c 20 46 61 ILE #\s?\d+", Fa
2160: 6c 73 65 5d 2c 0a 20 20 20 20 5b 22 5a 45 52 4f lse],. ["ZERO
2170: 20 53 59 53 3f 22 2c 20 22 5a 45 52 4f 20 53 59 SYS?", "ZERO SY
2180: 53 3f 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 20 S?", False],.
2190: 20 23 22 22 2c 20 20 4f 53 2f 38 20 48 61 6e 64 #"", OS/8 Hand
21a0: 62 6f 6f 6b 20 31 39 37 34 20 70 61 67 65 20 32 book 1974 page 2
21b0: 2d 38 31 2f 32 34 34 3a 20 44 49 52 45 43 54 20 -81/244: DIRECT
21c0: 45 72 72 6f 72 20 4d 65 73 73 61 67 65 73 0a 20 Error Messages.
21d0: 20 20 20 5b 22 42 41 44 20 49 4e 50 55 54 20 44 ["BAD INPUT D
21e0: 49 52 45 43 54 4f 52 59 22 2c 20 22 42 41 44 20 IRECTORY", "BAD
21f0: 49 4e 50 55 54 20 44 49 52 45 43 54 4f 52 59 22 INPUT DIRECTORY"
2200: 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 5b 22 , False],. ["
2210: 44 45 56 49 43 45 20 44 4f 45 53 20 4e 4f 54 20 DEVICE DOES NOT
2220: 48 41 56 45 20 41 20 44 49 52 45 43 54 4f 52 59 HAVE A DIRECTORY
2230: 22 2c 20 22 44 45 56 49 43 45 20 44 4f 45 53 20 ", "DEVICE DOES
2240: 4e 4f 54 20 48 41 56 45 20 41 20 44 49 52 45 43 NOT HAVE A DIREC
2250: 54 4f 52 59 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 TORY", False],.
2260: 20 20 20 5b 22 45 52 52 4f 52 20 43 4c 4f 53 49 ["ERROR CLOSI
2270: 4e 47 20 46 49 4c 45 22 2c 20 22 45 52 52 4f 52 NG FILE", "ERROR
2280: 20 43 4c 4f 53 49 4e 47 20 46 49 4c 45 22 2c 20 CLOSING FILE",
2290: 46 61 6c 73 65 5d 2c 0a 20 20 20 20 5b 22 45 52 False],. ["ER
22a0: 52 4f 52 20 43 4c 4f 53 49 4e 47 20 46 49 4c 45 ROR CLOSING FILE
22b0: 22 2c 20 22 45 52 52 4f 52 20 43 4c 4f 53 49 4e ", "ERROR CLOSIN
22c0: 47 20 46 49 4c 45 22 2c 20 46 61 6c 73 65 5d 2c G FILE", False],
22d0: 0a 20 20 20 20 5b 22 45 52 52 4f 52 20 52 45 41 . ["ERROR REA
22e0: 44 49 4e 47 20 49 4e 50 55 54 20 44 49 52 45 43 DING INPUT DIREC
22f0: 54 4f 52 59 22 2c 20 22 45 52 52 4f 52 20 52 45 TORY", "ERROR RE
2300: 41 44 49 4e 47 20 49 4e 50 55 54 20 44 49 52 45 ADING INPUT DIRE
2310: 43 54 4f 52 59 22 2c 20 46 61 6c 73 65 5d 2c 0a CTORY", False],.
2320: 20 20 20 20 5b 22 49 4c 4c 45 47 41 4c 20 2a 22 ["ILLEGAL *"
2330: 2c 20 22 49 4c 4c 45 47 41 4c 20 5c 5c 2a 22 2c , "ILLEGAL \\*",
2340: 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 23 22 22 False],. #""
2350: 2c 20 20 4f 53 2f 38 20 48 61 6e 64 62 6f 6f 6b , OS/8 Handbook
2360: 20 31 39 37 34 20 70 61 67 65 3a 20 32 2d 31 30 1974 page: 2-10
2370: 39 2f 32 37 32 3a 20 46 4f 54 50 20 45 72 72 6f 9/272: FOTP Erro
2380: 72 20 4d 65 73 73 61 67 65 73 0a 20 20 20 20 5b r Messages. [
2390: 22 45 52 52 4f 52 20 4f 4e 20 49 4e 50 55 54 20 "ERROR ON INPUT
23a0: 44 45 56 49 43 45 2c 20 53 4b 49 50 50 49 4e 47 DEVICE, SKIPPING
23b0: 22 2c 20 22 45 52 52 4f 52 20 4f 4e 20 49 4e 50 ", "ERROR ON INP
23c0: 55 54 20 44 45 56 49 43 45 2c 20 53 4b 49 50 50 UT DEVICE, SKIPP
23d0: 49 4e 47 20 5c 5c 28 28 5c 53 2b 29 5c 5c 29 22 ING \\((\S+)\\)"
23e0: 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 5b 22 , False],. ["
23f0: 45 52 52 4f 52 20 4f 4e 20 4f 55 54 50 55 54 20 ERROR ON OUTPUT
2400: 44 45 56 49 43 45 2c 20 53 4b 49 50 50 49 4e 47 DEVICE, SKIPPING
2410: 22 2c 20 22 45 52 52 4f 52 20 4f 4e 20 4f 55 54 ", "ERROR ON OUT
2420: 50 55 54 20 44 45 56 49 43 45 2c 20 53 4b 49 50 PUT DEVICE, SKIP
2430: 50 49 4e 47 20 5c 5c 28 28 5c 53 2b 29 5c 5c 29 PING \\((\S+)\\)
2440: 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 5b ", False],. [
2450: 22 45 52 52 4f 52 20 52 45 41 44 49 4e 47 20 49 "ERROR READING I
2460: 4e 50 55 54 20 44 49 52 45 43 54 4f 52 59 22 2c NPUT DIRECTORY",
2470: 20 22 45 52 52 4f 52 20 52 45 41 44 49 4e 47 20 "ERROR READING
2480: 49 4e 50 55 54 20 44 49 52 45 43 54 4f 52 59 22 INPUT DIRECTORY"
2490: 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 5b 22 , False],. ["
24a0: 45 52 52 4f 52 20 52 45 41 44 49 4e 47 20 4f 55 ERROR READING OU
24b0: 54 50 55 54 20 44 49 52 45 43 54 4f 52 59 22 2c TPUT DIRECTORY",
24c0: 20 22 45 52 52 4f 52 20 52 45 41 44 49 4e 47 20 "ERROR READING
24d0: 4f 55 54 50 55 54 20 44 49 52 45 43 54 4f 52 59 OUTPUT DIRECTORY
24e0: 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 5b ", False],. [
24f0: 22 49 4c 4c 45 47 41 4c 20 3f 22 2c 20 22 49 4c "ILLEGAL ?", "IL
2500: 4c 45 47 41 4c 20 5c 5c 3f 22 2c 20 46 61 6c 73 LEGAL \\?", Fals
2510: 65 5d 2c 0a 20 20 20 20 5b 22 4e 4f 20 46 49 4c e],. ["NO FIL
2520: 45 53 20 4f 46 20 54 48 45 20 46 4f 52 4d 22 2c ES OF THE FORM",
2530: 20 22 4e 4f 20 46 49 4c 45 53 20 4f 46 20 54 48 "NO FILES OF TH
2540: 45 20 46 4f 52 4d 3a 20 28 5c 53 2b 29 22 2c 20 E FORM: (\S+)",
2550: 46 61 6c 73 65 5d 2c 0a 20 20 20 20 5b 22 4e 4f False],. ["NO
2560: 20 52 4f 4f 4d 2c 20 53 4b 49 50 50 49 4e 47 22 ROOM, SKIPPING"
2570: 2c 20 22 4e 4f 20 52 4f 4f 4d 2c 20 53 4b 49 50 , "NO ROOM, SKIP
2580: 50 49 4e 47 20 5c 5c 28 28 5c 53 2b 29 5c 5c 29 PING \\((\S+)\\)
2590: 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 5b ", False],. [
25a0: 22 53 59 53 54 45 4d 20 45 52 52 4f 52 2d 43 4c "SYSTEM ERROR-CL
25b0: 4f 53 49 4e 47 20 46 49 4c 45 22 2c 20 22 53 59 OSING FILE", "SY
25c0: 53 54 45 4d 20 45 52 52 4f 52 2d 43 4c 4f 53 49 STEM ERROR-CLOSI
25d0: 4e 47 20 46 49 4c 45 22 2c 20 46 61 6c 73 65 5d NG FILE", False]
25e0: 2c 0a 20 20 20 20 5b 22 55 53 45 20 50 49 50 20 ,. ["USE PIP
25f0: 46 4f 52 20 4e 4f 4e 2d 46 49 4c 45 20 53 54 52 FOR NON-FILE STR
2600: 55 43 54 55 52 45 44 20 44 45 56 49 43 45 22 2c UCTURED DEVICE",
2610: 20 22 55 53 45 20 50 49 50 20 46 4f 52 20 4e 4f "USE PIP FOR NO
2620: 4e 2d 46 49 4c 45 20 53 54 52 55 43 54 55 52 45 N-FILE STRUCTURE
2630: 44 20 44 45 56 49 43 45 22 2c 20 46 61 6c 73 65 D DEVICE", False
2640: 5d 2c 0a 20 20 20 20 5b 22 4c 49 4e 45 20 54 4f ],. ["LINE TO
2650: 4f 20 4c 4f 4e 47 20 49 4e 20 46 49 4c 45 22 2c O LONG IN FILE",
2660: 20 22 4c 49 4e 45 20 54 4f 4f 20 4c 4f 4e 47 20 "LINE TOO LONG
2670: 49 4e 20 46 49 4c 45 23 5c 64 2b 22 2c 20 46 61 IN FILE#\d+", Fa
2680: 6c 73 65 5d 2c 0a 20 20 20 20 5d 0a 20 20 0a 0a lse],. ]. ..
2690: 20 20 23 20 50 61 74 74 65 72 6e 20 74 6f 20 6d # Pattern to m
26a0: 61 74 63 68 20 61 20 53 49 4d 48 20 63 6f 6d 6d atch a SIMH comm
26b0: 61 6e 64 2e 20 20 54 68 65 20 63 6f 6d 6d 61 6e and. The comman
26c0: 64 20 76 65 72 62 20 65 6e 64 73 20 75 70 20 69 d verb ends up i
26d0: 6e 0a 20 20 23 20 6d 61 74 63 68 28 29 2e 67 72 n. # match().gr
26e0: 6f 75 70 28 31 29 2c 20 61 6e 64 20 61 6e 79 74 oup(1), and anyt
26f0: 68 69 6e 67 20 61 66 74 65 72 20 74 68 65 20 76 hing after the v
2700: 65 72 62 20 69 6e 20 67 72 6f 75 70 28 33 29 2e erb in group(3).
2710: 0a 20 20 5f 73 69 6d 68 5f 63 6f 6d 6d 5f 72 65 . _simh_comm_re
2720: 20 3d 20 72 65 2e 63 6f 6d 70 69 6c 65 20 28 22 = re.compile ("
2730: 5e 5c 73 2a 28 5c 53 2b 29 28 5c 73 2b 28 2e 2a ^\s*(\S+)(\s+(.*
2740: 29 29 3f 24 22 29 0a 0a 20 20 23 20 53 69 67 6e ))?$").. # Sign
2750: 69 66 69 63 61 6e 74 20 70 72 65 66 69 78 65 73 ificant prefixes
2760: 20 6f 66 20 53 49 4d 48 20 63 6f 6d 6d 61 6e 64 of SIMH command
2770: 20 76 65 72 62 73 20 74 68 61 74 20 74 72 61 6e verbs that tran
2780: 73 69 74 69 6f 6e 20 66 72 6f 6d 20 53 49 4d 48 sition from SIMH
2790: 0a 20 20 23 20 63 6f 6d 6d 61 6e 64 20 63 6f 6e . # command con
27a0: 74 65 78 74 20 62 61 63 6b 20 69 6e 74 6f 20 74 text back into t
27b0: 68 65 20 73 69 6d 75 6c 61 74 69 6f 6e 3a 20 42 he simulation: B
27c0: 4f 4f 54 2c 20 43 4f 4e 54 49 4e 55 45 2c 20 61 OOT, CONTINUE, a
27d0: 6e 64 20 47 4f 2e 0a 20 20 23 20 57 65 20 6e 65 nd GO.. # We ne
27e0: 65 64 20 6f 6e 6c 79 20 74 68 65 20 66 69 72 73 ed only the firs
27f0: 74 20 6c 65 74 74 65 72 20 69 6e 20 61 6c 6c 20 t letter in all
2800: 63 61 73 65 73 2c 20 73 69 6e 63 65 20 74 68 65 cases, since the
2810: 73 65 20 70 61 72 74 69 63 75 6c 61 72 0a 20 20 se particular.
2820: 23 20 63 6f 6d 6d 61 6e 64 73 20 61 72 65 20 6e # commands are n
2830: 6f 74 20 61 6d 62 69 67 75 6f 75 73 2e 20 20 54 ot ambiguous. T
2840: 68 65 79 27 72 65 20 75 70 70 65 72 63 61 73 65 hey're uppercase
2850: 20 62 65 63 61 75 73 65 20 74 68 65 20 63 6f 64 because the cod
2860: 65 20 74 68 61 74 0a 20 20 23 20 75 73 65 73 20 e that. # uses
2870: 74 68 69 73 20 61 6c 77 61 79 73 20 75 70 70 65 this always uppe
2880: 72 63 61 73 65 73 20 74 68 65 20 63 6f 6d 6d 61 rcases the comma
2890: 6e 64 20 62 65 66 6f 72 65 20 73 65 61 72 63 68 nd before search
28a0: 69 6e 67 20 74 68 69 73 20 6c 69 73 74 2e 0a 20 ing this list..
28b0: 20 5f 65 6e 74 65 72 73 5f 6f 73 38 5f 63 6f 6e _enters_os8_con
28c0: 74 65 78 74 20 3d 20 5b 22 42 22 2c 20 22 43 22 text = ["B", "C"
28d0: 2c 20 22 47 22 5d 0a 0a 0a 20 20 23 23 23 23 20 , "G"]... ####
28e0: 63 74 6f 72 20 23 23 23 23 23 23 23 23 23 23 23 ctor ###########
28f0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
2900: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
2910: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
2920: 23 0a 20 20 23 20 62 61 73 65 64 69 72 20 69 73 #. # basedir is
2930: 20 74 68 65 20 70 61 72 65 6e 74 20 6f 66 20 62 the parent of b
2940: 69 6e 2f 7b 70 64 70 38 2c 70 69 64 70 38 69 2d in/{pdp8,pidp8i-
2950: 73 69 6d 7d 2e 0a 20 20 23 0a 20 20 23 20 53 65 sim}.. #. # Se
2960: 74 74 69 6e 67 20 74 68 65 20 73 6b 69 70 5f 67 tting the skip_g
2970: 70 69 6f 20 66 6c 61 67 20 74 6f 20 54 72 75 65 pio flag to True
2980: 20 63 61 75 73 65 73 20 75 73 20 74 6f 20 75 73 causes us to us
2990: 65 20 62 69 6e 2f 70 64 70 38 20 69 6e 73 74 65 e bin/pdp8 inste
29a0: 61 64 0a 20 20 23 20 6f 66 20 62 69 6e 2f 70 69 ad. # of bin/pi
29b0: 64 70 38 69 2d 73 69 6d 2c 20 77 68 69 63 68 20 dp8i-sim, which
29c0: 72 75 6e 73 20 74 68 65 20 73 69 6d 75 6c 61 74 runs the simulat
29d0: 6f 72 20 77 69 74 68 20 74 68 65 20 50 69 44 50 or with the PiDP
29e0: 2d 38 2f 49 20 47 50 49 4f 20 0a 20 20 23 20 74 -8/I GPIO . # t
29f0: 68 72 65 61 64 20 64 69 73 61 62 6c 65 64 2e 20 hread disabled.
2a00: 20 59 6f 75 20 6d 69 67 68 74 20 64 6f 20 74 68 You might do th
2a10: 69 73 20 62 65 63 61 75 73 65 20 79 6f 75 20 64 is because you d
2a20: 6f 6e 27 74 20 6e 65 65 64 20 61 6e 79 20 66 72 on't need any fr
2a30: 6f 6e 74 0a 20 20 23 20 70 61 6e 65 6c 20 69 6e ont. # panel in
2a40: 74 65 72 61 63 74 69 6f 6e 20 6f 72 20 62 65 63 teraction or bec
2a50: 61 75 73 65 20 79 6f 75 20 6b 6e 6f 77 20 79 6f ause you know yo
2a60: 75 27 72 65 20 6e 6f 74 20 72 75 6e 6e 69 6e 67 u're not running
2a70: 20 6f 6e 20 61 6e 20 52 50 69 0a 20 20 23 20 69 on an RPi. # i
2a80: 6e 20 74 68 65 20 66 69 72 73 74 20 70 6c 61 63 n the first plac
2a90: 65 2e 0a 20 20 0a 20 20 64 65 66 20 5f 5f 69 6e e.. . def __in
2aa0: 69 74 5f 5f 20 28 73 65 6c 66 2c 20 62 61 73 65 it__ (self, base
2ab0: 64 69 72 2c 20 73 6b 69 70 5f 67 70 69 6f 20 3d dir, skip_gpio =
2ac0: 20 46 61 6c 73 65 29 3a 0a 20 20 20 20 23 20 53 False):. # S
2ad0: 74 61 72 74 20 74 68 65 20 73 69 6d 75 6c 61 74 tart the simulat
2ae0: 6f 72 20 69 6e 73 74 61 6e 63 65 0a 20 20 20 20 or instance.
2af0: 73 69 6d 20 3d 20 27 70 64 70 38 27 20 69 66 20 sim = 'pdp8' if
2b00: 73 6b 69 70 5f 67 70 69 6f 20 65 6c 73 65 20 27 skip_gpio else '
2b10: 70 69 64 70 38 69 2d 73 69 6d 27 3b 0a 20 20 20 pidp8i-sim';.
2b20: 20 73 65 6c 66 2e 5f 63 68 69 6c 64 20 3d 20 70 self._child = p
2b30: 65 78 70 65 63 74 2e 73 70 61 77 6e 20 28 6f 73 expect.spawn (os
2b40: 2e 70 61 74 68 2e 6a 6f 69 6e 20 28 62 61 73 65 .path.join (base
2b50: 64 69 72 2c 20 27 62 69 6e 27 2c 20 73 69 6d 29 dir, 'bin', sim)
2b60: 29 0a 20 20 20 20 73 65 6c 66 2e 5f 76 61 6c 69 ). self._vali
2b70: 64 5f 70 69 70 5f 6f 70 74 69 6f 6e 73 20 3d 20 d_pip_options =
2b80: 5b 22 2f 41 22 2c 20 22 2f 42 22 2c 20 22 2f 49 ["/A", "/B", "/I
2b90: 22 5d 0a 20 20 20 20 73 65 6c 66 2e 5f 6f 73 38 "]. self._os8
2ba0: 5f 66 69 6c 65 5f 72 65 20 3d 20 72 65 2e 63 6f _file_re = re.co
2bb0: 6d 70 69 6c 65 28 22 28 5c 53 2b 29 3a 28 5c 53 mpile("(\S+):(\S
2bc0: 2b 29 3f 22 29 0a 20 20 20 20 73 65 6c 66 2e 5f +)?"). self._
2bd0: 6f 73 38 5f 65 72 72 6f 72 5f 6d 61 74 63 68 5f os8_error_match_
2be0: 73 74 72 69 6e 67 73 20 3d 20 5b 5d 0a 20 20 20 strings = [].
2bf0: 20 73 65 6c 66 2e 5f 6f 73 38 5f 66 61 74 61 6c self._os8_fatal
2c00: 5f 63 68 65 63 6b 20 3d 20 5b 5d 0a 20 20 20 20 _check = [].
2c10: 73 65 6c 66 2e 76 65 72 62 6f 73 65 20 3d 20 46 self.verbose = F
2c20: 61 6c 73 65 0a 0a 20 20 20 20 23 20 57 65 20 6b alse.. # We k
2c30: 65 65 70 20 74 72 61 63 6b 20 6f 66 20 74 68 65 eep track of the
2c40: 20 63 6f 6d 6d 61 6e 64 20 63 6f 6e 74 65 78 74 command context
2c50: 20 61 6e 64 20 74 72 61 6e 73 69 74 69 6f 6e 20 and transition
2c60: 61 75 74 6f 6d 61 74 69 63 61 6c 6c 79 2e 0a 20 automatically..
2c70: 20 20 20 73 65 6c 66 2e 5f 63 6f 6e 74 65 78 74 self._context
2c80: 20 3d 20 22 73 69 6d 68 22 0a 20 20 20 20 0a 20 = "simh". .
2c90: 20 20 20 23 20 50 72 65 2d 63 6f 6d 70 69 6c 65 # Pre-compile
2ca0: 20 6f 75 72 20 6f 73 38 5f 72 65 70 6c 69 65 73 our os8_replies
2cb0: 20 72 65 67 65 78 70 73 2e 0a 20 20 20 20 73 65 regexps.. se
2cc0: 6c 66 2e 5f 6f 73 38 5f 72 65 70 6c 69 65 73 5f lf._os8_replies_
2cd0: 72 65 78 20 3d 20 5b 5d 0a 20 20 20 20 66 6f 72 rex = []. for
2ce0: 20 69 74 65 6d 20 69 6e 20 73 65 6c 66 2e 5f 6f item in self._o
2cf0: 73 38 5f 72 65 70 6c 69 65 73 3a 0a 20 20 20 20 s8_replies:.
2d00: 20 20 73 65 6c 66 2e 5f 6f 73 38 5f 72 65 70 6c self._os8_repl
2d10: 69 65 73 5f 72 65 78 2e 61 70 70 65 6e 64 28 72 ies_rex.append(r
2d20: 65 2e 63 6f 6d 70 69 6c 65 28 69 74 65 6d 5b 31 e.compile(item[1
2d30: 5d 2e 65 6e 63 6f 64 65 28 29 29 29 0a 0a 20 20 ].encode()))..
2d40: 20 20 23 20 50 72 65 2d 63 6f 6d 70 69 6c 65 20 # Pre-compile
2d50: 6f 75 72 20 73 69 6d 68 5f 72 65 70 6c 69 65 73 our simh_replies
2d60: 20 72 65 67 65 78 70 73 2e 0a 20 20 20 20 73 65 regexps.. se
2d70: 6c 66 2e 5f 73 69 6d 68 5f 72 65 70 6c 69 65 73 lf._simh_replies
2d80: 5f 72 65 78 20 3d 20 5b 5d 0a 20 20 20 20 66 6f _rex = []. fo
2d90: 72 20 69 74 65 6d 20 69 6e 20 73 65 6c 66 2e 5f r item in self._
2da0: 73 69 6d 68 5f 72 65 70 6c 69 65 73 3a 0a 20 20 simh_replies:.
2db0: 20 20 20 20 73 65 6c 66 2e 5f 73 69 6d 68 5f 72 self._simh_r
2dc0: 65 70 6c 69 65 73 5f 72 65 78 2e 61 70 70 65 6e eplies_rex.appen
2dd0: 64 28 72 65 2e 63 6f 6d 70 69 6c 65 28 69 74 65 d(re.compile(ite
2de0: 6d 5b 31 5d 2e 65 6e 63 6f 64 65 28 29 29 29 0a m[1].encode())).
2df0: 20 20 20 20 20 20 20 20 0a 20 20 20 20 23 20 54 . # T
2e00: 75 72 6e 20 6f 66 66 20 70 65 78 70 65 63 74 27 urn off pexpect'
2e10: 73 20 64 65 66 61 75 6c 74 20 69 6e 74 65 72 2d s default inter-
2e20: 73 65 6e 64 28 29 20 64 65 6c 61 79 2e 20 20 57 send() delay. W
2e30: 65 20 61 64 64 20 6f 75 72 20 6f 77 6e 20 61 73 e add our own as
2e40: 0a 20 20 20 20 23 20 6e 65 63 65 73 73 61 72 79 . # necessary
2e50: 2e 20 20 54 68 65 20 63 6f 6e 64 69 74 69 6f 6e . The condition
2e60: 61 6c 20 74 72 61 63 6b 73 20 61 6e 20 41 50 49 al tracks an API
2e70: 20 63 68 61 6e 67 65 20 62 65 74 77 65 65 6e 20 change between
2e80: 33 20 61 6e 64 20 34 2e 0a 20 20 20 20 70 65 76 3 and 4.. pev
2e90: 34 20 3d 20 28 70 6b 67 5f 72 65 73 6f 75 72 63 4 = (pkg_resourc
2ea0: 65 73 2e 67 65 74 5f 64 69 73 74 72 69 62 75 74 es.get_distribut
2eb0: 69 6f 6e 28 22 70 65 78 70 65 63 74 22 29 2e 70 ion("pexpect").p
2ec0: 61 72 73 65 64 5f 76 65 72 73 69 6f 6e 20 3e 0a arsed_version >.
2ed0: 20 20 20 20 20 20 20 20 20 20 20 20 70 6b 67 5f pkg_
2ee0: 72 65 73 6f 75 72 63 65 73 2e 70 61 72 73 65 5f resources.parse_
2ef0: 76 65 72 73 69 6f 6e 28 22 34 2e 30 22 29 29 0a version("4.0")).
2f00: 20 20 20 20 73 65 6c 66 2e 5f 63 68 69 6c 64 2e self._child.
2f10: 64 65 6c 61 79 62 65 66 6f 72 65 73 65 6e 64 20 delaybeforesend
2f20: 3d 20 4e 6f 6e 65 20 69 66 20 70 65 76 34 20 65 = None if pev4 e
2f30: 6c 73 65 20 30 0a 0a 20 20 20 20 23 20 57 61 69 lse 0.. # Wai
2f40: 74 20 66 6f 72 20 74 68 65 20 73 69 6d 75 6c 61 t for the simula
2f50: 74 6f 72 27 73 20 73 74 61 72 74 75 70 20 6d 65 tor's startup me
2f60: 73 73 61 67 65 2e 0a 20 20 20 20 69 66 20 6e 6f ssage.. if no
2f70: 74 20 73 65 6c 66 2e 74 72 79 5f 77 61 69 74 20 t self.try_wait
2f80: 28 27 50 44 50 2d 38 20 73 69 6d 75 6c 61 74 6f ('PDP-8 simulato
2f90: 72 20 4f 70 65 6e 20 53 49 4d 48 20 56 2e 2a 67 r Open SIMH V.*g
2fa0: 69 74 20 63 6f 6d 6d 69 74 20 69 64 3a 20 5b 30 it commit id: [0
2fb0: 2d 39 61 2d 66 5d 27 2c 20 31 30 29 3a 0a 20 20 -9a-f]', 10):.
2fc0: 20 20 20 20 72 61 69 73 65 20 52 75 6e 74 69 6d raise Runtim
2fd0: 65 45 72 72 6f 72 20 28 27 53 69 6d 75 6c 61 74 eError ('Simulat
2fe0: 6f 72 20 66 61 69 6c 65 64 20 74 6f 20 73 74 61 or failed to sta
2ff0: 72 74 27 29 0a 0a 0a 20 20 23 23 23 23 23 23 23 rt')... #######
3000: 23 23 23 23 23 23 23 23 23 23 23 23 23 20 73 69 ############# si
3010: 6d 68 20 70 65 78 70 65 63 74 20 41 62 73 74 72 mh pexpect Abstr
3020: 61 63 74 69 6f 6e 20 6c 61 79 65 72 20 23 23 23 action layer ###
3030: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0a ###############.
3040: 20 20 23 20 49 64 65 61 6c 6c 79 20 74 68 65 73 # Ideally thes
3050: 65 20 73 68 6f 75 6c 64 20 62 65 20 74 68 65 20 e should be the
3060: 70 75 62 6c 69 63 20 69 6e 74 65 72 66 61 63 65 public interface
3070: 20 74 6f 20 70 65 78 70 65 63 74 0a 20 20 23 20 to pexpect. #
3080: 75 73 65 64 20 77 69 74 68 20 74 68 65 20 73 69 used with the si
3090: 6d 68 20 6f 62 6a 65 63 74 0a 20 20 0a 20 20 23 mh object. . #
30a0: 23 23 23 20 73 65 74 5f 6c 6f 67 66 69 6c 65 20 ### set_logfile
30b0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
30c0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
30d0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
30e0: 23 23 23 23 23 0a 0a 20 20 64 65 66 20 73 65 74 #####.. def set
30f0: 5f 6c 6f 67 66 69 6c 65 20 28 73 65 6c 66 2c 20 _logfile (self,
3100: 6c 66 29 3a 0a 20 20 20 20 73 65 6c 66 2e 5f 63 lf):. self._c
3110: 68 69 6c 64 2e 6c 6f 67 66 69 6c 65 20 3d 20 6c hild.logfile = l
3120: 66 0a 0a 0a 20 20 23 23 23 23 20 73 65 6e 64 5f f... #### send_
3130: 6c 69 6e 65 20 23 23 23 23 23 23 23 23 23 23 23 line ###########
3140: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3150: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3160: 23 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 23 ############. #
3170: 20 53 65 6e 64 73 20 74 68 65 20 67 69 76 65 6e Sends the given
3180: 20 6c 69 6e 65 20 22 62 6c 69 6e 64 22 2c 20 77 line "blind", w
3190: 69 74 68 6f 75 74 20 62 65 66 6f 72 65 20 6f 72 ithout before or
31a0: 20 61 66 74 65 72 20 63 68 65 63 6b 73 0a 0a 20 after checks..
31b0: 20 64 65 66 20 73 65 6e 64 5f 6c 69 6e 65 20 28 def send_line (
31c0: 73 65 6c 66 2c 20 6c 69 6e 65 29 3a 0a 20 20 20 self, line):.
31d0: 20 73 65 6c 66 2e 5f 63 68 69 6c 64 2e 73 65 6e self._child.sen
31e0: 64 6c 69 6e 65 20 28 6c 69 6e 65 29 0a 0a 0a 20 dline (line)...
31f0: 20 23 23 23 23 20 72 65 61 64 5f 74 61 69 6c 20 #### read_tail
3200: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3210: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3220: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3230: 23 23 23 23 23 23 23 0a 20 20 23 20 57 61 74 63 #######. # Watc
3240: 68 20 66 6f 72 20 61 20 6c 69 74 65 72 61 6c 20 h for a literal
3250: 73 74 72 69 6e 67 2c 20 74 68 65 6e 20 67 65 74 string, then get
3260: 20 77 68 61 74 20 66 6f 6c 6c 6f 77 73 20 6f 6e what follows on
3270: 20 74 68 61 74 20 6c 69 6e 65 2e 0a 0a 20 20 64 that line... d
3280: 65 66 20 72 65 61 64 5f 74 61 69 6c 20 28 73 65 ef read_tail (se
3290: 6c 66 2c 20 68 65 61 64 2c 20 74 69 6d 65 6f 75 lf, head, timeou
32a0: 74 20 3d 20 2d 31 29 3a 0a 20 20 20 20 73 65 6c t = -1):. sel
32b0: 66 2e 5f 63 68 69 6c 64 2e 65 78 70 65 63 74 5f f._child.expect_
32c0: 65 78 61 63 74 20 28 5b 68 65 61 64 5d 2c 20 74 exact ([head], t
32d0: 69 6d 65 6f 75 74 29 0a 20 20 20 20 72 65 74 75 imeout). retu
32e0: 72 6e 20 73 65 6c 66 2e 5f 63 68 69 6c 64 2e 72 rn self._child.r
32f0: 65 61 64 6c 69 6e 65 20 28 29 0a 0a 0a 20 20 23 eadline ()... #
3300: 23 23 23 20 73 70 69 6e 20 23 23 23 23 23 23 23 ### spin #######
3310: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3320: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3330: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3340: 23 23 23 23 23 0a 20 20 23 20 4c 65 74 20 63 68 #####. # Let ch
3350: 69 6c 64 20 72 75 6e 20 77 69 74 68 6f 75 74 20 ild run without
3360: 61 73 6b 69 6e 67 20 61 6e 79 74 68 69 6e 67 20 asking anything
3370: 6d 6f 72 65 20 66 72 6f 6d 20 69 74 2c 20 77 69 more from it, wi
3380: 74 68 20 61 6e 20 6f 70 74 69 6f 6e 61 6c 0a 20 th an optional.
3390: 20 23 20 74 69 6d 65 6f 75 74 20 76 61 6c 75 65 # timeout value
33a0: 2e 20 20 49 66 20 6e 6f 20 76 61 6c 75 65 20 69 . If no value i
33b0: 73 20 67 69 76 65 6e 2c 20 6c 65 74 73 20 63 68 s given, lets ch
33c0: 69 6c 64 20 72 75 6e 20 69 6e 64 65 66 69 6e 69 ild run indefini
33d0: 74 65 6c 79 2e 0a 0a 20 20 64 65 66 20 73 70 69 tely... def spi
33e0: 6e 20 28 73 65 6c 66 2c 20 74 69 6d 65 6f 75 74 n (self, timeout
33f0: 20 3d 20 4e 6f 6e 65 29 3a 0a 20 20 20 20 73 65 = None):. se
3400: 6c 66 2e 5f 63 68 69 6c 64 2e 65 78 70 65 63 74 lf._child.expect
3410: 20 28 70 65 78 70 65 63 74 2e 45 4f 46 2c 20 74 (pexpect.EOF, t
3420: 69 6d 65 6f 75 74 20 3d 20 74 69 6d 65 6f 75 74 imeout = timeout
3430: 29 0a 0a 0a 20 20 23 23 23 23 20 63 68 69 6c 64 )... #### child
3440: 5f 65 78 70 65 63 74 20 23 23 23 23 23 23 23 23 _expect ########
3450: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3460: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3470: 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 23 20 ###########. #
3480: 48 69 67 68 65 72 20 6c 65 76 65 6c 20 61 63 63 Higher level acc
3490: 65 73 73 6f 72 20 74 6f 20 5f 63 68 69 6c 64 2e essor to _child.
34a0: 65 78 70 65 63 74 20 74 68 61 74 20 63 61 74 63 expect that catc
34b0: 68 65 73 20 74 68 65 20 74 69 6d 65 6f 75 74 2e hes the timeout.
34c0: 0a 0a 20 20 64 65 66 20 63 68 69 6c 64 5f 65 78 .. def child_ex
34d0: 70 65 63 74 28 73 65 6c 66 2c 20 72 65 70 6c 69 pect(self, repli
34e0: 65 73 2c 20 74 69 6d 65 6f 75 74 3d 31 30 29 3a es, timeout=10):
34f0: 0a 20 20 20 20 74 72 79 3a 0a 20 20 20 20 20 20 . try:.
3500: 72 65 70 6c 79 20 3d 20 73 65 6c 66 2e 5f 63 68 reply = self._ch
3510: 69 6c 64 2e 65 78 70 65 63 74 28 72 65 70 6c 69 ild.expect(repli
3520: 65 73 2c 20 74 69 6d 65 6f 75 74 3d 74 69 6d 65 es, timeout=time
3530: 6f 75 74 29 0a 20 20 20 20 65 78 63 65 70 74 20 out). except
3540: 70 65 78 70 65 63 74 2e 65 78 63 65 70 74 69 6f pexpect.exceptio
3550: 6e 73 2e 54 49 4d 45 4f 55 54 3a 0a 20 20 20 20 ns.TIMEOUT:.
3560: 20 20 70 72 69 6e 74 20 28 22 70 65 78 70 65 63 print ("pexpec
3570: 74 20 74 69 6d 65 6f 75 74 22 29 0a 20 20 20 20 t timeout").
3580: 20 20 70 72 69 6e 74 28 22 5c 74 6d 61 74 63 68 print("\tmatch
3590: 20 62 65 66 6f 72 65 3a 20 7b 22 20 2b 20 73 65 before: {" + se
35a0: 6c 66 2e 5f 63 68 69 6c 64 2e 62 65 66 6f 72 65 lf._child.before
35b0: 2e 64 65 63 6f 64 65 28 29 20 2b 20 22 7d 22 29 .decode() + "}")
35c0: 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 2d 31 . return -1
35d0: 20 20 20 20 20 20 0a 20 20 20 20 72 65 74 75 72 . retur
35e0: 6e 20 72 65 70 6c 79 0a 0a 20 20 23 23 23 23 20 n reply.. ####
35f0: 63 68 69 6c 64 5f 61 66 74 65 72 20 23 23 23 23 child_after ####
3600: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3610: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3620: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3630: 23 0a 20 20 23 20 41 62 73 74 72 61 63 74 20 61 #. # Abstract a
3640: 63 63 65 73 73 6f 72 20 66 6f 72 20 74 68 65 20 ccessor for the
3650: 70 65 78 70 65 63 74 20 6f 62 6a 65 63 74 27 73 pexpect object's
3660: 20 61 66 74 65 72 20 63 6f 6e 74 65 6e 74 73 2e after contents.
3670: 0a 20 20 23 20 43 6f 70 65 73 20 77 69 74 68 20 . # Copes with
3680: 74 68 65 20 70 6f 73 73 69 62 69 6c 69 74 79 20 the possibility
3690: 74 68 61 74 20 77 65 20 74 69 6d 65 64 20 6f 75 that we timed ou
36a0: 74 20 6f 72 20 68 69 74 20 65 6e 64 20 6f 66 20 t or hit end of
36b0: 66 69 6c 65 2e 0a 0a 20 20 64 65 66 20 63 68 69 file... def chi
36c0: 6c 64 5f 61 66 74 65 72 20 28 73 65 6c 66 29 3a ld_after (self):
36d0: 0a 20 20 20 20 6f 62 6a 20 3d 20 73 65 6c 66 2e . obj = self.
36e0: 5f 63 68 69 6c 64 2e 61 66 74 65 72 0a 20 20 20 _child.after.
36f0: 20 69 66 20 6f 62 6a 20 3d 3d 20 70 65 78 70 65 if obj == pexpe
3700: 63 74 2e 54 49 4d 45 4f 55 54 3a 20 72 65 74 75 ct.TIMEOUT: retu
3710: 72 6e 20 22 54 49 4d 45 4f 55 54 22 0a 20 20 20 rn "TIMEOUT".
3720: 20 65 6c 69 66 20 6f 62 6a 20 3d 3d 20 70 65 78 elif obj == pex
3730: 70 65 63 74 2e 45 4f 46 3a 20 72 65 74 75 72 6e pect.EOF: return
3740: 20 22 45 6e 64 20 4f 66 20 46 69 6c 65 22 0a 20 "End Of File".
3750: 20 20 20 72 65 74 75 72 6e 20 73 65 6c 66 2e 5f return self._
3760: 63 68 69 6c 64 2e 61 66 74 65 72 2e 64 65 63 6f child.after.deco
3770: 64 65 28 29 0a 20 20 20 20 20 20 0a 0a 20 20 23 de(). .. #
3780: 23 23 23 20 74 72 79 5f 77 61 69 74 20 23 23 23 ### try_wait ###
3790: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
37a0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
37b0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
37c0: 23 23 23 23 23 0a 20 20 23 20 41 20 77 72 61 70 #####. # A wrap
37d0: 70 65 72 20 61 72 6f 75 6e 64 20 73 65 6c 66 2e per around self.
37e0: 5f 63 68 69 6c 64 2e 65 78 70 65 63 74 20 77 68 _child.expect wh
37f0: 69 63 68 20 63 61 74 63 68 65 73 20 65 78 63 65 ich catches exce
3800: 70 74 69 6f 6e 73 20 61 6e 64 0a 20 20 23 20 72 ptions and. # r
3810: 65 74 75 72 6e 73 20 66 61 6c 73 65 20 6f 6e 20 eturns false on
3820: 70 65 78 70 65 63 74 20 74 69 6d 65 6f 75 74 2e pexpect timeout.
3830: 20 20 49 66 20 79 6f 75 20 70 61 73 73 20 61 20 If you pass a
3840: 6c 69 73 74 20 69 6e 73 74 65 61 64 20 6f 66 20 list instead of
3850: 61 0a 20 20 23 20 73 74 72 69 6e 67 2c 20 69 74 a. # string, it
3860: 20 61 6c 73 6f 20 72 65 74 75 72 6e 73 20 74 72 also returns tr
3870: 75 65 20 69 66 20 74 68 65 20 6d 61 74 63 68 20 ue if the match
3880: 77 61 73 6e 27 74 20 66 6f 72 20 74 68 65 20 66 wasn't for the f
3890: 69 72 73 74 0a 20 20 23 20 65 6c 65 6d 65 6e 74 irst. # element
38a0: 2c 20 73 6f 20 79 6f 75 20 63 61 6e 20 70 61 73 , so you can pas
38b0: 73 20 5b 73 75 63 63 65 73 73 2c 20 66 61 69 6c s [success, fail
38c0: 75 72 65 31 2c 20 66 61 69 6c 75 72 65 32 2c 20 ure1, failure2,
38d0: 65 74 63 2e 5d 20 74 6f 0a 20 20 23 20 63 68 65 etc.] to. # che
38e0: 63 6b 20 66 6f 72 20 61 20 6b 6e 6f 77 6e 2d 73 ck for a known-s
38f0: 75 63 63 65 73 73 20 63 61 73 65 20 61 6e 64 20 uccess case and
3900: 6f 6e 65 20 6f 72 20 6d 6f 72 65 20 66 61 69 6c one or more fail
3910: 75 72 65 20 63 61 73 65 73 2e 0a 0a 20 20 64 65 ure cases... de
3920: 66 20 74 72 79 5f 77 61 69 74 20 28 73 65 6c 66 f try_wait (self
3930: 2c 20 6d 61 74 63 68 65 73 2c 20 74 69 6d 65 6f , matches, timeo
3940: 75 74 20 3d 20 2d 31 29 3a 0a 20 20 20 20 74 72 ut = -1):. tr
3950: 79 3a 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 y:. return
3960: 73 65 6c 66 2e 5f 63 68 69 6c 64 2e 65 78 70 65 self._child.expe
3970: 63 74 20 28 6d 61 74 63 68 65 73 2c 20 74 69 6d ct (matches, tim
3980: 65 6f 75 74 20 3d 20 74 69 6d 65 6f 75 74 29 20 eout = timeout)
3990: 3d 3d 20 30 0a 20 20 20 20 65 78 63 65 70 74 20 == 0. except
39a0: 70 65 78 70 65 63 74 2e 65 78 63 65 70 74 69 6f pexpect.exceptio
39b0: 6e 73 2e 54 49 4d 45 4f 55 54 3a 0a 20 20 20 20 ns.TIMEOUT:.
39c0: 20 20 73 79 73 2e 73 74 64 65 72 72 2e 77 72 69 sys.stderr.wri
39d0: 74 65 20 28 22 45 78 63 65 65 64 65 64 20 22 20 te ("Exceeded "
39e0: 2b 20 73 74 72 28 74 69 6d 65 6f 75 74 29 20 2b + str(timeout) +
39f0: 20 22 20 73 65 63 20 74 69 6d 65 6f 75 74 20 22 " sec timeout "
3a00: 20 2b 0a 20 20 20 20 20 20 20 20 20 20 22 77 61 +. "wa
3a10: 69 74 69 6e 67 20 66 6f 72 20 22 20 2b 20 73 74 iting for " + st
3a20: 72 28 6d 61 74 63 68 65 73 29 20 2b 20 22 5c 6e r(matches) + "\n
3a30: 22 29 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 "). return
3a40: 46 61 6c 73 65 0a 20 20 20 20 65 78 63 65 70 74 False. except
3a50: 3a 0a 20 20 20 20 20 20 73 79 73 2e 73 74 64 65 :. sys.stde
3a60: 72 72 2e 77 72 69 74 65 20 28 22 46 61 69 6c 65 rr.write ("Faile
3a70: 64 20 74 6f 20 6d 61 74 63 68 20 22 20 2b 20 73 d to match " + s
3a80: 74 72 28 6d 61 74 63 68 65 73 29 20 2b 20 0a 20 tr(matches) + .
3a90: 20 20 20 20 20 20 20 20 20 22 3a 20 75 6e 6b 6e ": unkn
3aa0: 6f 77 6e 20 65 78 63 65 70 74 69 6f 6e 2e 5c 6e own exception.\n
3ab0: 22 29 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 "). return
3ac0: 46 61 6c 73 65 0a 0a 20 20 23 23 23 23 23 23 23 False.. #######
3ad0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3ae0: 23 20 55 74 69 6c 69 74 79 20 46 75 6e 63 74 69 # Utility Functi
3af0: 6f 6e 73 20 23 23 23 23 23 23 23 23 23 23 23 23 ons ############
3b00: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3b10: 23 0a 20 20 20 20 0a 20 20 23 23 23 23 20 74 65 #. . #### te
3b20: 73 74 5f 72 65 73 75 6c 74 20 23 23 23 23 23 23 st_result ######
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 23 23 23 ################
3b60: 0a 20 20 23 20 47 69 76 65 6e 20 61 20 72 65 73 . # Given a res
3b70: 75 6c 74 20 6e 75 6d 62 65 72 2c 20 61 6e 20 65 ult number, an e
3b80: 78 70 65 63 74 65 64 20 72 65 73 75 6c 74 2c 20 xpected result,
3b90: 61 6e 64 20 61 6e 20 61 72 72 61 79 20 6f 66 20 and an array of
3ba0: 72 65 73 75 6c 74 20 65 6c 65 6d 65 6e 74 73 2c result elements,
3bb0: 0a 20 20 23 20 72 65 74 75 72 6e 20 54 72 75 65 . # return True
3bc0: 20 69 66 20 74 68 65 20 72 65 73 75 6c 74 20 6d if the result m
3bd0: 61 74 63 68 65 64 20 65 78 70 65 63 74 65 64 20 atched expected
3be0: 76 61 6c 75 65 2e 0a 20 20 23 20 49 66 20 63 61 value.. # If ca
3bf0: 6c 6c 65 72 20 69 73 20 6e 6f 74 20 74 68 65 20 ller is not the
3c00: 65 6d 70 74 79 20 73 74 72 69 6e 67 2c 20 70 72 empty string, pr
3c10: 69 6e 74 20 61 20 6d 65 73 73 61 67 65 20 61 62 int a message ab
3c20: 6f 75 74 20 69 74 2e 0a 20 20 23 0a 20 20 23 20 out it.. #. #
3c30: 54 68 69 73 20 72 6f 75 74 69 6e 65 20 64 6f 65 This routine doe
3c40: 73 20 74 68 65 20 72 65 70 65 74 69 74 69 76 65 s the repetitive
3c50: 20 77 6f 72 6b 20 6f 66 20 74 65 73 74 69 6e 67 work of testing
3c60: 20 72 65 73 75 6c 74 73 20 72 65 74 75 72 6e 65 results returne
3c70: 64 0a 20 20 23 20 66 72 6f 6d 20 72 75 6e 6e 69 d. # from runni
3c80: 6e 67 20 61 20 63 6f 6d 6d 61 6e 64 2c 20 61 6e ng a command, an
3c90: 64 20 6f 70 74 69 6f 6e 61 6c 6c 79 20 70 72 69 d optionally pri
3ca0: 6e 74 69 6e 67 20 73 74 61 74 75 73 2e 0a 0a 20 nting status...
3cb0: 20 64 65 66 20 74 65 73 74 5f 72 65 73 75 6c 74 def test_result
3cc0: 20 28 73 65 6c 66 2c 20 72 65 70 6c 79 2c 20 65 (self, reply, e
3cd0: 78 70 65 63 74 65 64 2c 20 72 65 73 75 6c 74 73 xpected, results
3ce0: 2c 20 63 61 6c 6c 65 72 2c 20 64 65 62 75 67 3d , caller, debug=
3cf0: 46 61 6c 73 65 29 3a 0a 20 20 20 20 23 20 43 6f False):. # Co
3d00: 76 65 72 20 63 61 73 65 20 6f 66 20 75 74 74 65 ver case of utte
3d10: 72 20 66 61 69 6c 75 72 65 2e 0a 20 20 20 20 69 r failure.. i
3d20: 66 20 72 65 70 6c 79 20 3d 3d 20 2d 31 3a 0a 20 f reply == -1:.
3d30: 20 20 20 20 20 69 66 20 64 65 62 75 67 20 6f 72 if debug or
3d40: 20 63 61 6c 6c 65 72 20 21 3d 20 22 22 3a 0a 20 caller != "":.
3d50: 20 20 20 20 20 20 20 70 72 69 6e 74 20 28 63 61 print (ca
3d60: 6c 6c 65 72 20 2b 20 22 3a 20 66 61 69 6c 75 72 ller + ": failur
3d70: 65 2e 22 29 0a 20 20 20 20 20 20 72 65 74 75 72 e."). retur
3d80: 6e 20 46 61 6c 73 65 0a 20 20 20 20 72 65 70 6c n False. repl
3d90: 79 5f 49 44 20 3d 20 72 65 73 75 6c 74 73 5b 72 y_ID = results[r
3da0: 65 70 6c 79 5d 5b 30 5d 0a 20 20 20 20 69 66 20 eply][0]. if
3db0: 64 65 62 75 67 3a 0a 20 20 20 20 20 20 70 72 69 debug:. pri
3dc0: 6e 74 20 28 22 74 65 73 74 5f 72 65 73 75 6c 74 nt ("test_result
3dd0: 3a 20 47 6f 74 20 72 65 70 6c 79 3a 20 22 20 2b : Got reply: " +
3de0: 20 73 74 72 28 72 65 70 6c 79 29 20 2b 20 22 20 str(reply) + "
3df0: 2d 3e 20 22 20 20 2b 20 72 65 70 6c 79 5f 49 44 -> " + reply_ID
3e00: 29 0a 20 20 20 20 20 20 70 72 69 6e 74 28 22 5c ). print("\
3e10: 74 6d 61 74 63 68 20 62 65 66 6f 72 65 3a 20 7b tmatch before: {
3e20: 22 20 2b 20 73 65 6c 66 2e 5f 63 68 69 6c 64 2e " + self._child.
3e30: 62 65 66 6f 72 65 2e 64 65 63 6f 64 65 28 29 20 before.decode()
3e40: 2b 20 22 7d 22 29 0a 20 20 20 20 20 20 70 72 69 + "}"). pri
3e50: 6e 74 28 22 5c 74 6d 61 74 63 68 20 61 66 74 65 nt("\tmatch afte
3e60: 72 3a 20 7b 22 20 2b 20 73 65 6c 66 2e 63 68 69 r: {" + self.chi
3e70: 6c 64 5f 61 66 74 65 72 28 29 20 2b 20 22 7d 22 ld_after() + "}"
3e80: 29 0a 20 20 20 20 69 66 20 72 65 70 6c 79 5f 49 ). if reply_I
3e90: 44 2e 6c 6f 77 65 72 28 29 20 3d 3d 20 65 78 70 D.lower() == exp
3ea0: 65 63 74 65 64 2e 6c 6f 77 65 72 28 29 3a 0a 20 ected.lower():.
3eb0: 20 20 20 20 20 72 65 74 75 72 6e 20 54 72 75 65 return True
3ec0: 0a 20 20 20 20 65 6c 73 65 3a 0a 20 20 20 20 20 . else:.
3ed0: 20 69 66 20 63 61 6c 6c 65 72 20 21 3d 20 22 22 if caller != ""
3ee0: 3a 0a 20 20 20 20 20 20 20 20 70 72 69 6e 74 20 :. print
3ef0: 28 63 61 6c 6c 65 72 20 2b 20 22 3a 20 45 78 70 (caller + ": Exp
3f00: 65 63 74 65 64 3a 20 5c 22 22 20 2b 20 65 78 70 ected: \"" + exp
3f10: 65 63 74 65 64 20 2b 20 22 5c 22 2e 20 49 6e 73 ected + "\". Ins
3f20: 74 65 61 64 20 67 6f 74 3a 20 5c 22 22 20 2b 20 tead got: \"" +
3f30: 72 65 70 6c 79 5f 49 44 20 2b 20 22 5c 22 2e 22 reply_ID + "\"."
3f40: 29 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 46 ). return F
3f50: 61 6c 73 65 20 20 20 20 20 20 0a 0a 20 20 0a 20 alse .. .
3f60: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ###############
3f70: 23 23 23 23 23 23 20 42 61 73 69 63 20 53 49 4d ###### Basic SIM
3f80: 48 20 49 6e 74 65 72 61 63 74 69 6f 6e 20 23 23 H Interaction ##
3f90: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3fa0: 23 23 23 23 23 23 23 23 23 0a 20 20 23 20 55 73 #########. # Us
3fb0: 65 20 74 68 65 73 65 20 74 6f 20 77 6f 72 6b 20 e these to work
3fc0: 77 69 74 68 20 73 69 6d 68 20 75 6e 64 65 72 20 with simh under
3fd0: 70 65 78 70 65 63 74 0a 0a 20 20 0a 20 20 23 23 pexpect.. . ##
3fe0: 23 23 20 65 73 63 5f 74 6f 5f 73 69 6d 68 20 20 ## esc_to_simh
3ff0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
4000: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
4010: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
4020: 23 23 23 23 23 23 0a 20 20 23 20 55 6e 63 6f 6e ######. # Uncon
4030: 64 69 74 69 6f 6e 61 6c 6c 79 20 67 6f 20 74 6f ditionally go to
4040: 20 53 49 4d 48 0a 20 20 64 65 66 20 65 73 63 5f SIMH. def esc_
4050: 74 6f 5f 73 69 6d 68 20 28 73 65 6c 66 2c 20 64 to_simh (self, d
4060: 65 62 75 67 3d 46 61 6c 73 65 29 3a 0a 20 20 20 ebug=False):.
4070: 20 73 65 6c 66 2e 5f 63 68 69 6c 64 2e 73 65 6e self._child.sen
4080: 64 63 6f 6e 74 72 6f 6c 20 28 27 65 27 29 0a 20 dcontrol ('e').
4090: 20 20 20 72 65 70 6c 79 20 3d 20 73 65 6c 66 2e reply = self.
40a0: 63 68 69 6c 64 5f 65 78 70 65 63 74 20 28 73 65 child_expect (se
40b0: 6c 66 2e 5f 73 69 6d 68 5f 72 65 70 6c 69 65 73 lf._simh_replies
40c0: 5f 72 65 78 29 20 20 23 20 57 61 69 74 20 74 6f _rex) # Wait to
40d0: 20 67 65 74 20 73 69 6d 68 20 70 72 6f 6d 70 74 get simh prompt
40e0: 0a 20 20 20 20 73 65 6c 66 2e 73 69 6d 68 5f 74 . self.simh_t
40f0: 65 73 74 5f 72 65 73 75 6c 74 28 72 65 70 6c 79 est_result(reply
4100: 2c 20 22 50 72 6f 6d 70 74 22 2c 20 22 65 73 63 , "Prompt", "esc
4110: 5f 74 6f 5f 73 69 6d 68 22 29 0a 20 20 20 20 73 _to_simh"). s
4120: 65 6c 66 2e 5f 63 6f 6e 74 65 78 74 20 3d 20 22 elf._context = "
4130: 73 69 6d 68 22 0a 20 20 20 20 69 66 20 64 65 62 simh". if deb
4140: 75 67 3a 0a 20 20 20 20 20 20 70 72 69 6e 74 28 ug:. print(
4150: 22 65 73 63 5f 74 6f 5f 73 69 6d 68 3a 20 72 65 "esc_to_simh: re
4160: 70 6c 79 3a 20 22 20 2b 20 73 74 72 28 72 65 70 ply: " + str(rep
4170: 6c 79 29 20 2b 20 22 20 2d 3e 20 22 20 2b 20 73 ly) + " -> " + s
4180: 65 6c 66 2e 5f 73 69 6d 68 5f 72 65 70 6c 69 65 elf._simh_replie
4190: 73 5b 72 65 70 6c 79 5d 5b 30 5d 29 0a 20 20 20 s[reply][0]).
41a0: 20 20 20 70 72 69 6e 74 28 22 5c 74 6d 61 74 63 print("\tmatc
41b0: 68 20 62 65 66 6f 72 65 3a 20 7b 22 20 2b 20 73 h before: {" + s
41c0: 65 6c 66 2e 5f 63 68 69 6c 64 2e 62 65 66 6f 72 elf._child.befor
41d0: 65 2e 64 65 63 6f 64 65 28 29 20 2b 20 22 7d 22 e.decode() + "}"
41e0: 29 0a 20 20 20 20 20 20 70 72 69 6e 74 28 22 5c ). print("\
41f0: 74 6d 61 74 63 68 20 61 66 74 65 72 3a 20 7b 22 tmatch after: {"
4200: 20 2b 20 73 65 6c 66 2e 63 68 69 6c 64 5f 61 66 + self.child_af
4210: 74 65 72 28 29 20 2b 20 22 7d 22 29 0a 20 20 20 ter() + "}").
4220: 20 72 65 74 75 72 6e 20 72 65 70 6c 79 0a 0a 0a return reply...
4230: 20 20 23 23 23 23 20 73 69 6d 68 5f 74 65 73 74 #### simh_test
4240: 5f 72 65 73 75 6c 74 20 23 23 23 23 23 23 23 23 _result ########
4250: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
4260: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
4270: 23 23 23 23 23 23 23 23 23 0a 20 20 23 20 43 6f #########. # Co
4280: 6e 76 65 6e 69 65 6e 63 65 20 77 72 61 70 70 65 nvenience wrappe
4290: 72 20 66 6f 72 20 74 65 73 74 5f 72 65 73 75 6c r for test_resul
42a0: 74 20 74 68 61 74 20 75 73 65 73 20 53 49 4d 48 t that uses SIMH
42b0: 20 72 65 70 6c 69 65 73 2e 0a 0a 20 20 64 65 66 replies... def
42c0: 20 73 69 6d 68 5f 74 65 73 74 5f 72 65 73 75 6c simh_test_resul
42d0: 74 20 28 73 65 6c 66 2c 20 72 65 70 6c 79 2c 20 t (self, reply,
42e0: 65 78 70 65 63 74 65 64 2c 20 63 61 6c 6c 65 72 expected, caller
42f0: 2c 20 64 65 62 75 67 3d 46 61 6c 73 65 29 3a 0a , debug=False):.
4300: 20 20 20 20 72 65 74 75 72 6e 20 73 65 6c 66 2e return self.
4310: 74 65 73 74 5f 72 65 73 75 6c 74 20 28 72 65 70 test_result (rep
4320: 6c 79 2c 20 65 78 70 65 63 74 65 64 2c 20 73 65 ly, expected, se
4330: 6c 66 2e 5f 73 69 6d 68 5f 72 65 70 6c 69 65 73 lf._simh_replies
4340: 2c 20 63 61 6c 6c 65 72 29 0a 0a 20 20 0a 20 20 , caller).. .
4350: 23 23 23 23 20 73 69 6d 68 5f 73 65 6e 64 5f 6c #### simh_send_l
4360: 69 6e 65 20 23 23 23 23 23 23 23 23 23 23 23 23 ine ############
4370: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
4380: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
4390: 23 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 23 ############. #
43a0: 20 53 65 6e 64 20 61 20 6c 69 6e 65 20 74 6f 20 Send a line to
43b0: 73 69 6d 68 20 77 68 69 6c 65 20 6d 61 6e 61 67 simh while manag
43c0: 69 6e 67 20 63 6f 6e 74 65 78 74 2e 0a 20 20 23 ing context.. #
43d0: 20 49 66 20 77 65 20 61 72 65 20 6e 6f 74 20 69 If we are not i
43e0: 6e 20 74 68 65 20 73 69 6d 68 20 63 6f 6e 74 65 n the simh conte
43f0: 78 74 20 63 61 6c 6c 20 65 73 63 5f 74 6f 5f 73 xt call esc_to_s
4400: 69 6d 68 20 77 68 69 63 68 20 77 69 6c 6c 0a 20 imh which will.
4410: 20 23 20 20 20 20 73 65 6e 64 20 5e 65 2c 20 61 # send ^e, a
4420: 6e 64 20 73 65 74 20 74 68 65 20 63 6f 6e 74 65 nd set the conte
4430: 78 74 20 74 6f 20 73 69 6d 68 2e 0a 20 20 23 20 xt to simh.. #
4440: 49 66 20 77 65 20 69 73 73 75 65 20 61 20 63 6f If we issue a co
4450: 6d 6d 61 6e 64 20 74 68 61 74 20 65 6e 74 65 72 mmand that enter
4460: 73 20 6f 73 38 20 63 6f 6e 74 65 78 74 2c 20 73 s os8 context, s
4470: 65 74 20 63 6f 6e 74 65 78 74 20 22 6f 73 38 22 et context "os8"
4480: 2e 0a 20 20 23 20 49 74 20 69 73 20 75 70 20 74 .. # It is up t
4490: 6f 20 74 68 65 20 63 61 6c 6c 65 72 20 74 6f 20 o the caller to
44a0: 74 68 65 6e 20 64 6f 20 61 6e 20 65 78 70 65 63 then do an expec
44b0: 74 20 74 6f 20 63 6f 6e 66 69 72 6d 20 73 75 63 t to confirm suc
44c0: 63 65 73 73 2e 0a 0a 20 20 64 65 66 20 73 69 6d cess... def sim
44d0: 68 5f 73 65 6e 64 5f 6c 69 6e 65 20 28 73 65 6c h_send_line (sel
44e0: 66 2c 20 63 6d 64 2c 20 64 65 62 75 67 3d 46 61 f, cmd, debug=Fa
44f0: 6c 73 65 29 3a 0a 20 20 20 20 69 66 20 64 65 62 lse):. if deb
4500: 75 67 3a 20 70 72 69 6e 74 20 28 22 43 6f 6e 74 ug: print ("Cont
4510: 65 78 74 3a 20 22 20 2b 20 73 65 6c 66 2e 5f 63 ext: " + self._c
4520: 6f 6e 74 65 78 74 29 0a 20 20 20 20 69 66 20 73 ontext). if s
4530: 65 6c 66 2e 5f 63 6f 6e 74 65 78 74 20 21 3d 20 elf._context !=
4540: 22 73 69 6d 68 22 3a 0a 20 20 20 20 20 20 73 65 "simh":. se
4550: 6c 66 2e 65 73 63 5f 74 6f 5f 73 69 6d 68 28 29 lf.esc_to_simh()
4560: 0a 20 20 20 20 69 66 20 64 65 62 75 67 3a 20 70 . if debug: p
4570: 72 69 6e 74 20 28 22 73 69 6d 68 5f 73 65 6e 64 rint ("simh_send
4580: 5f 6c 69 6e 65 3a 20 53 65 6e 64 69 6e 67 3a 20 _line: Sending:
4590: 22 20 2b 20 63 6d 64 29 0a 20 20 20 20 73 65 6c " + cmd). sel
45a0: 66 2e 5f 63 68 69 6c 64 2e 73 65 6e 64 6c 69 6e f._child.sendlin
45b0: 65 20 28 63 6d 64 29 0a 20 20 20 20 6d 20 3d 20 e (cmd). m =
45c0: 72 65 2e 6d 61 74 63 68 20 28 73 65 6c 66 2e 5f re.match (self._
45d0: 73 69 6d 68 5f 63 6f 6d 6d 5f 72 65 2c 20 63 6d simh_comm_re, cm
45e0: 64 29 0a 20 20 20 20 69 66 20 6d 20 21 3d 20 4e d). if m != N
45f0: 6f 6e 65 20 61 6e 64 20 6d 2e 67 72 6f 75 70 28 one and m.group(
4600: 31 29 5b 3a 31 5d 2e 75 70 70 65 72 28 29 20 69 1)[:1].upper() i
4610: 6e 20 73 65 6c 66 2e 5f 65 6e 74 65 72 73 5f 6f n self._enters_o
4620: 73 38 5f 63 6f 6e 74 65 78 74 3a 0a 20 20 20 20 s8_context:.
4630: 20 20 73 65 6c 66 2e 5f 63 6f 6e 74 65 78 74 20 self._context
4640: 3d 20 22 6f 73 38 22 0a 0a 20 20 0a 0a 20 20 23 = "os8".. .. #
4650: 23 23 23 20 73 69 6d 68 5f 63 6d 64 20 23 23 23 ### simh_cmd ###
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 23 23 ################
4680: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
4690: 23 23 23 23 23 0a 20 20 23 20 49 66 20 77 65 20 #####. # If we
46a0: 61 72 65 20 6e 6f 74 20 69 6e 20 74 68 65 20 73 are not in the s
46b0: 69 6d 68 20 63 6f 6e 74 65 78 74 20 63 61 6c 6c imh context call
46c0: 20 65 73 63 5f 74 6f 5f 73 69 6d 68 20 77 68 69 esc_to_simh whi
46d0: 63 68 20 77 69 6c 6c 0a 20 20 23 20 20 20 20 73 ch will. # s
46e0: 65 6e 64 20 5e 65 2c 20 61 6e 64 20 73 65 74 20 end ^e, and set
46f0: 74 68 65 20 63 6f 6e 74 65 78 74 20 74 6f 20 73 the context to s
4700: 69 6d 68 2e 0a 20 20 23 20 49 66 20 77 65 20 69 imh.. # If we i
4710: 73 73 75 65 20 61 20 63 6f 6d 6d 61 6e 64 20 74 ssue a command t
4720: 68 61 74 20 65 6e 74 65 72 73 20 6f 73 38 20 63 hat enters os8 c
4730: 6f 6e 74 65 78 74 2c 20 73 65 74 20 63 6f 6e 74 ontext, set cont
4740: 65 78 74 20 22 6f 73 38 22 2e 0a 20 20 23 20 57 ext "os8".. # W
4750: 61 69 74 20 66 6f 72 20 61 20 72 65 70 6c 79 20 ait for a reply
4760: 66 6f 72 20 65 72 72 6f 72 20 63 68 65 63 6b 69 for error checki
4770: 6e 67 2e 0a 20 20 23 20 72 65 70 6c 69 65 73 20 ng.. # replies
4780: 69 73 20 61 6e 20 6f 70 74 69 6f 6e 61 6c 20 61 is an optional a
4790: 72 67 75 6d 65 6e 74 20 74 68 61 74 20 64 65 66 rgument that def
47a0: 61 75 6c 74 73 20 74 6f 20 5f 73 69 6d 68 5f 72 aults to _simh_r
47b0: 65 70 6c 69 65 73 5f 72 65 78 0a 20 20 0a 20 20 eplies_rex. .
47c0: 64 65 66 20 73 69 6d 68 5f 63 6d 64 20 28 73 65 def simh_cmd (se
47d0: 6c 66 2c 20 63 6d 64 2c 20 72 65 70 6c 69 65 73 lf, cmd, replies
47e0: 3d 4e 6f 6e 65 2c 20 64 65 62 75 67 3d 46 61 6c =None, debug=Fal
47f0: 73 65 29 3a 0a 20 20 20 20 69 66 20 72 65 70 6c se):. if repl
4800: 69 65 73 20 3d 3d 20 4e 6f 6e 65 3a 20 72 65 70 ies == None: rep
4810: 6c 69 65 73 20 3d 20 73 65 6c 66 2e 5f 73 69 6d lies = self._sim
4820: 68 5f 72 65 70 6c 69 65 73 5f 72 65 78 0a 20 20 h_replies_rex.
4830: 20 20 73 65 6c 66 2e 73 69 6d 68 5f 73 65 6e 64 self.simh_send
4840: 5f 6c 69 6e 65 20 28 63 6d 64 2c 20 64 65 62 75 _line (cmd, debu
4850: 67 3d 64 65 62 75 67 29 0a 20 20 20 20 72 65 70 g=debug). rep
4860: 6c 79 20 3d 20 73 65 6c 66 2e 63 68 69 6c 64 5f ly = self.child_
4870: 65 78 70 65 63 74 28 72 65 70 6c 69 65 73 29 0a expect(replies).
4880: 20 20 20 20 69 66 20 72 65 70 6c 79 20 3d 3d 20 if reply ==
4890: 2d 31 3a 0a 20 20 20 20 20 20 70 72 69 6e 74 20 -1:. print
48a0: 28 22 73 69 6d 68 5f 63 6d 64 3a 20 77 61 73 20 ("simh_cmd: was
48b0: 73 65 6e 64 69 6e 67 3a 22 20 2b 20 63 6d 64 29 sending:" + cmd)
48c0: 0a 20 20 20 20 69 66 20 64 65 62 75 67 3a 0a 20 . if debug:.
48d0: 20 20 20 20 20 70 72 69 6e 74 28 22 5c 74 47 6f print("\tGo
48e0: 74 20 72 65 70 6c 79 3a 20 22 20 2b 20 73 74 72 t reply: " + str
48f0: 28 72 65 70 6c 79 29 20 2b 20 22 20 2d 3e 20 22 (reply) + " -> "
4900: 20 2b 20 73 65 6c 66 2e 5f 73 69 6d 68 5f 72 65 + self._simh_re
4910: 70 6c 69 65 73 5b 72 65 70 6c 79 5d 5b 30 5d 29 plies[reply][0])
4920: 0a 20 20 20 20 20 20 70 72 69 6e 74 28 22 5c 74 . print("\t
4930: 6d 61 74 63 68 20 62 65 66 6f 72 65 3a 20 7b 22 match before: {"
4940: 20 2b 20 73 65 6c 66 2e 5f 63 68 69 6c 64 2e 62 + self._child.b
4950: 65 66 6f 72 65 2e 64 65 63 6f 64 65 28 29 20 2b efore.decode() +
4960: 20 22 7d 22 29 0a 20 20 20 20 20 20 70 72 69 6e "}"). prin
4970: 74 28 22 5c 74 6d 61 74 63 68 20 61 66 74 65 72 t("\tmatch after
4980: 3a 20 7b 22 20 2b 20 73 65 6c 66 2e 63 68 69 6c : {" + self.chil
4990: 64 5f 61 66 74 65 72 28 29 20 2b 20 22 7d 22 29 d_after() + "}")
49a0: 0a 20 20 20 20 72 65 74 75 72 6e 20 72 65 70 6c . return repl
49b0: 79 0a 0a 0a 20 20 23 23 23 23 20 71 75 69 74 20 y... #### quit
49c0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
49d0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
49e0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
49f0: 23 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 23 ############. #
4a00: 20 51 75 69 74 73 20 74 68 65 20 73 69 6d 75 6c Quits the simul
4a10: 61 74 6f 72 20 61 6e 64 20 77 61 69 74 73 20 66 ator and waits f
4a20: 6f 72 20 69 74 20 74 6f 20 65 78 69 74 0a 20 20 or it to exit.
4a30: 23 20 42 79 20 63 61 6c 6c 69 6e 67 20 73 69 6d # By calling sim
4a40: 68 5f 73 65 6e 64 5f 6c 69 6e 65 2c 20 77 65 20 h_send_line, we
4a50: 61 72 65 20 63 61 72 65 66 75 6c 20 74 6f 20 6c are careful to l
4a60: 6f 6f 6b 20 74 6f 20 6f 75 72 20 63 6f 6e 74 65 ook to our conte
4a70: 78 74 0a 20 20 23 20 61 6e 64 20 65 73 63 61 70 xt. # and escap
4a80: 65 20 74 6f 20 53 49 4d 48 20 69 66 20 6e 65 63 e to SIMH if nec
4a90: 65 73 73 61 72 79 2e 0a 0a 20 20 64 65 66 20 71 essary... def q
4aa0: 75 69 74 20 28 73 65 6c 66 29 3a 0a 20 20 20 20 uit (self):.
4ab0: 73 65 6c 66 2e 73 69 6d 68 5f 73 65 6e 64 5f 6c self.simh_send_l
4ac0: 69 6e 65 28 22 71 75 69 74 22 29 0a 20 20 0a 0a ine("quit"). ..
4ad0: 20 20 23 23 23 23 20 7a 65 72 6f 5f 63 6f 72 65 #### zero_core
4ae0: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ###############
4af0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
4b00: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
4b10: 23 23 23 23 23 23 23 23 0a 20 20 23 20 46 72 6f ########. # Fro
4b20: 6d 20 53 49 4d 48 20 63 6f 6e 74 65 78 74 2c 20 m SIMH context,
4b30: 7a 65 72 6f 20 74 68 65 20 65 6e 74 69 72 65 20 zero the entire
4b40: 63 6f 6e 74 65 6e 74 73 20 6f 66 20 63 6f 72 65 contents of core
4b50: 2c 20 77 68 69 63 68 20 69 73 0a 20 20 23 20 61 , which is. # a
4b60: 73 73 75 6d 65 64 20 74 6f 20 62 65 20 33 32 20 ssumed to be 32
4b70: 6b 57 6f 72 64 73 2e 0a 20 20 23 0a 20 20 23 20 kWords.. #. #
4b80: 53 49 4d 48 27 73 20 50 44 50 2d 38 20 73 69 6d SIMH's PDP-8 sim
4b90: 75 6c 61 74 6f 72 20 64 6f 65 73 6e 27 74 20 73 ulator doesn't s
4ba0: 74 61 72 74 20 77 69 74 68 20 63 6f 72 65 20 7a tart with core z
4bb0: 65 72 6f 65 64 2c 20 6f 6e 20 70 75 72 70 6f 73 eroed, on purpos
4bc0: 65 2c 0a 20 20 23 20 62 65 63 61 75 73 65 20 74 e,. # because t
4bd0: 68 65 20 61 63 74 75 61 6c 20 68 61 72 64 77 61 he actual hardwa
4be0: 72 65 20 64 69 64 20 6e 6f 74 20 64 6f 20 74 68 re did not do th
4bf0: 61 74 2e 20 20 53 49 4d 48 20 64 6f 65 73 20 6e at. SIMH does n
4c00: 6f 74 20 61 74 74 65 6d 70 74 0a 20 20 23 20 74 ot attempt. # t
4c10: 6f 20 73 69 6d 75 6c 61 74 65 20 74 68 65 20 70 o simulate the p
4c20: 65 72 73 69 73 74 65 6e 63 65 20 6f 66 20 63 6f ersistence of co
4c30: 72 65 20 6d 65 6d 6f 72 79 20 62 79 20 73 61 76 re memory by sav
4c40: 69 6e 67 20 69 74 20 74 6f 20 64 69 73 6b 0a 20 ing it to disk.
4c50: 20 23 20 62 65 74 77 65 65 6e 20 72 75 6e 73 2c # between runs,
4c60: 20 62 75 74 20 74 68 65 20 53 49 4d 48 20 64 65 but the SIMH de
4c70: 76 65 6c 6f 70 65 72 73 20 61 72 65 20 72 69 67 velopers are rig
4c80: 68 74 20 74 6f 20 72 65 66 75 73 65 20 74 6f 20 ht to refuse to
4c90: 64 6f 20 74 68 69 73 0a 20 20 23 20 62 79 20 64 do this. # by d
4ca0: 65 66 61 75 6c 74 3a 20 79 6f 75 20 63 61 6e 6e efault: you cann
4cb0: 6f 74 20 74 72 75 73 74 20 74 68 65 20 70 72 69 ot trust the pri
4cc0: 6f 72 20 73 74 61 74 65 20 6f 66 20 61 20 50 44 or state of a PD
4cd0: 50 2d 38 27 73 20 63 6f 72 65 0a 20 20 23 20 6d P-8's core. # m
4ce0: 65 6d 6f 72 79 20 62 65 66 6f 72 65 20 69 6e 69 emory before ini
4cf0: 74 69 61 6c 69 7a 69 6e 67 20 69 74 20 79 6f 75 tializing it you
4d00: 72 73 65 6c 66 2e 0a 20 20 23 0a 20 20 23 20 53 rself.. #. # S
4d10: 65 65 20 6f 73 38 5f 7a 65 72 6f 5f 63 6f 72 65 ee os8_zero_core
4d20: 20 28 29 20 66 6f 72 20 61 20 6c 65 73 73 20 68 () for a less h
4d30: 65 61 76 79 2d 68 61 6e 64 65 64 20 61 6c 74 65 eavy-handed alte
4d40: 72 6e 61 74 69 76 65 20 66 6f 72 20 75 73 65 0a rnative for use.
4d50: 20 20 23 20 77 68 65 6e 20 72 75 6e 6e 69 6e 67 # when running
4d60: 20 75 6e 64 65 72 20 4f 53 2f 38 2e 0a 0a 20 20 under OS/8...
4d70: 64 65 66 20 7a 65 72 6f 5f 63 6f 72 65 20 28 73 def zero_core (s
4d80: 65 6c 66 29 3a 0a 20 20 20 20 72 65 70 6c 79 20 elf):. reply
4d90: 3d 20 73 65 6c 66 2e 73 69 6d 68 5f 63 6d 64 20 = self.simh_cmd
4da0: 28 27 64 65 20 61 6c 6c 20 30 27 29 0a 20 20 20 ('de all 0').
4db0: 20 73 65 6c 66 2e 73 69 6d 68 5f 74 65 73 74 5f self.simh_test_
4dc0: 72 65 73 75 6c 74 28 72 65 70 6c 79 2c 20 22 50 result(reply, "P
4dd0: 72 6f 6d 70 74 22 2c 20 22 73 69 6d 68 5f 7a 65 rompt", "simh_ze
4de0: 72 6f 5f 63 6f 72 65 22 29 0a 0a 0a 20 20 23 23 ro_core")... ##
4df0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 20 ###############
4e00: 50 44 50 2d 38 20 53 49 4d 48 20 49 6e 74 65 72 PDP-8 SIMH Inter
4e10: 61 63 74 69 6f 6e 20 23 23 23 23 23 23 23 23 23 action #########
4e20: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
4e30: 23 23 23 23 0a 20 20 23 20 48 69 67 68 20 6c 65 ####. # High le
4e40: 76 65 6c 20 69 6e 74 65 72 66 61 63 65 73 20 74 vel interfaces t
4e50: 6f 20 6c 65 61 72 6e 20 61 62 6f 75 74 20 61 6e o learn about an
4e60: 64 20 63 68 61 6e 67 65 20 64 65 76 69 63 65 20 d change device
4e70: 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e 73 0a 20 configurations.
4e80: 20 23 20 66 6f 72 20 74 68 65 20 50 44 50 2d 38 # for the PDP-8
4e90: 20 75 6e 64 65 72 20 53 49 4d 48 2e 0a 20 20 0a under SIMH.. .
4ea0: 20 20 23 23 23 23 20 64 65 73 63 72 69 62 65 5f #### describe_
4eb0: 64 65 76 5f 63 6f 6e 66 69 67 20 23 23 23 23 23 dev_config #####
4ec0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
4ed0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
4ee0: 23 23 23 23 23 23 23 23 0a 20 20 23 20 57 65 20 ########. # We
4ef0: 70 72 6f 76 69 64 65 20 61 6e 20 69 6e 74 65 72 provide an inter
4f00: 66 61 63 65 20 74 6f 20 61 6c 74 65 72 20 53 49 face to alter SI
4f10: 4d 48 20 64 65 76 69 63 65 20 63 6f 6e 66 69 67 MH device config
4f20: 75 72 61 74 69 6f 6e 73 20 66 6f 72 0a 20 20 23 urations for. #
4f30: 20 73 70 65 63 69 66 69 63 20 70 61 72 61 6d 65 specific parame
4f40: 74 65 72 73 20 61 6e 64 20 73 70 65 63 69 66 69 ters and specifi
4f50: 63 20 64 65 76 69 63 65 73 0a 20 20 23 0a 20 20 c devices. #.
4f60: 23 20 64 65 76 20 63 6f 6e 66 69 67 73 20 73 75 # dev configs su
4f70: 70 70 6f 72 74 65 64 3a 20 20 72 78 2c 20 74 74 pported: rx, tt
4f80: 69 2c 20 74 61 70 65 0a 20 20 23 0a 20 20 23 20 i, tape. #. #
4f90: 72 78 3a 20 20 20 20 20 52 58 38 45 2c 20 52 58 rx: RX8E, RX
4fa0: 32 38 20 20 20 52 58 38 45 20 69 73 20 74 68 65 28 RX8E is the
4fb0: 20 73 69 6d 68 20 6e 61 6d 65 20 66 6f 72 20 52 simh name for R
4fc0: 58 30 31 20 73 75 70 70 6f 72 74 2e 0a 20 20 23 X01 support.. #
4fd0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
4fe0: 20 20 20 20 20 20 52 58 32 38 20 69 73 20 74 68 RX28 is th
4ff0: 65 20 73 69 6d 68 20 6e 61 6d 65 20 66 6f 72 20 e simh name for
5000: 52 58 30 32 20 73 75 70 70 6f 72 74 2e 0a 20 20 RX02 support..
5010: 23 20 74 74 69 3a 20 20 20 20 4b 53 52 2c 20 37 # tti: KSR, 7
5020: 62 20 20 20 20 20 20 37 62 20 69 73 20 66 75 6c b 7b is ful
5030: 6c 20 6b 65 79 62 6f 61 72 64 20 73 75 70 70 6f l keyboard suppo
5040: 72 74 2e 0a 20 20 23 20 20 20 20 20 20 20 20 20 rt.. #
5050: 20 20 20 20 20 20 20 20 20 20 20 20 20 4b 53 52 KSR
5060: 20 66 6f 72 63 65 73 20 75 70 63 61 73 65 20 6f forces upcase o
5070: 66 20 6c 6f 77 65 72 20 63 61 73 65 20 6b 65 79 f lower case key
5080: 73 20 6f 6e 20 69 6e 70 75 74 2e 0a 20 20 23 20 s on input.. #
5090: 74 61 70 65 3a 20 20 20 74 64 2c 20 64 74 20 20 tape: td, dt
50a0: 20 20 20 20 20 74 64 20 69 73 20 74 68 65 20 54 td is the T
50b0: 44 38 45 20 44 45 43 74 61 70 65 20 64 65 76 69 D8E DECtape devi
50c0: 63 65 0a 20 20 23 20 20 20 20 20 20 20 20 20 20 ce. #
50d0: 20 20 20 20 20 20 20 20 20 20 20 20 64 74 20 69 dt i
50e0: 73 20 74 68 65 20 54 43 30 38 20 44 45 43 74 61 s the TC08 DECta
50f0: 70 65 20 64 65 76 69 63 65 0a 0a 20 20 64 65 66 pe device.. def
5100: 20 64 65 73 63 72 69 62 65 5f 64 65 76 5f 63 6f describe_dev_co
5110: 6e 66 69 67 20 28 73 65 6c 66 2c 20 6e 61 6d 65 nfig (self, name
5120: 29 3a 0a 20 20 20 20 69 66 20 6e 61 6d 65 20 3d ):. if name =
5130: 3d 20 22 74 61 70 65 22 3a 0a 20 20 20 20 20 20 = "tape":.
5140: 6c 69 6e 65 73 20 3d 20 73 65 6c 66 2e 64 6f 5f lines = self.do_
5150: 73 69 6d 68 5f 73 68 6f 77 28 22 64 74 22 29 0a simh_show("dt").
5160: 20 20 20 20 20 20 64 65 76 5f 73 74 61 74 75 73 dev_status
5170: 20 3d 20 73 65 6c 66 2e 70 61 72 73 65 5f 73 68 = self.parse_sh
5180: 6f 77 5f 74 61 70 65 5f 64 65 76 28 6c 69 6e 65 ow_tape_dev(line
5190: 73 29 0a 0a 20 20 20 20 20 20 69 66 20 64 65 76 s).. if dev
51a0: 5f 73 74 61 74 75 73 20 3d 3d 20 22 64 74 22 3a _status == "dt":
51b0: 20 72 65 74 75 72 6e 20 22 64 74 22 0a 20 20 20 return "dt".
51c0: 20 20 20 65 6c 73 65 3a 0a 20 20 20 20 20 20 20 else:.
51d0: 20 6c 69 6e 65 73 20 3d 20 73 65 6c 66 2e 64 6f lines = self.do
51e0: 5f 73 69 6d 68 5f 73 68 6f 77 28 22 74 64 22 29 _simh_show("td")
51f0: 0a 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 . return
5200: 73 65 6c 66 2e 70 61 72 73 65 5f 73 68 6f 77 5f self.parse_show_
5210: 74 61 70 65 5f 64 65 76 28 6c 69 6e 65 73 29 0a tape_dev(lines).
5220: 20 20 20 20 65 6c 69 66 20 6e 61 6d 65 20 3d 3d elif name ==
5230: 20 22 72 78 22 3a 0a 20 20 20 20 20 20 6c 69 6e "rx":. lin
5240: 65 73 20 3d 20 73 65 6c 66 2e 64 6f 5f 73 69 6d es = self.do_sim
5250: 68 5f 73 68 6f 77 28 22 72 78 22 29 0a 20 20 20 h_show("rx").
5260: 20 20 20 72 65 74 75 72 6e 20 73 65 6c 66 2e 70 return self.p
5270: 61 72 73 65 5f 73 68 6f 77 5f 72 78 5f 64 65 76 arse_show_rx_dev
5280: 28 6c 69 6e 65 73 29 0a 20 20 20 20 65 6c 69 66 (lines). elif
5290: 20 6e 61 6d 65 20 3d 3d 20 22 74 74 69 22 3a 0a name == "tti":.
52a0: 20 20 20 20 20 20 6c 69 6e 65 73 20 3d 20 73 65 lines = se
52b0: 6c 66 2e 64 6f 5f 73 69 6d 68 5f 73 68 6f 77 28 lf.do_simh_show(
52c0: 22 74 74 69 22 29 0a 20 20 20 20 20 20 72 65 74 "tti"). ret
52d0: 75 72 6e 20 73 65 6c 66 2e 70 61 72 73 65 5f 73 urn self.parse_s
52e0: 68 6f 77 5f 74 74 69 28 6c 69 6e 65 73 29 0a 20 how_tti(lines).
52f0: 20 20 20 65 6c 73 65 3a 20 72 65 74 75 72 6e 20 else: return
5300: 4e 6f 6e 65 0a 0a 20 20 20 20 20 20 0a 20 20 23 None.. . #
5310: 23 23 23 20 64 6f 5f 73 69 6d 68 5f 73 68 6f 77 ### do_simh_show
5320: 20 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ##############
5330: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
5340: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
5350: 23 23 23 23 23 0a 20 20 23 20 43 61 6c 6c 73 20 #####. # Calls
5360: 73 68 6f 77 20 6f 6e 20 74 68 65 20 64 65 76 69 show on the devi
5370: 63 65 20 6e 61 6d 65 2e 0a 20 20 23 20 52 65 74 ce name.. # Ret
5380: 75 72 6e 73 20 61 72 72 61 79 20 6f 66 20 6c 69 urns array of li
5390: 6e 65 73 20 66 72 6f 6d 20 6f 75 74 70 75 74 2e nes from output.
53a0: 0a 20 20 23 20 54 68 69 73 20 69 73 20 66 6f 63 . # This is foc
53b0: 75 73 65 64 20 6f 6e 20 4f 53 2f 38 20 64 65 76 used on OS/8 dev
53c0: 69 63 65 73 2e 0a 0a 20 20 64 65 66 20 64 6f 5f ices... def do_
53d0: 73 69 6d 68 5f 73 68 6f 77 20 28 73 65 6c 66 2c simh_show (self,
53e0: 20 6e 61 6d 65 29 3a 0a 20 20 20 20 73 75 70 70 name):. supp
53f0: 6f 72 74 65 64 5f 73 68 6f 77 73 20 3d 20 5b 22 orted_shows = ["
5400: 64 74 22 2c 20 22 74 64 22 2c 20 22 74 74 69 22 dt", "td", "tti"
5410: 2c 20 22 72 78 22 5d 0a 20 20 20 20 69 66 20 6e , "rx"]. if n
5420: 61 6d 65 20 6e 6f 74 20 69 6e 20 73 75 70 70 6f ame not in suppo
5430: 72 74 65 64 5f 73 68 6f 77 73 3a 20 72 65 74 75 rted_shows: retu
5440: 72 6e 20 4e 6f 6e 65 0a 20 20 20 20 0a 20 20 20 rn None. .
5450: 20 75 63 6e 61 6d 65 20 3d 20 6e 61 6d 65 2e 75 ucname = name.u
5460: 70 70 65 72 28 29 0a 20 20 20 20 73 65 6c 66 2e pper(). self.
5470: 73 69 6d 68 5f 73 65 6e 64 5f 6c 69 6e 65 28 22 simh_send_line("
5480: 73 68 6f 77 20 22 20 2b 20 6e 61 6d 65 29 0a 20 show " + name).
5490: 20 20 20 69 66 20 73 65 6c 66 2e 63 68 69 6c 64 if self.child
54a0: 5f 65 78 70 65 63 74 28 75 63 6e 61 6d 65 20 2b _expect(ucname +
54b0: 20 22 5c 73 2b 28 2e 2b 29 5c 72 22 29 20 3d 3d "\s+(.+)\r") ==
54c0: 20 2d 31 3a 20 72 65 74 75 72 6e 20 5b 5d 0a 20 -1: return [].
54d0: 20 20 20 6c 69 6e 65 73 20 3d 20 73 65 6c 66 2e lines = self.
54e0: 63 68 69 6c 64 5f 61 66 74 65 72 28 29 2e 73 70 child_after().sp
54f0: 6c 69 74 20 28 22 5c 72 22 29 0a 20 20 20 20 72 lit ("\r"). r
5500: 65 74 75 72 6e 20 6c 69 6e 65 73 0a 0a 0a 20 20 eturn lines...
5510: 23 23 23 23 20 70 61 72 73 65 5f 73 68 6f 77 5f #### parse_show_
5520: 74 61 70 65 5f 64 65 76 20 20 23 23 23 23 23 23 tape_dev ######
5530: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
5540: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
5550: 23 23 23 23 23 23 0a 20 20 23 20 52 65 74 75 72 ######. # Retur
5560: 6e 73 20 63 75 72 72 65 6e 74 20 73 74 61 74 65 ns current state
5570: 20 6f 66 20 44 45 43 74 61 70 65 20 73 75 70 70 of DECtape supp
5580: 6f 72 74 2e 0a 20 20 23 20 4f 6e 65 20 6f 66 3a ort.. # One of:
5590: 20 64 69 73 61 62 6c 65 64 2c 20 74 64 2c 20 64 disabled, td, d
55a0: 74 2c 20 6f 72 20 4e 6f 6e 65 20 69 66 20 70 61 t, or None if pa
55b0: 72 73 65 20 66 61 69 6c 73 2e 0a 0a 20 20 64 65 rse fails... de
55c0: 66 20 70 61 72 73 65 5f 73 68 6f 77 5f 74 61 70 f parse_show_tap
55d0: 65 5f 64 65 76 20 28 73 65 6c 66 2c 20 6c 69 6e e_dev (self, lin
55e0: 65 73 29 3a 0a 20 20 20 20 69 66 20 6c 69 6e 65 es):. if line
55f0: 73 20 3d 3d 20 4e 6f 6e 65 3a 20 72 65 74 75 72 s == None: retur
5600: 6e 20 4e 6f 6e 65 0a 20 20 20 20 69 73 5f 65 6e n None. is_en
5610: 61 62 6c 65 64 5f 72 65 20 3d 20 72 65 2e 63 6f abled_re = re.co
5620: 6d 70 69 6c 65 28 22 5e 28 54 44 7c 44 54 29 5c mpile("^(TD|DT)\
5630: 73 2b 28 64 69 73 61 62 6c 65 64 7c 28 64 65 76 s+(disabled|(dev
5640: 6e 6f 3d 5c 53 2b 2c 5c 73 28 5c 64 29 5c 73 2b no=\S+,\s(\d)\s+
5650: 75 6e 69 74 73 29 29 24 22 29 0a 20 20 20 20 6d units))$"). m
5660: 20 3d 20 72 65 2e 6d 61 74 63 68 28 69 73 5f 65 = re.match(is_e
5670: 6e 61 62 6c 65 64 5f 72 65 2c 20 6c 69 6e 65 73 nabled_re, lines
5680: 5b 30 5d 29 0a 0a 20 20 20 20 69 66 20 6d 20 3d [0]).. if m =
5690: 3d 20 4e 6f 6e 65 20 6f 72 20 6d 2e 67 72 6f 75 = None or m.grou
56a0: 70 28 31 29 20 3d 3d 20 4e 6f 6e 65 20 6f 72 20 p(1) == None or
56b0: 6d 2e 67 72 6f 75 70 28 32 29 20 3d 3d 20 4e 6f m.group(2) == No
56c0: 6e 65 3a 20 72 65 74 75 72 6e 20 4e 6f 6e 65 0a ne: return None.
56d0: 20 20 20 20 69 66 20 6d 2e 67 72 6f 75 70 28 32 if m.group(2
56e0: 29 20 3d 3d 20 22 64 69 73 61 62 6c 65 64 22 3a ) == "disabled":
56f0: 20 72 65 74 75 72 6e 20 22 64 69 73 61 62 6c 65 return "disable
5700: 64 22 0a 20 20 20 20 65 6c 69 66 20 6d 2e 67 72 d". elif m.gr
5710: 6f 75 70 28 31 29 20 3d 3d 20 22 54 44 22 3a 20 oup(1) == "TD":
5720: 72 65 74 75 72 6e 20 22 74 64 22 0a 20 20 20 20 return "td".
5730: 65 6c 69 66 20 6d 2e 67 72 6f 75 70 28 31 29 20 elif m.group(1)
5740: 3d 3d 20 22 44 54 22 3a 20 72 65 74 75 72 6e 20 == "DT": return
5750: 22 64 74 22 0a 20 20 20 20 65 6c 73 65 3a 20 72 "dt". else: r
5760: 65 74 75 72 6e 20 4e 6f 6e 65 0a 0a 0a 20 20 23 eturn None... #
5770: 23 23 23 20 70 61 72 73 65 5f 73 68 6f 77 5f 74 ### parse_show_t
5780: 61 70 65 5f 61 74 74 61 63 68 65 64 20 20 23 23 ape_attached ##
5790: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
57a0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
57b0: 23 23 23 23 23 23 0a 20 20 23 20 52 65 74 75 72 ######. # Retur
57c0: 6e 73 20 61 6e 20 6f 72 64 65 72 65 64 20 6c 69 ns an ordered li
57d0: 73 74 20 6f 66 20 66 69 6c 65 73 20 61 74 74 61 st of files atta
57e0: 63 68 65 64 20 6f 72 20 4e 6f 6e 65 20 69 66 20 ched or None if
57f0: 64 69 73 61 62 6c 65 64 2e 0a 20 20 64 65 66 20 disabled.. def
5800: 70 61 72 73 65 5f 73 68 6f 77 5f 74 61 70 65 5f parse_show_tape_
5810: 61 74 74 61 63 68 65 64 20 28 73 65 6c 66 2c 20 attached (self,
5820: 6c 69 6e 65 73 29 3a 0a 20 20 20 20 69 66 20 6c lines):. if l
5830: 69 6e 65 73 20 3d 3d 20 4e 6f 6e 65 3a 20 72 65 ines == None: re
5840: 74 75 72 6e 20 4e 6f 6e 65 0a 20 20 20 20 69 66 turn None. if
5850: 20 6c 65 6e 28 6c 69 6e 65 73 29 20 3c 20 32 3a len(lines) < 2:
5860: 20 72 65 74 75 72 6e 20 4e 6f 6e 65 0a 20 20 20 return None.
5870: 20 61 74 74 61 63 68 65 64 20 3d 20 7b 7d 0a 20 attached = {}.
5880: 20 20 20 61 74 74 61 63 68 6d 65 6e 74 5f 72 65 attachment_re
5890: 20 3d 20 72 65 2e 63 6f 6d 70 69 6c 65 28 22 5e = re.compile("^
58a0: 5c 73 2b 28 28 28 44 54 7c 54 44 29 28 5c 64 29 \s+(((DT|TD)(\d)
58b0: 28 2e 2b 29 2c 5c 73 2b 28 6e 6f 74 5c 73 2b 61 (.+),\s+(not\s+a
58c0: 74 74 61 63 68 65 64 7c 61 74 74 61 63 68 65 64 ttached|attached
58d0: 5c 73 2b 74 6f 5c 73 2b 28 5c 53 2b 29 29 2c 28 \s+to\s+(\S+)),(
58e0: 2e 2b 29 29 7c 31 32 62 29 24 22 29 0a 20 20 20 .+))|12b)$").
58f0: 20 66 6f 72 20 6c 69 6e 65 20 69 6e 20 6c 69 6e for line in lin
5900: 65 73 5b 31 3a 5d 3a 0a 20 20 20 20 20 20 6d 20 es[1:]:. m
5910: 3d 20 72 65 2e 6d 61 74 63 68 28 61 74 74 61 63 = re.match(attac
5920: 68 6d 65 6e 74 5f 72 65 2c 20 6c 69 6e 65 29 0a hment_re, line).
5930: 20 20 20 20 20 20 69 66 20 6d 20 3d 3d 20 4e 6f if m == No
5940: 6e 65 20 6f 72 20 6d 2e 67 72 6f 75 70 28 31 29 ne or m.group(1)
5950: 20 3d 3d 20 4e 6f 6e 65 20 6f 72 20 6d 2e 67 72 == None or m.gr
5960: 6f 75 70 28 31 29 20 3d 3d 20 22 31 32 62 22 3a oup(1) == "12b":
5970: 20 63 6f 6e 74 69 6e 75 65 0a 20 20 20 20 20 20 continue.
5980: 66 69 6c 65 6e 61 6d 65 20 3d 20 6d 2e 67 72 6f filename = m.gro
5990: 75 70 28 37 29 0a 20 20 20 20 20 20 69 66 20 66 up(7). if f
59a0: 69 6c 65 6e 61 6d 65 20 3d 3d 20 4e 6f 6e 65 3a ilename == None:
59b0: 20 66 69 6c 65 6e 61 6d 65 20 3d 20 22 22 0a 20 filename = "".
59c0: 20 20 20 20 20 61 74 74 61 63 68 65 64 5b 6d 2e attached[m.
59d0: 67 72 6f 75 70 28 34 29 5d 20 3d 20 66 69 6c 65 group(4)] = file
59e0: 6e 61 6d 65 0a 20 20 20 20 72 65 74 75 72 6e 20 name. return
59f0: 61 74 74 61 63 68 65 64 0a 0a 20 20 23 23 23 23 attached.. ####
5a00: 20 64 6f 5f 70 72 69 6e 74 5f 6c 69 6e 65 73 20 do_print_lines
5a10: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
5a20: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
5a30: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
5a40: 23 23 23 0a 20 20 23 20 44 65 62 75 67 67 69 6e ###. # Debuggin
5a50: 67 20 61 69 64 2e 20 50 72 69 6e 74 73 20 77 68 g aid. Prints wh
5a60: 61 74 20 77 65 20 70 61 72 73 65 64 20 6f 75 74 at we parsed out
5a70: 20 6f 66 20 63 68 69 6c 64 5f 61 66 74 65 72 2e of child_after.
5a80: 0a 20 20 64 65 66 20 64 6f 5f 70 72 69 6e 74 5f . def do_print_
5a90: 6c 69 6e 65 73 20 28 73 65 6c 66 2c 20 6c 69 6e lines (self, lin
5aa0: 65 73 29 3a 0a 20 20 20 20 66 6f 72 20 6c 69 6e es):. for lin
5ab0: 65 20 69 6e 20 6c 69 6e 65 73 3a 0a 20 20 20 20 e in lines:.
5ac0: 20 20 70 72 69 6e 74 28 6c 69 6e 65 29 0a 0a 20 print(line)..
5ad0: 20 23 23 23 23 20 73 69 6d 68 5f 63 6f 6e 66 69 #### simh_confi
5ae0: 67 75 72 65 20 72 6f 75 74 69 6e 65 73 20 23 23 gure routines ##
5af0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
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 0a 20 20 23 20 54 68 65 73 #######. # Thes
5b20: 65 20 72 6f 75 74 69 6e 65 73 20 61 66 66 65 63 e routines affec
5b30: 74 20 74 68 65 20 73 74 61 74 65 20 6f 66 20 64 t the state of d
5b40: 65 76 69 63 65 20 63 6f 6e 66 69 67 75 72 61 74 evice configurat
5b50: 69 6f 6e 20 69 6e 20 53 49 4d 48 2e 0a 20 20 23 ion in SIMH.. #
5b60: 20 54 68 65 79 20 61 72 65 20 69 6e 74 65 6e 64 They are intend
5b70: 65 64 20 61 73 20 72 6f 62 75 73 74 20 77 61 79 ed as robust way
5b80: 73 20 74 6f 20 74 6f 67 67 6c 65 20 62 65 74 77 s to toggle betw
5b90: 65 65 6e 20 69 6e 63 6f 6d 70 61 74 69 62 6c 65 een incompatible
5ba0: 0a 20 20 23 20 63 6f 6e 66 69 67 75 72 61 74 69 . # configurati
5bb0: 6f 6e 73 20 6f 66 20 53 49 4d 48 3a 0a 20 20 23 ons of SIMH:. #
5bc0: 20 43 68 6f 69 63 65 20 6f 66 20 54 44 38 45 20 Choice of TD8E
5bd0: 6f 72 20 54 43 30 38 20 44 45 43 74 61 70 65 20 or TC08 DECtape
5be0: 28 53 49 4d 48 20 74 64 20 61 6e 64 20 64 74 20 (SIMH td and dt
5bf0: 64 65 76 69 63 65 73 29 2e 0a 20 20 23 20 43 68 devices).. # Ch
5c00: 6f 69 63 65 20 6f 66 20 52 58 30 31 20 6f 72 20 oice of RX01 or
5c10: 52 58 30 32 20 46 6c 6f 70 70 79 20 65 6d 75 6c RX02 Floppy emul
5c20: 61 74 69 6f 6e 2e 0a 20 20 23 20 54 68 65 20 53 ation.. # The S
5c30: 49 4d 48 20 72 78 20 64 65 76 69 63 65 20 73 65 IMH rx device se
5c40: 74 73 20 52 58 38 45 20 66 6f 72 20 52 58 30 31 ts RX8E for RX01
5c50: 2c 20 61 6e 64 20 52 58 32 38 20 66 6f 72 20 52 , and RX28 for R
5c60: 58 30 32 2e 20 20 0a 20 20 23 20 43 68 6f 69 63 X02. . # Choic
5c70: 65 20 6f 66 20 4b 53 52 20 6f 72 20 37 62 69 74 e of KSR or 7bit
5c80: 20 63 6f 6e 73 6f 6c 65 20 63 6f 6e 66 69 67 75 console configu
5c90: 72 61 74 69 6f 6e 2e 0a 20 20 23 0a 20 20 23 20 ration.. #. #
5ca0: 57 68 65 6e 20 72 65 2d 63 6f 6e 66 69 67 75 72 When re-configur
5cb0: 69 6e 67 20 64 74 2c 20 64 74 2c 20 61 6e 64 20 ing dt, dt, and
5cc0: 72 78 20 64 65 76 69 63 65 73 2c 20 61 6e 79 20 rx devices, any
5cd0: 61 74 74 61 63 68 65 64 0a 20 20 23 20 69 6d 61 attached. # ima
5ce0: 67 65 73 20 61 72 65 20 64 65 74 61 63 68 65 64 ges are detached
5cf0: 20 62 65 66 6f 72 65 20 72 65 63 6f 6e 66 69 67 before reconfig
5d00: 75 72 61 74 69 6f 6e 20 69 73 20 61 74 74 65 6d uration is attem
5d10: 70 74 65 64 2e 0a 20 20 23 20 28 53 49 4d 48 20 pted.. # (SIMH
5d20: 65 72 72 6f 72 73 20 6f 75 74 20 69 66 20 79 6f errors out if yo
5d30: 75 20 64 6f 6e 27 74 20 64 65 74 61 63 68 20 74 u don't detach t
5d40: 68 65 6d 2e 29 0a 20 20 23 0a 20 20 23 20 54 68 hem.). #. # Th
5d50: 65 20 63 68 65 63 6b 20 74 6f 20 73 65 65 20 69 e check to see i
5d60: 66 20 74 68 65 20 63 68 61 6e 67 65 20 69 73 20 f the change is
5d70: 75 6e 6e 65 63 65 73 73 61 72 79 2e 0a 20 20 23 unnecessary.. #
5d80: 20 46 6f 72 20 6e 6f 77 20 74 68 65 79 20 72 65 For now they re
5d90: 74 75 72 6e 20 4e 6f 6e 65 20 69 66 20 6e 6f 20 turn None if no
5da0: 63 68 61 6e 67 65 20 6e 65 63 65 73 73 61 72 79 change necessary
5db0: 2e 0a 20 20 23 0a 20 20 23 20 41 66 74 65 72 20 .. #. # After
5dc0: 72 65 2d 63 6f 6e 66 69 67 75 72 69 6e 67 20 74 re-configuring t
5dd0: 68 65 20 64 65 76 69 63 65 2c 20 74 68 65 20 53 he device, the S
5de0: 49 4d 48 20 73 68 6f 77 20 63 6f 6d 6d 61 6e 64 IMH show command
5df0: 20 69 73 20 75 73 65 64 0a 20 20 23 20 74 6f 20 is used. # to
5e00: 63 6f 6e 66 69 72 6d 20 74 68 65 20 72 65 2d 63 confirm the re-c
5e10: 6f 6e 66 69 67 75 72 61 74 69 6f 6e 20 77 61 73 onfiguration was
5e20: 20 73 75 63 63 65 73 73 66 75 6c 2e 0a 20 20 23 successful.. #
5e30: 0a 20 20 23 20 49 6e 20 66 75 74 75 72 65 2c 20 . # In future,
5e40: 77 65 20 73 68 6f 75 6c 64 20 61 64 64 20 65 78 we should add ex
5e50: 63 65 70 74 69 6f 6e 20 68 61 6e 64 6c 69 6e 67 ception handling
5e60: 20 66 6f 72 20 6e 6f 20 63 68 61 6e 67 65 20 6e for no change n
5e70: 65 63 65 73 73 61 72 79 2e 0a 20 20 23 20 46 6f ecessary.. # Fo
5e80: 72 20 6e 6f 77 2c 20 72 65 74 75 72 6e 20 54 72 r now, return Tr
5e90: 75 65 20 69 66 20 74 68 65 20 63 68 61 6e 67 65 ue if the change
5ea0: 20 77 61 73 20 73 75 63 63 65 73 73 66 75 6c 20 was successful
5eb0: 61 6e 64 20 46 61 6c 73 65 20 69 66 20 6e 6f 74 and False if not
5ec0: 2e 0a 0a 0a 20 20 64 65 66 20 73 65 74 5f 74 61 .... def set_ta
5ed0: 70 65 5f 63 6f 6e 66 69 67 20 28 73 65 6c 66 2c pe_config (self,
5ee0: 20 74 6f 5f 74 61 70 65 29 3a 0a 20 20 20 20 69 to_tape):. i
5ef0: 66 20 74 6f 5f 74 61 70 65 20 3d 3d 20 22 64 74 f to_tape == "dt
5f00: 22 3a 20 66 72 6f 6d 5f 74 61 70 65 20 3d 20 22 ": from_tape = "
5f10: 74 64 22 0a 20 20 20 20 65 6c 69 66 20 74 6f 5f td". elif to_
5f20: 74 61 70 65 20 3d 3d 20 22 74 64 22 3a 20 66 72 tape == "td": fr
5f30: 6f 6d 5f 74 61 70 65 20 3d 20 22 64 74 22 0a 20 om_tape = "dt".
5f40: 20 20 20 65 6c 73 65 3a 0a 20 20 20 20 20 20 70 else:. p
5f50: 72 69 6e 74 28 22 43 61 6e 6e 6f 74 20 73 65 74 rint("Cannot set
5f60: 5f 74 61 70 65 5f 63 6f 6e 66 69 67 20 66 6f 72 _tape_config for
5f70: 20 22 20 2b 20 74 6f 5f 74 61 70 65 29 0a 20 20 " + to_tape).
5f80: 20 20 20 20 72 65 74 75 72 6e 20 46 61 6c 73 65 return False
5f90: 0a 0a 20 20 20 20 69 66 20 73 65 6c 66 2e 76 65 .. if self.ve
5fa0: 72 62 6f 73 65 3a 0a 20 20 20 20 20 20 70 72 69 rbose:. pri
5fb0: 6e 74 28 22 44 69 73 61 62 6c 65 3a 20 22 20 2b nt("Disable: " +
5fc0: 20 66 72 6f 6d 5f 74 61 70 65 20 2b 20 22 2c 20 from_tape + ",
5fd0: 61 6e 64 20 65 6e 61 62 6c 65 3a 20 22 20 2b 20 and enable: " +
5fe0: 74 6f 5f 74 61 70 65 29 0a 20 20 20 20 0a 20 20 to_tape). .
5ff0: 20 20 6c 69 6e 65 73 20 3d 20 73 65 6c 66 2e 64 lines = self.d
6000: 6f 5f 73 69 6d 68 5f 73 68 6f 77 28 66 72 6f 6d o_simh_show(from
6010: 5f 74 61 70 65 29 0a 20 20 20 20 66 72 6f 6d 5f _tape). from_
6020: 73 74 61 74 75 73 20 3d 20 73 65 6c 66 2e 70 61 status = self.pa
6030: 72 73 65 5f 73 68 6f 77 5f 74 61 70 65 5f 64 65 rse_show_tape_de
6040: 76 28 6c 69 6e 65 73 29 0a 0a 20 20 20 20 69 66 v(lines).. if
6050: 20 66 72 6f 6d 5f 73 74 61 74 75 73 20 3d 3d 20 from_status ==
6060: 4e 6f 6e 65 3a 0a 20 20 20 20 20 20 70 72 69 6e None:. prin
6070: 74 28 22 64 6f 5f 74 61 70 65 5f 63 68 61 6e 67 t("do_tape_chang
6080: 65 3a 20 54 72 6f 75 62 6c 65 20 70 61 72 73 69 e: Trouble parsi
6090: 6e 67 20 5c 27 73 68 6f 77 20 22 20 2b 20 66 72 ng \'show " + fr
60a0: 6f 6d 5f 74 61 70 65 20 2b 20 5c 0a 20 20 20 20 om_tape + \.
60b0: 20 20 20 20 20 20 22 5c 27 20 6f 75 74 70 75 74 "\' output
60c0: 20 66 72 6f 6d 20 73 69 6d 68 2e 20 47 69 76 69 from simh. Givi
60d0: 6e 67 20 75 70 20 6f 6e 3a 22 29 0a 20 20 20 20 ng up on:").
60e0: 20 20 73 65 6c 66 2e 64 6f 5f 70 72 69 6e 74 5f self.do_print_
60f0: 6c 69 6e 65 73 20 28 6c 69 6e 65 73 29 0a 20 20 lines (lines).
6100: 20 20 20 20 72 65 74 75 72 6e 20 46 61 6c 73 65 return False
6110: 0a 0a 20 20 20 20 69 66 20 66 72 6f 6d 5f 73 74 .. if from_st
6120: 61 74 75 73 20 3d 3d 20 22 64 69 73 61 62 6c 65 atus == "disable
6130: 64 22 3a 0a 20 20 20 20 20 20 70 72 69 6e 74 28 d":. print(
6140: 66 72 6f 6d 5f 74 61 70 65 20 2b 20 22 20 61 6c from_tape + " al
6150: 72 65 61 64 79 20 69 73 20 64 69 73 61 62 6c 65 ready is disable
6160: 64 2e 22 29 0a 20 20 20 20 65 6c 73 65 3a 0a 20 d."). else:.
6170: 20 20 20 20 20 61 74 74 61 63 68 65 64 5f 66 72 attached_fr
6180: 6f 6d 20 3d 20 73 65 6c 66 2e 70 61 72 73 65 5f om = self.parse_
6190: 73 68 6f 77 5f 74 61 70 65 5f 61 74 74 61 63 68 show_tape_attach
61a0: 65 64 28 6c 69 6e 65 73 29 0a 20 20 20 20 20 20 ed(lines).
61b0: 69 66 20 61 74 74 61 63 68 65 64 5f 66 72 6f 6d if attached_from
61c0: 20 3d 3d 20 4e 6f 6e 65 3a 0a 20 20 20 20 20 20 == None:.
61d0: 20 20 70 72 69 6e 74 28 22 64 6f 5f 74 61 70 65 print("do_tape
61e0: 5f 63 68 61 6e 67 65 3a 20 54 72 6f 75 62 6c 65 _change: Trouble
61f0: 20 70 61 72 73 69 6e 67 20 5c 27 73 68 6f 77 20 parsing \'show
6200: 22 20 2b 20 66 72 6f 6d 5f 74 61 70 65 20 2b 20 " + from_tape +
6210: 5c 0a 20 20 20 20 20 20 20 20 20 20 20 20 22 5c \. "\
6220: 27 20 6f 75 74 70 75 74 20 66 72 6f 6d 20 73 69 ' output from si
6230: 6d 68 2e 20 47 69 76 69 6e 67 20 75 70 20 6f 6e mh. Giving up on
6240: 3a 22 29 0a 20 20 20 20 20 20 20 20 73 65 6c 66 :"). self
6250: 2e 64 6f 5f 70 72 69 6e 74 5f 6c 69 6e 65 73 20 .do_print_lines
6260: 28 6c 69 6e 65 73 29 0a 20 20 20 20 20 20 20 20 (lines).
6270: 72 65 74 75 72 6e 20 46 61 6c 73 65 0a 20 20 20 return False.
6280: 20 20 20 65 6c 73 65 3a 0a 20 20 20 20 20 20 20 else:.
6290: 20 66 6f 72 20 75 6e 69 74 20 69 6e 20 61 74 74 for unit in att
62a0: 61 63 68 65 64 5f 66 72 6f 6d 2e 6b 65 79 73 28 ached_from.keys(
62b0: 29 3a 0a 20 20 20 20 20 20 20 20 20 20 69 66 20 ):. if
62c0: 61 74 74 61 63 68 65 64 5f 66 72 6f 6d 5b 75 6e attached_from[un
62d0: 69 74 5d 20 21 3d 20 22 22 3a 0a 20 20 20 20 20 it] != "":.
62e0: 20 20 20 20 20 20 20 64 65 74 5f 63 6f 6d 6d 20 det_comm
62f0: 3d 20 22 64 65 74 20 22 20 2b 20 66 72 6f 6d 5f = "det " + from_
6300: 74 61 70 65 20 2b 20 75 6e 69 74 0a 20 20 20 20 tape + unit.
6310: 20 20 20 20 20 20 20 20 69 66 20 73 65 6c 66 2e if self.
6320: 76 65 72 62 6f 73 65 3a 0a 20 20 20 20 20 20 20 verbose:.
6330: 20 20 20 20 20 20 20 70 72 69 6e 74 28 64 65 74 print(det
6340: 5f 63 6f 6d 6d 20 2b 20 22 28 48 61 64 3a 20 22 _comm + "(Had: "
6350: 20 2b 20 61 74 74 61 63 68 65 64 5f 66 72 6f 6d + attached_from
6360: 5b 75 6e 69 74 5d 20 2b 20 22 29 22 29 0a 20 20 [unit] + ")").
6370: 20 20 20 20 20 20 20 20 20 20 72 65 70 6c 79 20 reply
6380: 3d 20 73 65 6c 66 2e 73 69 6d 68 5f 63 6d 64 28 = self.simh_cmd(
6390: 64 65 74 5f 63 6f 6d 6d 29 0a 20 20 20 20 20 20 det_comm).
63a0: 20 20 20 20 20 20 73 65 6c 66 2e 73 69 6d 68 5f self.simh_
63b0: 74 65 73 74 5f 72 65 73 75 6c 74 28 72 65 70 6c test_result(repl
63c0: 79 2c 20 22 50 72 6f 6d 70 74 22 2c 20 22 73 65 y, "Prompt", "se
63d0: 74 5f 74 61 70 65 5f 63 6f 6e 66 69 67 3a 20 22 t_tape_config: "
63e0: 20 2b 20 64 65 74 5f 63 6f 6d 29 0a 20 20 20 20 + det_com).
63f0: 20 20 20 20 72 65 70 6c 79 20 3d 20 73 65 6c 66 reply = self
6400: 2e 73 69 6d 68 5f 63 6d 64 28 22 73 65 74 20 22 .simh_cmd("set "
6410: 20 2b 20 66 72 6f 6d 5f 74 61 70 65 20 2b 20 22 + from_tape + "
6420: 20 64 69 73 61 62 6c 65 64 22 29 0a 20 20 20 20 disabled").
6430: 20 20 20 20 73 65 6c 66 2e 73 69 6d 68 5f 74 65 self.simh_te
6440: 73 74 5f 72 65 73 75 6c 74 28 72 65 70 6c 79 2c st_result(reply,
6450: 20 22 50 72 6f 6d 70 74 22 2c 20 22 73 65 74 5f "Prompt", "set_
6460: 74 61 70 65 5f 63 6f 6e 66 69 67 20 64 69 73 61 tape_config disa
6470: 62 6c 65 20 22 20 2b 20 66 72 6f 6d 5f 74 61 70 ble " + from_tap
6480: 65 29 0a 0a 20 20 20 20 6c 69 6e 65 73 20 3d 20 e).. lines =
6490: 73 65 6c 66 2e 64 6f 5f 73 69 6d 68 5f 73 68 6f self.do_simh_sho
64a0: 77 28 74 6f 5f 74 61 70 65 29 0a 20 20 20 20 74 w(to_tape). t
64b0: 6f 5f 73 74 61 74 75 73 20 3d 20 73 65 6c 66 2e o_status = self.
64c0: 70 61 72 73 65 5f 73 68 6f 77 5f 74 61 70 65 5f parse_show_tape_
64d0: 64 65 76 28 6c 69 6e 65 73 29 0a 0a 20 20 20 20 dev(lines)..
64e0: 69 66 20 74 6f 5f 73 74 61 74 75 73 20 3d 3d 20 if to_status ==
64f0: 4e 6f 6e 65 3a 0a 20 20 20 20 20 20 70 72 69 6e None:. prin
6500: 74 28 22 64 6f 5f 74 61 70 65 5f 63 68 61 6e 67 t("do_tape_chang
6510: 65 3a 20 54 72 6f 75 62 6c 65 20 70 61 72 73 69 e: Trouble parsi
6520: 6e 67 20 5c 27 73 68 6f 77 20 22 20 2b 20 74 6f ng \'show " + to
6530: 5f 74 61 70 65 20 2b 20 5c 0a 20 20 20 20 20 20 _tape + \.
6540: 20 20 20 20 22 5c 27 20 6f 75 74 70 75 74 20 66 "\' output f
6550: 72 6f 6d 20 73 69 6d 68 2e 20 47 69 76 69 6e 67 rom simh. Giving
6560: 20 75 70 20 6f 6e 3a 22 29 0a 20 20 20 20 20 20 up on:").
6570: 73 65 6c 66 2e 64 6f 5f 70 72 69 6e 74 5f 6c 69 self.do_print_li
6580: 6e 65 73 20 28 6c 69 6e 65 73 29 0a 20 20 20 20 nes (lines).
6590: 20 20 72 65 74 75 72 6e 20 46 61 6c 73 65 0a 20 return False.
65a0: 20 20 20 65 6c 69 66 20 74 6f 5f 73 74 61 74 75 elif to_statu
65b0: 73 20 21 3d 20 22 64 69 73 61 62 6c 65 64 22 3a s != "disabled":
65c0: 0a 20 20 20 20 20 20 70 72 69 6e 74 28 74 6f 5f . print(to_
65d0: 74 61 70 65 20 2b 20 22 20 61 6c 72 65 61 64 79 tape + " already
65e0: 20 69 73 20 65 6e 61 62 6c 65 64 2e 22 29 0a 20 is enabled.").
65f0: 20 20 20 65 6c 73 65 3a 0a 20 20 20 20 20 20 72 else:. r
6600: 65 70 6c 79 20 3d 20 73 65 6c 66 2e 73 69 6d 68 eply = self.simh
6610: 5f 63 6d 64 28 22 73 65 74 20 22 20 2b 20 74 6f _cmd("set " + to
6620: 5f 74 61 70 65 20 2b 20 22 20 65 6e 61 62 6c 65 _tape + " enable
6630: 64 22 29 0a 20 20 20 20 20 20 73 65 6c 66 2e 73 d"). self.s
6640: 69 6d 68 5f 74 65 73 74 5f 72 65 73 75 6c 74 28 imh_test_result(
6650: 72 65 70 6c 79 2c 20 22 50 72 6f 6d 70 74 22 2c reply, "Prompt",
6660: 20 22 73 65 74 5f 74 61 70 65 5f 63 6f 6e 66 69 "set_tape_confi
6670: 67 20 65 6e 61 62 6c 65 20 22 20 2b 20 74 6f 5f g enable " + to_
6680: 74 61 70 65 29 0a 0a 20 20 20 20 23 20 54 65 73 tape).. # Tes
6690: 74 20 74 6f 20 63 6f 6e 66 69 72 6d 20 74 6f 5f t to confirm to_
66a0: 74 61 70 65 20 69 73 20 6e 6f 77 20 65 6e 61 62 tape is now enab
66b0: 6c 65 64 2e 0a 0a 20 20 20 20 6c 69 6e 65 73 20 led... lines
66c0: 3d 20 73 65 6c 66 2e 64 6f 5f 73 69 6d 68 5f 73 = self.do_simh_s
66d0: 68 6f 77 28 74 6f 5f 74 61 70 65 29 0a 20 20 20 how(to_tape).
66e0: 20 74 6f 5f 73 74 61 74 75 73 20 3d 20 73 65 6c to_status = sel
66f0: 66 2e 70 61 72 73 65 5f 73 68 6f 77 5f 74 61 70 f.parse_show_tap
6700: 65 5f 64 65 76 28 6c 69 6e 65 73 29 0a 0a 20 20 e_dev(lines)..
6710: 20 20 69 66 20 74 6f 5f 73 74 61 74 75 73 20 3d if to_status =
6720: 3d 20 4e 6f 6e 65 3a 0a 20 20 20 20 20 20 70 72 = None:. pr
6730: 69 6e 74 28 22 46 61 69 6c 65 64 20 65 6e 61 62 int("Failed enab
6740: 6c 65 20 6f 66 20 22 20 2b 20 74 6f 5f 74 61 70 le of " + to_tap
6750: 65 20 2b 20 5c 0a 20 20 20 20 20 20 20 20 20 20 e + \.
6760: 22 2e 20 50 61 72 73 65 20 66 61 69 6c 20 6f 6e ". Parse fail on
6770: 20 5c 27 73 68 6f 77 20 22 20 2b 20 74 6f 5f 74 \'show " + to_t
6780: 61 70 65 20 2b 20 22 5c 27 2e 20 47 6f 74 3a 22 ape + "\'. Got:"
6790: 29 0a 20 20 20 20 20 20 73 65 6c 66 2e 64 6f 5f ). self.do_
67a0: 70 72 69 6e 74 5f 6c 69 6e 65 73 20 28 6c 69 6e print_lines (lin
67b0: 65 73 29 0a 20 20 20 20 20 20 72 65 74 75 72 6e es). return
67c0: 20 46 61 6c 73 65 0a 20 20 20 20 65 6c 69 66 20 False. elif
67d0: 74 6f 5f 73 74 61 74 75 73 20 3d 3d 20 22 64 69 to_status == "di
67e0: 73 61 62 6c 65 64 22 3a 0a 20 20 20 20 20 20 70 sabled":. p
67f0: 72 69 6e 74 28 22 46 61 69 6c 65 64 20 65 6e 61 rint("Failed ena
6800: 62 6c 65 20 6f 66 20 22 20 2b 20 74 6f 5f 74 61 ble of " + to_ta
6810: 70 65 20 2b 20 22 2e 20 44 65 76 69 63 65 20 73 pe + ". Device s
6820: 74 69 6c 6c 20 64 69 73 61 62 6c 65 64 2e 22 29 till disabled.")
6830: 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 46 61 . return Fa
6840: 6c 73 65 0a 20 20 20 20 65 6c 73 65 3a 20 0a 20 lse. else: .
6850: 20 20 20 20 20 72 65 74 75 72 6e 20 54 72 75 65 return True
6860: 0a 0a 0a 20 20 23 23 23 23 20 70 61 72 73 65 5f ... #### parse_
6870: 73 68 6f 77 5f 72 78 5f 64 65 76 20 23 23 23 23 show_rx_dev ####
6880: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
6890: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
68a0: 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 23 20 ###########. #
68b0: 53 68 6f 77 20 74 68 65 20 72 78 20 64 65 76 69 Show the rx devi
68c0: 63 65 20 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e ce configuration
68d0: 2e 0a 0a 20 20 64 65 66 20 70 61 72 73 65 5f 73 ... def parse_s
68e0: 68 6f 77 5f 72 78 5f 64 65 76 20 28 73 65 6c 66 how_rx_dev (self
68f0: 2c 20 6c 69 6e 65 73 29 3a 0a 20 20 20 20 69 66 , lines):. if
6900: 20 6c 69 6e 65 73 20 3d 3d 20 4e 6f 6e 65 3a 20 lines == None:
6910: 72 65 74 75 72 6e 20 4e 6f 6e 65 0a 20 20 20 20 return None.
6920: 69 73 5f 65 6e 61 62 6c 65 64 5f 72 65 20 3d 20 is_enabled_re =
6930: 72 65 2e 63 6f 6d 70 69 6c 65 28 22 5e 5c 73 2a re.compile("^\s*
6940: 28 52 58 29 5c 73 2b 28 64 69 73 61 62 6c 65 64 (RX)\s+(disabled
6950: 7c 28 28 52 58 38 45 7c 52 58 32 38 29 2c 5c 73 |((RX8E|RX28),\s
6960: 2b 64 65 76 6e 6f 3d 5c 53 2b 2c 5c 73 2b 28 5c +devno=\S+,\s+(\
6970: 64 29 5c 73 2b 75 6e 69 74 73 29 29 24 22 29 0a d)\s+units))$").
6980: 20 20 20 20 6d 20 3d 20 72 65 2e 6d 61 74 63 68 m = re.match
6990: 28 69 73 5f 65 6e 61 62 6c 65 64 5f 72 65 2c 20 (is_enabled_re,
69a0: 6c 69 6e 65 73 5b 30 5d 29 0a 20 20 20 20 69 66 lines[0]). if
69b0: 20 6d 20 3d 3d 20 4e 6f 6e 65 20 6f 72 20 6d 2e m == None or m.
69c0: 67 72 6f 75 70 28 32 29 20 3d 3d 20 4e 6f 6e 65 group(2) == None
69d0: 3a 20 72 65 74 75 72 6e 20 4e 6f 6e 65 0a 20 20 : return None.
69e0: 20 20 69 66 20 6d 2e 67 72 6f 75 70 28 32 29 20 if m.group(2)
69f0: 3d 3d 20 22 64 69 73 61 62 6c 65 64 22 3a 20 72 == "disabled": r
6a00: 65 74 75 72 6e 20 22 64 69 73 61 62 6c 65 64 22 eturn "disabled"
6a10: 0a 20 20 20 20 72 65 74 75 72 6e 20 6d 2e 67 72 . return m.gr
6a20: 6f 75 70 28 34 29 0a 0a 0a 20 20 20 23 23 23 23 oup(4)... ####
6a30: 20 70 61 72 73 65 5f 73 68 6f 77 5f 72 78 5f 61 parse_show_rx_a
6a40: 74 74 61 63 68 65 64 20 23 23 23 23 23 23 23 23 ttached ########
6a50: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
6a60: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
6a70: 23 23 0a 20 20 23 20 52 65 74 75 72 6e 73 20 61 ##. # Returns a
6a80: 6e 20 6f 72 64 65 72 65 64 20 6c 69 73 74 20 6f n ordered list o
6a90: 66 20 66 69 6c 65 73 20 61 74 74 61 63 68 65 64 f files attached
6aa0: 20 6f 72 20 4e 6f 6e 65 20 69 66 20 64 69 73 61 or None if disa
6ab0: 62 6c 65 64 2e 0a 0a 20 20 64 65 66 20 70 61 72 bled... def par
6ac0: 73 65 5f 73 68 6f 77 5f 72 78 5f 61 74 74 61 63 se_show_rx_attac
6ad0: 68 65 64 20 28 73 65 6c 66 2c 20 6c 69 6e 65 73 hed (self, lines
6ae0: 29 3a 0a 20 20 20 20 69 66 20 6c 65 6e 28 6c 69 ):. if len(li
6af0: 6e 65 73 29 20 3c 20 32 3a 20 72 65 74 75 72 6e nes) < 2: return
6b00: 20 4e 6f 6e 65 0a 20 20 20 20 61 74 74 61 63 68 None. attach
6b10: 65 64 20 3d 20 7b 7d 0a 20 20 20 20 61 74 74 61 ed = {}. atta
6b20: 63 68 6d 65 6e 74 5f 72 65 20 3d 20 72 65 2e 63 chment_re = re.c
6b30: 6f 6d 70 69 6c 65 28 22 5e 5c 73 2b 28 28 28 52 ompile("^\s+(((R
6b40: 58 29 28 5c 64 29 28 2e 2b 29 2c 5c 73 2b 28 6e X)(\d)(.+),\s+(n
6b50: 6f 74 5c 73 2b 61 74 74 61 63 68 65 64 7c 61 74 ot\s+attached|at
6b60: 74 61 63 68 65 64 5c 73 2b 74 6f 5c 73 2b 28 5c tached\s+to\s+(\
6b70: 53 2b 29 29 2c 28 2e 2b 29 29 7c 61 75 74 6f 73 S+)),(.+))|autos
6b80: 69 7a 65 29 24 22 29 0a 20 20 20 20 66 6f 72 20 ize)$"). for
6b90: 6c 69 6e 65 20 69 6e 20 6c 69 6e 65 73 5b 31 3a line in lines[1:
6ba0: 5d 3a 0a 20 20 20 20 20 20 6d 20 3d 20 72 65 2e ]:. m = re.
6bb0: 6d 61 74 63 68 28 61 74 74 61 63 68 6d 65 6e 74 match(attachment
6bc0: 5f 72 65 2c 20 6c 69 6e 65 29 0a 20 20 20 20 20 _re, line).
6bd0: 20 69 66 20 6d 20 3d 3d 20 4e 6f 6e 65 20 6f 72 if m == None or
6be0: 20 6d 2e 67 72 6f 75 70 28 31 29 20 3d 3d 20 4e m.group(1) == N
6bf0: 6f 6e 65 20 6f 72 20 6d 2e 67 72 6f 75 70 28 31 one or m.group(1
6c00: 29 20 3d 3d 20 22 61 75 74 6f 73 69 7a 65 22 3a ) == "autosize":
6c10: 20 63 6f 6e 74 69 6e 75 65 0a 20 20 20 20 20 20 continue.
6c20: 66 69 6c 65 6e 61 6d 65 20 3d 20 6d 2e 67 72 6f filename = m.gro
6c30: 75 70 28 37 29 0a 20 20 20 20 20 20 69 66 20 66 up(7). if f
6c40: 69 6c 65 6e 61 6d 65 20 3d 3d 20 4e 6f 6e 65 3a ilename == None:
6c50: 20 66 69 6c 65 6e 61 6d 65 20 3d 20 22 22 0a 20 filename = "".
6c60: 20 20 20 20 20 61 74 74 61 63 68 65 64 5b 6d 2e attached[m.
6c70: 67 72 6f 75 70 28 34 29 5d 20 3d 20 66 69 6c 65 group(4)] = file
6c80: 6e 61 6d 65 0a 20 20 20 20 72 65 74 75 72 6e 20 name. return
6c90: 61 74 74 61 63 68 65 64 0a 0a 0a 20 20 23 23 23 attached... ###
6ca0: 23 20 73 65 74 5f 72 78 5f 63 6f 6e 66 69 67 20 # set_rx_config
6cb0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
6cc0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
6cd0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
6ce0: 23 23 23 23 0a 20 20 0a 20 20 64 65 66 20 73 65 ####. . def se
6cf0: 74 5f 72 78 5f 63 6f 6e 66 69 67 20 28 73 65 6c t_rx_config (sel
6d00: 66 2c 20 74 6f 5f 72 78 29 3a 0a 20 20 20 20 74 f, to_rx):. t
6d10: 6f 5f 72 78 20 3d 20 74 6f 5f 72 78 2e 6c 6f 77 o_rx = to_rx.low
6d20: 65 72 28 29 0a 20 20 20 20 69 66 20 74 6f 5f 72 er(). if to_r
6d30: 78 20 3d 3d 20 22 72 78 38 65 22 3a 20 66 72 6f x == "rx8e": fro
6d40: 6d 5f 72 78 20 3d 20 22 72 78 32 38 22 0a 20 20 m_rx = "rx28".
6d50: 20 20 65 6c 69 66 20 74 6f 5f 72 78 20 3d 3d 20 elif to_rx ==
6d60: 22 72 78 30 31 22 3a 0a 20 20 20 20 20 20 74 6f "rx01":. to
6d70: 5f 72 78 20 3d 20 22 72 78 38 65 22 0a 20 20 20 _rx = "rx8e".
6d80: 20 20 20 66 72 6f 6d 5f 72 78 20 3d 20 22 72 78 from_rx = "rx
6d90: 32 38 22 0a 20 20 20 20 65 6c 69 66 20 74 6f 5f 28". elif to_
6da0: 72 78 20 3d 3d 20 22 72 78 32 38 22 3a 20 66 72 rx == "rx28": fr
6db0: 6f 6d 5f 72 78 20 3d 20 22 72 78 38 65 22 0a 20 om_rx = "rx8e".
6dc0: 20 20 20 65 6c 69 66 20 74 6f 5f 72 78 20 3d 3d elif to_rx ==
6dd0: 20 22 72 78 30 32 22 3a 0a 20 20 20 20 20 20 74 "rx02":. t
6de0: 6f 5f 72 78 20 3d 20 22 72 78 32 38 22 0a 20 20 o_rx = "rx28".
6df0: 20 20 20 20 66 72 6f 6d 5f 72 78 20 3d 20 22 72 from_rx = "r
6e00: 78 38 65 22 0a 20 20 20 20 65 6c 73 65 3a 0a 20 x8e". else:.
6e10: 20 20 20 20 20 70 72 69 6e 74 28 22 43 61 6e 6e print("Cann
6e20: 6f 74 20 73 65 74 5f 72 78 5f 63 6f 6e 66 69 67 ot set_rx_config
6e30: 20 66 6f 72 20 22 20 2b 20 74 6f 5f 72 78 29 0a for " + to_rx).
6e40: 20 20 20 20 20 20 72 65 74 75 72 6e 20 46 61 6c return Fal
6e50: 73 65 0a 20 20 20 20 20 20 0a 20 20 20 20 69 66 se. . if
6e60: 20 73 65 6c 66 2e 76 65 72 62 6f 73 65 3a 0a 20 self.verbose:.
6e70: 20 20 20 20 20 70 72 69 6e 74 28 22 53 77 69 74 print("Swit
6e80: 63 68 20 72 78 20 64 72 69 76 65 72 3a 20 22 20 ch rx driver: "
6e90: 2b 20 66 72 6f 6d 5f 72 78 20 2b 20 22 2c 20 74 + from_rx + ", t
6ea0: 6f 3a 20 22 20 2b 20 74 6f 5f 72 78 29 0a 20 20 o: " + to_rx).
6eb0: 20 20 6c 69 6e 65 73 20 3d 20 73 65 6c 66 2e 64 lines = self.d
6ec0: 6f 5f 73 69 6d 68 5f 73 68 6f 77 28 22 72 78 22 o_simh_show("rx"
6ed0: 29 0a 0a 20 20 20 20 72 78 5f 74 79 70 65 20 3d ).. rx_type =
6ee0: 20 73 65 6c 66 2e 70 61 72 73 65 5f 73 68 6f 77 self.parse_show
6ef0: 5f 72 78 5f 64 65 76 20 28 6c 69 6e 65 73 29 0a _rx_dev (lines).
6f00: 20 20 20 20 69 66 20 72 78 5f 74 79 70 65 20 3d if rx_type =
6f10: 3d 20 4e 6f 6e 65 3a 0a 20 20 20 20 20 20 70 72 = None:. pr
6f20: 69 6e 74 28 22 64 6f 5f 72 78 5f 63 68 61 6e 67 int("do_rx_chang
6f30: 65 3a 20 54 72 6f 75 62 6c 65 20 70 61 72 73 69 e: Trouble parsi
6f40: 6e 67 20 5c 27 73 68 6f 77 20 72 78 5c 27 20 6f ng \'show rx\' o
6f50: 75 74 70 75 74 20 66 72 6f 6d 20 73 69 6d 68 2e utput from simh.
6f60: 20 20 47 69 76 69 6e 67 20 75 70 20 6f 6e 3a 22 Giving up on:"
6f70: 29 0a 20 20 20 20 20 20 73 65 6c 66 2e 64 6f 5f ). self.do_
6f80: 70 72 69 6e 74 5f 6c 69 6e 65 73 28 6c 69 6e 65 print_lines(line
6f90: 73 29 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 s). return
6fa0: 46 61 6c 73 65 0a 20 20 20 20 65 6c 69 66 20 72 False. elif r
6fb0: 78 5f 74 79 70 65 20 3d 3d 20 22 64 69 73 61 62 x_type == "disab
6fc0: 6c 65 64 22 3a 0a 20 20 20 20 20 20 69 66 20 73 led":. if s
6fd0: 65 6c 66 2e 76 65 72 62 6f 73 65 3a 20 70 72 69 elf.verbose: pri
6fe0: 6e 74 28 22 72 78 20 69 73 20 64 69 73 61 62 6c nt("rx is disabl
6ff0: 65 64 2e 20 45 6e 61 62 6c 69 6e 67 2e 2e 2e 22 ed. Enabling..."
7000: 29 0a 20 20 20 20 20 20 72 65 70 6c 79 20 3d 20 ). reply =
7010: 73 65 6c 66 2e 73 69 6d 68 5f 63 6d 64 28 22 73 self.simh_cmd("s
7020: 65 74 20 72 78 20 65 6e 61 62 6c 65 64 22 29 0a et rx enabled").
7030: 20 20 20 20 20 20 73 65 6c 66 2e 73 69 6d 68 5f self.simh_
7040: 74 65 73 74 5f 72 65 73 75 6c 74 28 72 65 70 6c test_result(repl
7050: 79 2c 20 22 50 72 6f 6d 70 74 22 2c 20 22 73 65 y, "Prompt", "se
7060: 74 5f 72 78 5f 63 6f 6e 66 69 67 20 65 6e 61 62 t_rx_config enab
7070: 6c 65 20 20 72 78 22 29 0a 20 20 20 20 20 20 23 le rx"). #
7080: 20 52 65 74 72 79 20 67 65 74 74 69 6e 67 20 72 Retry getting r
7090: 78 20 69 6e 66 6f 0a 20 20 20 20 20 20 6c 69 6e x info. lin
70a0: 65 73 20 3d 20 73 65 6c 66 2e 64 6f 5f 73 69 6d es = self.do_sim
70b0: 68 5f 73 68 6f 77 28 22 72 78 22 29 0a 20 20 20 h_show("rx").
70c0: 20 20 20 72 78 5f 74 79 70 65 20 3d 20 73 65 6c rx_type = sel
70d0: 66 2e 70 61 72 73 65 5f 73 68 6f 77 5f 72 78 5f f.parse_show_rx_
70e0: 64 65 76 20 28 6c 69 6e 65 73 29 0a 20 20 20 20 dev (lines).
70f0: 20 20 69 66 20 72 78 5f 74 79 70 65 20 3d 3d 20 if rx_type ==
7100: 4e 6f 6e 65 3a 0a 20 20 20 20 20 20 20 20 70 72 None:. pr
7110: 69 6e 74 28 22 64 6f 5f 72 78 5f 63 68 61 6e 67 int("do_rx_chang
7120: 65 20 61 66 74 65 72 20 72 65 2d 65 6e 61 62 6c e after re-enabl
7130: 65 3a 20 54 72 6f 75 62 6c 65 20 70 61 72 73 69 e: Trouble parsi
7140: 6e 67 20 5c 60 73 68 6f 77 20 72 78 5c 60 20 6f ng \`show rx\` o
7150: 75 74 70 75 74 20 66 72 6f 6d 20 73 69 6d 68 2e utput from simh.
7160: 20 47 69 76 69 6e 67 20 75 70 20 6f 6e 3a 22 29 Giving up on:")
7170: 0a 20 20 20 20 20 20 20 20 73 65 6c 66 2e 64 6f . self.do
7180: 5f 70 72 69 6e 74 5f 6c 69 6e 65 73 28 6c 69 6e _print_lines(lin
7190: 65 73 29 0a 20 20 20 20 20 20 20 20 72 65 74 75 es). retu
71a0: 72 6e 20 46 61 6c 73 65 0a 20 20 20 20 20 20 65 rn False. e
71b0: 6c 69 66 20 72 78 5f 74 79 70 65 20 3d 3d 20 22 lif rx_type == "
71c0: 64 69 73 61 62 6c 65 64 22 3a 0a 20 20 20 20 20 disabled":.
71d0: 20 20 20 70 72 69 6e 74 28 22 64 6f 5f 72 78 5f print("do_rx_
71e0: 63 68 61 6e 67 65 20 72 65 2d 65 6e 61 62 6c 65 change re-enable
71f0: 20 6f 66 20 72 78 20 66 61 69 6c 65 64 2e 20 47 of rx failed. G
7200: 69 76 69 6e 67 20 75 70 2e 22 29 0a 20 20 20 20 iving up.").
7210: 20 20 20 20 72 65 74 75 72 6e 20 46 61 6c 73 65 return False
7220: 0a 0a 20 20 20 20 69 66 20 72 78 5f 74 79 70 65 .. if rx_type
7230: 2e 6c 6f 77 65 72 28 29 20 3d 3d 20 74 6f 5f 72 .lower() == to_r
7240: 78 3a 0a 20 20 20 20 20 20 70 72 69 6e 74 28 22 x:. print("
7250: 72 78 20 64 65 76 69 63 65 20 69 73 20 61 6c 72 rx device is alr
7260: 65 61 64 79 20 73 65 74 20 74 6f 20 22 20 2b 20 eady set to " +
7270: 74 6f 5f 72 78 29 0a 20 20 20 20 20 20 72 65 74 to_rx). ret
7280: 75 72 6e 20 4e 6f 6e 65 0a 20 20 20 20 20 20 0a urn None. .
7290: 20 20 20 20 61 74 74 61 63 68 65 64 5f 72 78 3d attached_rx=
72a0: 20 73 65 6c 66 2e 70 61 72 73 65 5f 73 68 6f 77 self.parse_show
72b0: 5f 72 78 5f 61 74 74 61 63 68 65 64 28 6c 69 6e _rx_attached(lin
72c0: 65 73 29 0a 20 20 20 20 69 66 20 61 74 74 61 63 es). if attac
72d0: 68 65 64 5f 72 78 20 3d 3d 20 4e 6f 6e 65 3a 0a hed_rx == None:.
72e0: 20 20 20 20 20 20 70 72 69 6e 74 28 22 64 6f 5f print("do_
72f0: 72 78 5f 63 68 61 6e 67 65 3a 20 54 72 6f 75 62 rx_change: Troub
7300: 6c 65 20 70 61 72 73 69 6e 67 20 2f 27 73 68 6f le parsing /'sho
7310: 77 20 72 78 5c 27 20 66 72 6f 6d 20 73 69 6d 68 w rx\' from simh
7320: 20 74 6f 20 66 69 6e 64 20 72 78 20 61 74 74 61 to find rx atta
7330: 63 68 6d 65 6e 74 73 2e 20 47 6f 74 3a 22 29 0a chments. Got:").
7340: 20 20 20 20 20 20 73 65 6c 66 2e 64 6f 5f 70 72 self.do_pr
7350: 69 6e 74 5f 6c 69 6e 65 73 28 6c 69 6e 65 73 29 int_lines(lines)
7360: 0a 20 20 20 20 65 6c 73 65 3a 0a 20 20 20 20 20 . else:.
7370: 20 66 6f 72 20 75 6e 69 74 20 69 6e 20 61 74 74 for unit in att
7380: 61 63 68 65 64 5f 72 78 2e 6b 65 79 73 28 29 3a ached_rx.keys():
7390: 0a 20 20 20 20 20 20 20 20 69 66 20 61 74 74 61 . if atta
73a0: 63 68 65 64 5f 72 78 5b 75 6e 69 74 5d 20 21 3d ched_rx[unit] !=
73b0: 20 22 22 3a 0a 20 20 20 20 20 20 20 20 20 20 64 "":. d
73c0: 65 74 5f 63 6f 6d 6d 20 3d 20 22 64 65 74 20 72 et_comm = "det r
73d0: 78 22 20 2b 20 75 6e 69 74 0a 20 20 20 20 20 20 x" + unit.
73e0: 20 20 20 20 69 66 20 73 65 6c 66 2e 76 65 72 62 if self.verb
73f0: 6f 73 65 3a 0a 20 20 20 20 20 20 20 20 20 20 20 ose:.
7400: 20 70 72 69 6e 74 28 64 65 74 5f 63 6f 6d 6d 20 print(det_comm
7410: 2b 20 22 28 48 61 64 3a 20 22 20 2b 20 61 74 74 + "(Had: " + att
7420: 61 63 68 65 64 5f 72 78 5b 75 6e 69 74 5d 20 2b ached_rx[unit] +
7430: 20 22 29 22 29 0a 20 20 20 20 20 20 20 20 20 20 ")").
7440: 72 65 70 6c 79 20 3d 20 73 65 6c 66 2e 73 69 6d reply = self.sim
7450: 68 5f 63 6d 64 28 64 65 74 5f 63 6f 6d 6d 29 0a h_cmd(det_comm).
7460: 20 20 20 20 20 20 20 20 20 20 73 65 6c 66 2e 73 self.s
7470: 69 6d 68 5f 74 65 73 74 5f 72 65 73 75 6c 74 28 imh_test_result(
7480: 72 65 70 6c 79 2c 20 22 50 72 6f 6d 70 74 22 2c reply, "Prompt",
7490: 20 22 73 65 74 5f 72 78 5f 63 6f 6e 66 69 67 20 "set_rx_config
74a0: 64 65 74 61 63 68 3a 20 22 20 2b 20 64 65 74 5f detach: " + det_
74b0: 63 6f 6d 6d 29 0a 0a 20 20 20 20 72 65 70 6c 79 comm).. reply
74c0: 20 3d 20 73 65 6c 66 2e 73 69 6d 68 5f 63 6d 64 = self.simh_cmd
74d0: 28 22 73 65 74 20 72 78 20 22 20 2b 20 74 6f 5f ("set rx " + to_
74e0: 72 78 29 0a 20 20 20 20 73 65 6c 66 2e 73 69 6d rx). self.sim
74f0: 68 5f 74 65 73 74 5f 72 65 73 75 6c 74 28 72 65 h_test_result(re
7500: 70 6c 79 2c 20 22 50 72 6f 6d 70 74 22 2c 20 22 ply, "Prompt", "
7510: 73 65 74 5f 72 78 5f 63 6f 6e 66 69 67 20 73 65 set_rx_config se
7520: 74 20 72 78 20 22 20 2b 20 74 6f 5f 72 78 29 0a t rx " + to_rx).
7530: 0a 20 20 20 20 23 20 54 65 73 74 20 74 6f 20 63 . # Test to c
7540: 6f 6e 66 69 72 6d 20 6e 65 77 20 73 65 74 74 69 onfirm new setti
7550: 6e 67 20 6f 66 20 52 58 0a 20 20 20 20 6c 69 6e ng of RX. lin
7560: 65 73 20 3d 20 73 65 6c 66 2e 64 6f 5f 73 69 6d es = self.do_sim
7570: 68 5f 73 68 6f 77 28 22 72 78 22 29 0a 20 20 20 h_show("rx").
7580: 20 72 78 5f 74 79 70 65 20 3d 20 73 65 6c 66 2e rx_type = self.
7590: 70 61 72 73 65 5f 73 68 6f 77 5f 72 78 5f 64 65 parse_show_rx_de
75a0: 76 20 28 6c 69 6e 65 73 29 0a 0a 20 20 20 20 69 v (lines).. i
75b0: 66 20 72 78 5f 74 79 70 65 20 3d 3d 20 4e 6f 6e f rx_type == Non
75c0: 65 3a 0a 20 20 20 20 20 20 70 72 69 6e 74 28 22 e:. print("
75d0: 46 61 69 6c 65 64 20 63 68 61 6e 67 65 20 6f 66 Failed change of
75e0: 20 72 78 20 74 6f 20 22 20 2b 20 74 6f 5f 72 78 rx to " + to_rx
75f0: 20 2b 20 5c 0a 20 20 20 20 20 20 20 20 20 20 22 + \. "
7600: 2e 20 50 61 72 73 65 20 66 61 69 6c 20 6f 6e 20 . Parse fail on
7610: 5c 27 73 68 6f 77 20 72 78 5c 27 2e 22 29 0a 20 \'show rx\'.").
7620: 20 20 20 20 20 72 65 74 75 72 6e 20 46 61 6c 73 return Fals
7630: 65 0a 20 20 20 20 65 6c 69 66 20 72 78 5f 74 79 e. elif rx_ty
7640: 70 65 2e 6c 6f 77 65 72 28 29 20 21 3d 20 74 6f pe.lower() != to
7650: 5f 72 78 3a 20 0a 20 20 20 20 20 20 70 72 69 6e _rx: . prin
7660: 74 28 22 46 61 69 6c 65 64 20 63 68 61 6e 67 65 t("Failed change
7670: 20 6f 66 20 72 78 20 74 6f 20 22 20 2b 20 74 6f of rx to " + to
7680: 5f 72 78 20 2b 20 22 2e 20 49 6e 73 74 65 61 64 _rx + ". Instead
7690: 20 67 6f 74 3a 20 22 20 2b 20 5c 0a 20 20 20 20 got: " + \.
76a0: 20 20 20 20 20 20 72 78 5f 74 79 70 65 29 0a 20 rx_type).
76b0: 20 20 20 20 20 72 65 74 75 72 6e 20 46 61 6c 73 return Fals
76c0: 65 0a 20 20 20 20 72 65 74 75 72 6e 20 54 72 75 e. return Tru
76d0: 65 0a 0a 0a 20 20 23 23 23 23 20 67 65 74 5f 74 e... #### get_t
76e0: 74 69 20 23 23 23 23 23 23 23 23 23 23 23 23 23 ti #############
76f0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
7700: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
7710: 23 23 23 23 23 0a 20 20 23 20 52 65 74 75 72 6e #####. # Return
7720: 73 20 61 6e 20 6f 72 64 65 72 65 64 20 6c 69 73 s an ordered lis
7730: 74 20 6f 66 20 66 69 6c 65 73 20 61 74 74 61 63 t of files attac
7740: 68 65 64 20 6f 72 20 4e 6f 6e 65 20 69 66 20 64 hed or None if d
7750: 69 73 61 62 6c 65 64 2e 0a 20 20 64 65 66 20 70 isabled.. def p
7760: 61 72 73 65 5f 73 68 6f 77 5f 74 74 69 20 28 73 arse_show_tti (s
7770: 65 6c 66 2c 20 6c 69 6e 65 73 29 3a 0a 20 20 20 elf, lines):.
7780: 20 69 66 20 6c 69 6e 65 73 20 3d 3d 20 4e 6f 6e if lines == Non
7790: 65 3a 20 72 65 74 75 72 6e 20 4e 6f 6e 65 0a 20 e: return None.
77a0: 20 20 20 69 73 5f 65 6e 61 62 6c 65 64 5f 72 65 is_enabled_re
77b0: 20 3d 20 72 65 2e 63 6f 6d 70 69 6c 65 28 22 5e = re.compile("^
77c0: 28 4b 53 52 7c 37 62 29 24 22 29 0a 20 20 20 20 (KSR|7b)$").
77d0: 69 66 20 6c 65 6e 28 6c 69 6e 65 73 29 20 3c 20 if len(lines) <
77e0: 32 3a 20 72 65 74 75 72 6e 20 4e 6f 6e 65 0a 0a 2: return None..
77f0: 20 20 20 20 23 20 54 68 61 74 20 73 65 63 6f 6e # That secon
7800: 64 20 6c 69 6e 65 20 6f 66 20 6f 75 74 70 75 74 d line of output
7810: 20 63 6f 6e 74 61 69 6e 73 20 65 6d 62 65 64 64 contains embedd
7820: 65 64 20 6e 65 77 6c 69 6e 65 73 2e 0a 20 20 20 ed newlines..
7830: 20 6d 20 3d 20 72 65 2e 6d 61 74 63 68 28 69 73 m = re.match(is
7840: 5f 65 6e 61 62 6c 65 64 5f 72 65 2c 20 6c 69 6e _enabled_re, lin
7850: 65 73 5b 31 5d 2e 73 74 72 69 70 28 29 29 0a 20 es[1].strip()).
7860: 20 20 20 69 66 20 6d 20 3d 3d 20 4e 6f 6e 65 20 if m == None
7870: 6f 72 20 6d 2e 67 72 6f 75 70 28 31 29 20 3d 3d or m.group(1) ==
7880: 20 4e 6f 6e 65 3a 20 72 65 74 75 72 6e 20 4e 6f None: return No
7890: 6e 65 0a 20 20 20 20 72 65 74 75 72 6e 20 6d 2e ne. return m.
78a0: 67 72 6f 75 70 28 31 29 0a 0a 0a 0a 20 20 23 23 group(1).... ##
78b0: 23 23 20 64 6f 5f 74 74 69 5f 63 68 61 6e 67 65 ## do_tti_change
78c0: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ###############
78d0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
78e0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
78f0: 23 23 23 23 0a 0a 20 20 64 65 66 20 73 65 74 5f ####.. def set_
7900: 74 74 69 5f 63 6f 6e 66 69 67 20 28 73 65 6c 66 tti_config (self
7910: 2c 20 74 6f 5f 74 74 69 29 3a 0a 20 20 20 20 69 , to_tti):. i
7920: 66 20 74 6f 5f 74 74 69 20 3d 3d 20 22 4b 53 52 f to_tti == "KSR
7930: 22 3a 20 66 72 6f 6d 5f 74 74 69 20 3d 20 22 37 ": from_tti = "7
7940: 62 22 0a 20 20 20 20 65 6c 69 66 20 74 6f 5f 74 b". elif to_t
7950: 74 69 20 3d 3d 20 22 37 62 22 3a 20 66 72 6f 6d ti == "7b": from
7960: 5f 74 74 69 20 3d 20 22 4b 53 52 22 0a 20 20 20 _tti = "KSR".
7970: 20 65 6c 73 65 3a 0a 20 20 20 20 20 20 70 72 69 else:. pri
7980: 6e 74 28 22 43 61 6e 6e 6f 74 20 73 65 74 5f 74 nt("Cannot set_t
7990: 74 69 5f 63 6f 6e 66 69 67 20 74 6f 20 22 20 2b ti_config to " +
79a0: 20 74 6f 5f 74 74 69 29 0a 20 20 20 20 20 20 72 to_tti). r
79b0: 65 74 75 72 6e 0a 20 20 20 20 0a 20 20 20 20 69 eturn. . i
79c0: 66 20 73 65 6c 66 2e 76 65 72 62 6f 73 65 3a 0a f self.verbose:.
79d0: 20 20 20 20 20 20 70 72 69 6e 74 28 22 53 77 69 print("Swi
79e0: 74 63 68 20 74 74 69 20 64 72 69 76 65 72 20 66 tch tti driver f
79f0: 72 6f 6d 3a 20 22 20 2b 20 66 72 6f 6d 5f 74 74 rom: " + from_tt
7a00: 69 20 2b 20 22 2c 20 74 6f 3a 20 22 20 2b 20 74 i + ", to: " + t
7a10: 6f 5f 74 74 69 29 0a 0a 20 20 20 20 6c 69 6e 65 o_tti).. line
7a20: 73 20 3d 20 73 65 6c 66 2e 64 6f 5f 73 69 6d 68 s = self.do_simh
7a30: 5f 73 68 6f 77 28 22 74 74 69 22 29 0a 20 20 20 _show("tti").
7a40: 20 74 74 69 5f 74 79 70 65 20 3d 20 73 65 6c 66 tti_type = self
7a50: 2e 70 61 72 73 65 5f 73 68 6f 77 5f 74 74 69 20 .parse_show_tti
7a60: 28 6c 69 6e 65 73 29 0a 20 20 20 20 69 66 20 74 (lines). if t
7a70: 74 69 5f 74 79 70 65 20 3d 3d 20 4e 6f 6e 65 3a ti_type == None:
7a80: 0a 20 20 20 20 20 20 70 72 69 6e 74 28 22 64 6f . print("do
7a90: 5f 74 74 69 5f 63 68 61 6e 67 65 3a 20 54 72 6f _tti_change: Tro
7aa0: 75 62 6c 65 20 70 61 72 73 69 6e 67 20 5c 27 73 uble parsing \'s
7ab0: 68 6f 77 20 74 74 69 5c 27 20 6f 75 74 70 75 74 how tti\' output
7ac0: 20 66 72 6f 6d 20 73 69 6d 68 2e 20 47 69 76 69 from simh. Givi
7ad0: 6e 67 20 75 70 20 6f 6e 3a 22 29 0a 20 20 20 20 ng up on:").
7ae0: 20 20 73 65 6c 66 2e 64 6f 5f 70 72 69 6e 74 5f self.do_print_
7af0: 6c 69 6e 65 73 28 6c 69 6e 65 73 29 0a 20 20 20 lines(lines).
7b00: 20 20 20 72 65 74 75 72 6e 20 46 61 6c 73 65 0a return False.
7b10: 20 20 20 20 65 6c 69 66 20 74 74 69 5f 74 79 70 elif tti_typ
7b20: 65 20 3d 3d 20 74 6f 5f 74 74 69 3a 0a 20 20 20 e == to_tti:.
7b30: 20 20 20 70 72 69 6e 74 28 22 74 74 69 20 64 65 print("tti de
7b40: 76 69 63 65 20 69 73 20 61 6c 72 65 61 64 79 20 vice is already
7b50: 73 65 74 20 74 6f 20 22 20 2b 20 74 6f 5f 74 74 set to " + to_tt
7b60: 69 29 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 i). return
7b70: 4e 6f 6e 65 0a 0a 20 20 20 20 72 65 70 6c 79 20 None.. reply
7b80: 3d 20 73 65 6c 66 2e 73 69 6d 68 5f 63 6d 64 28 = self.simh_cmd(
7b90: 22 73 65 74 20 74 74 69 20 22 20 2b 20 74 6f 5f "set tti " + to_
7ba0: 74 74 69 29 0a 20 20 20 20 73 65 6c 66 2e 73 69 tti). self.si
7bb0: 6d 68 5f 74 65 73 74 5f 72 65 73 75 6c 74 28 72 mh_test_result(r
7bc0: 65 70 6c 79 2c 20 22 50 72 6f 6d 70 74 22 2c 20 eply, "Prompt",
7bd0: 22 73 65 74 5f 74 74 69 5f 63 6f 6e 66 69 67 20 "set_tti_config
7be0: 73 65 74 74 69 6e 67 20 74 74 69 20 22 20 2b 20 setting tti " +
7bf0: 74 6f 5f 74 74 69 29 0a 0a 20 20 20 20 23 20 54 to_tti).. # T
7c00: 65 73 74 20 74 6f 20 63 6f 6e 66 69 72 6d 20 6e est to confirm n
7c10: 65 77 20 73 65 74 74 69 6e 67 20 6f 66 20 74 74 ew setting of tt
7c20: 69 0a 20 20 20 20 6c 69 6e 65 73 20 3d 20 73 65 i. lines = se
7c30: 6c 66 2e 64 6f 5f 73 69 6d 68 5f 73 68 6f 77 28 lf.do_simh_show(
7c40: 22 74 74 69 22 29 0a 20 20 20 20 74 74 69 5f 74 "tti"). tti_t
7c50: 79 70 65 20 3d 20 73 65 6c 66 2e 70 61 72 73 65 ype = self.parse
7c60: 5f 73 68 6f 77 5f 74 74 69 20 28 6c 69 6e 65 73 _show_tti (lines
7c70: 29 0a 20 20 20 20 0a 20 20 20 20 69 66 20 74 74 ). . if tt
7c80: 69 5f 74 79 70 65 20 3d 3d 20 4e 6f 6e 65 3a 0a i_type == None:.
7c90: 20 20 20 20 20 20 70 72 69 6e 74 28 22 46 61 69 print("Fai
7ca0: 6c 65 64 20 63 68 61 6e 67 65 20 6f 66 20 74 74 led change of tt
7cb0: 69 20 74 6f 20 22 20 2b 20 74 6f 5f 74 74 69 20 i to " + to_tti
7cc0: 2b 20 5c 0a 20 20 20 20 20 20 20 20 20 20 22 2e + \. ".
7cd0: 20 50 61 72 73 65 20 66 61 69 6c 20 6f 6e 20 5c Parse fail on \
7ce0: 27 73 68 6f 77 20 74 74 69 5c 27 2e 22 29 0a 20 'show tti\'.").
7cf0: 20 20 20 20 20 72 65 74 75 72 6e 20 46 61 6c 73 return Fals
7d00: 65 0a 20 20 20 20 65 6c 69 66 20 74 74 69 5f 74 e. elif tti_t
7d10: 79 70 65 20 21 3d 20 74 6f 5f 74 74 69 3a 20 0a ype != to_tti: .
7d20: 20 20 20 20 20 20 70 72 69 6e 74 28 22 46 61 69 print("Fai
7d30: 6c 65 64 20 63 68 61 6e 67 65 20 6f 66 20 74 74 led change of tt
7d40: 69 20 74 6f 20 22 20 2b 20 74 6f 5f 74 74 69 20 i to " + to_tti
7d50: 2b 20 22 2e 20 49 6e 73 74 65 61 64 20 67 6f 74 + ". Instead got
7d60: 3a 20 22 20 2b 20 5c 0a 20 20 20 20 20 20 20 20 : " + \.
7d70: 20 20 74 74 69 5f 74 79 70 65 29 0a 20 20 20 20 tti_type).
7d80: 20 20 72 65 74 75 72 6e 20 46 61 6c 73 65 0a 20 return False.
7d90: 20 20 20 65 6c 73 65 3a 0a 20 20 20 20 20 20 72 else:. r
7da0: 65 74 75 72 6e 20 54 72 75 65 0a 0a 20 20 23 23 eturn True.. ##
7db0: 23 23 23 23 23 23 23 23 23 23 23 23 23 20 42 61 ############# Ba
7dc0: 73 69 63 20 4f 53 2f 38 20 49 6e 74 65 72 61 63 sic OS/8 Interac
7dd0: 74 69 6f 6e 20 23 23 23 23 23 23 23 23 23 23 23 tion ###########
7de0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
7df0: 23 23 23 23 0a 20 20 23 20 49 6e 74 65 72 65 61 ####. # Interea
7e00: 63 74 20 77 69 74 68 20 4f 53 2f 38 20 75 6e 64 ct with OS/8 und
7e10: 65 72 20 53 49 4d 48 2e 0a 0a 20 20 23 23 23 23 er SIMH... ####
7e20: 20 6f 73 38 5f 6b 62 64 5f 64 65 6c 61 79 20 23 os8_kbd_delay #
7e30: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
7e40: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
7e50: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
7e60: 23 23 0a 20 20 23 20 41 72 74 69 66 69 63 69 61 ##. # Artificia
7e70: 6c 6c 79 20 64 65 6c 61 79 20 74 68 65 20 6d 65 lly delay the me
7e80: 64 69 61 20 67 65 6e 65 72 61 74 69 6f 6e 20 70 dia generation p
7e90: 72 6f 63 65 73 73 20 74 6f 20 61 63 63 6f 75 6e rocess to accoun
7ea0: 74 20 66 6f 72 20 74 68 65 0a 20 20 23 20 66 61 t for the. # fa
7eb0: 63 74 20 74 68 61 74 20 4f 53 2f 38 20 6c 61 63 ct that OS/8 lac
7ec0: 6b 73 20 61 20 6d 6f 64 65 72 6e 20 6d 75 6c 74 ks a modern mult
7ed0: 69 2d 63 68 61 72 61 63 74 65 72 20 6b 65 79 62 i-character keyb
7ee0: 6f 61 72 64 20 69 6e 70 75 74 20 62 75 66 66 65 oard input buffe
7ef0: 72 2e 0a 20 20 23 20 49 74 20 69 73 20 75 6e 73 r.. # It is uns
7f00: 61 66 65 20 74 6f 20 73 65 6e 64 20 74 65 78 74 afe to send text
7f10: 20 66 61 73 74 65 72 20 74 68 61 6e 20 61 20 63 faster than a c
7f20: 6f 6e 74 65 6d 70 6f 72 61 72 79 20 74 65 72 6d ontemporary term
7f30: 69 6e 61 6c 20 63 6f 75 6c 64 2c 0a 20 20 23 20 inal could,. #
7f40: 74 68 6f 75 67 68 20 77 65 20 63 61 6e 20 73 63 though we can sc
7f50: 61 6c 65 20 69 74 20 62 61 73 65 64 20 6f 6e 20 ale it based on
7f60: 68 6f 77 20 6d 75 63 68 20 66 61 73 74 65 72 20 how much faster
7f70: 74 68 69 73 20 68 6f 73 74 20 69 73 20 74 68 61 this host is tha
7f80: 6e 20 61 0a 20 20 23 20 72 65 61 6c 20 50 44 50 n a. # real PDP
7f90: 2d 38 2e 20 20 53 65 65 20 74 68 65 20 63 6f 6e -8. See the con
7fa0: 73 74 61 6e 74 73 20 61 62 6f 76 65 20 66 6f 72 stants above for
7fb0: 20 74 68 65 20 63 61 6c 63 75 6c 61 74 69 6f 6e the calculation
7fc0: 2e 0a 0a 20 20 64 65 66 20 6f 73 38 5f 6b 62 64 ... def os8_kbd
7fd0: 5f 64 65 6c 61 79 20 28 73 65 6c 66 29 3a 0a 20 _delay (self):.
7fe0: 20 20 20 74 69 6d 65 2e 73 6c 65 65 70 20 28 73 time.sleep (s
7ff0: 65 6c 66 2e 5f 6f 73 38 5f 6b 62 64 5f 64 65 6c elf._os8_kbd_del
8000: 61 79 29 0a 0a 0a 20 20 23 23 23 23 20 6f 73 38 ay)... #### os8
8010: 5f 73 65 6e 64 5f 73 74 72 20 23 23 23 23 23 23 _send_str ######
8020: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
8030: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
8040: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
8050: 23 23 0a 20 20 23 20 43 6f 72 65 20 6f 66 20 6f ##. # Core of o
8060: 73 38 5f 73 65 6e 64 5f 6c 69 6e 65 2e 20 20 41 s8_send_line. A
8070: 6c 73 6f 20 75 73 65 64 20 62 79 20 63 6f 64 65 lso used by code
8080: 20 74 68 61 74 20 6e 65 65 64 73 20 74 6f 20 73 that needs to s
8090: 65 6e 64 20 74 65 78 74 0a 20 20 23 20 22 62 6c end text. # "bl
80a0: 69 6e 64 22 20 74 6f 20 4f 53 2f 38 2c 20 77 69 ind" to OS/8, wi
80b0: 74 68 6f 75 74 20 65 78 70 65 63 74 69 6e 67 20 thout expecting
80c0: 61 20 70 72 6f 6d 70 74 20 61 6e 64 20 77 69 74 a prompt and wit
80d0: 68 6f 75 74 20 61 20 43 52 2c 20 61 73 0a 20 20 hout a CR, as.
80e0: 23 20 77 68 65 6e 20 64 72 69 76 69 6e 67 20 54 # when driving T
80f0: 45 43 4f 2e 0a 0a 20 20 64 65 66 20 6f 73 38 5f ECO... def os8_
8100: 73 65 6e 64 5f 73 74 72 20 28 73 65 6c 66 2c 20 send_str (self,
8110: 73 74 72 29 3a 0a 20 20 20 20 66 6f 72 20 69 20 str):. for i
8120: 69 6e 20 72 61 6e 67 65 20 28 30 2c 20 6c 65 6e in range (0, len
8130: 20 28 73 74 72 29 29 3a 0a 20 20 20 20 20 20 73 (str)):. s
8140: 65 6c 66 2e 6f 73 38 5f 6b 62 64 5f 64 65 6c 61 elf.os8_kbd_dela
8150: 79 20 28 29 0a 20 20 20 20 20 20 73 65 6c 66 2e y (). self.
8160: 5f 63 68 69 6c 64 2e 73 65 6e 64 20 28 73 74 72 _child.send (str
8170: 5b 69 5d 29 0a 0a 0a 20 20 23 23 23 23 20 6f 73 [i])... #### os
8180: 38 5f 73 65 6e 64 5f 63 74 72 6c 20 23 23 23 23 8_send_ctrl ####
8190: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
81a0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
81b0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0a ###############.
81c0: 20 20 23 20 53 65 6e 64 20 61 20 63 6f 6e 74 72 # Send a contr
81d0: 6f 6c 20 63 68 61 72 61 63 74 65 72 20 74 6f 20 ol character to
81e0: 4f 53 2f 38 20 63 6f 72 72 65 73 70 6f 6e 64 69 OS/8 correspondi
81f0: 6e 67 20 74 6f 20 74 68 65 20 41 53 43 49 49 20 ng to the ASCII
8200: 6c 65 74 74 65 72 0a 20 20 23 20 67 69 76 65 6e letter. # given
8210: 2e 20 20 57 65 20 70 72 65 63 65 64 65 20 69 74 . We precede it
8220: 20 77 69 74 68 20 74 68 65 20 4f 53 2f 38 20 6b with the OS/8 k
8230: 65 79 62 6f 61 72 64 20 64 65 6c 61 79 2c 20 73 eyboard delay, s
8240: 69 6e 63 65 20 77 65 27 72 65 0a 20 20 23 20 70 ince we're. # p
8250: 72 6f 62 61 62 6c 79 20 66 6f 6c 6c 6f 77 69 6e robably followin
8260: 67 20 61 20 63 61 6c 6c 20 74 6f 20 6f 73 38 5f g a call to os8_
8270: 73 65 6e 64 5f 6c 69 6e 65 20 6f 72 20 6f 73 38 send_line or os8
8280: 5f 63 6d 64 2e 0a 0a 20 20 64 65 66 20 6f 73 38 _cmd... def os8
8290: 5f 73 65 6e 64 5f 63 74 72 6c 20 28 73 65 6c 66 _send_ctrl (self
82a0: 2c 20 63 68 61 72 29 3a 0a 20 20 20 20 63 63 20 , char):. cc
82b0: 3d 20 63 68 61 72 5b 30 5d 2e 6c 6f 77 65 72 20 = char[0].lower
82c0: 28 29 0a 20 20 20 20 73 65 6c 66 2e 6f 73 38 5f (). self.os8_
82d0: 6b 62 64 5f 64 65 6c 61 79 20 28 29 0a 20 20 20 kbd_delay ().
82e0: 20 73 65 6c 66 2e 5f 63 68 69 6c 64 2e 73 65 6e self._child.sen
82f0: 64 63 6f 6e 74 72 6f 6c 20 28 63 63 29 0a 20 20 dcontrol (cc).
8300: 20 20 0a 20 20 20 20 69 66 20 63 63 20 3d 3d 20 . if cc ==
8310: 27 65 27 3a 20 73 65 6c 66 2e 5f 63 6f 6e 74 65 'e': self._conte
8320: 78 74 20 3d 20 27 73 69 6d 68 27 0a 0a 0a 20 20 xt = 'simh'...
8330: 23 23 23 23 20 6f 73 38 5f 73 65 6e 64 5f 6c 69 #### os8_send_li
8340: 6e 65 20 23 23 23 23 23 23 23 23 23 23 23 23 23 ne #############
8350: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
8360: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
8370: 23 23 23 23 23 23 0a 20 20 23 20 43 6f 72 65 20 ######. # Core
8380: 6f 66 20 6f 73 38 5f 63 6d 64 2e 20 20 41 6c 73 of os8_cmd. Als
8390: 6f 20 75 73 65 64 20 62 79 20 63 6f 64 65 20 74 o used by code t
83a0: 68 61 74 20 6e 65 65 64 73 20 74 6f 20 73 65 6e hat needs to sen
83b0: 64 20 74 65 78 74 0a 20 20 23 20 22 62 6c 69 6e d text. # "blin
83c0: 64 22 20 74 6f 20 4f 53 2f 38 2c 20 77 69 74 68 d" to OS/8, with
83d0: 6f 75 74 20 65 78 70 65 63 74 69 6e 67 20 61 20 out expecting a
83e0: 70 72 6f 6d 70 74 2c 20 61 73 20 77 68 65 6e 20 prompt, as when
83f0: 64 72 69 76 69 6e 67 20 45 44 49 54 2e 0a 0a 20 driving EDIT...
8400: 20 64 65 66 20 6f 73 38 5f 73 65 6e 64 5f 6c 69 def os8_send_li
8410: 6e 65 20 28 73 65 6c 66 2c 20 6c 69 6e 65 29 3a ne (self, line):
8420: 0a 20 20 20 20 73 65 6c 66 2e 6f 73 38 5f 73 65 . self.os8_se
8430: 6e 64 5f 73 74 72 20 28 6c 69 6e 65 29 0a 20 20 nd_str (line).
8440: 20 20 73 65 6c 66 2e 5f 63 68 69 6c 64 2e 73 65 self._child.se
8450: 6e 64 20 28 22 5c 72 22 29 0a 0a 0a 20 20 23 23 nd ("\r")... ##
8460: 23 23 20 6f 73 38 5f 74 65 73 74 5f 72 65 73 75 ## os8_test_resu
8470: 6c 74 20 23 23 23 23 23 23 23 23 23 23 23 23 23 lt #############
8480: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
8490: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
84a0: 23 23 23 23 23 0a 20 20 23 20 43 6f 6e 76 65 6e #####. # Conven
84b0: 69 65 6e 63 65 20 77 72 61 70 70 65 72 20 66 6f ience wrapper fo
84c0: 72 20 74 65 73 74 5f 72 65 73 75 6c 74 20 74 68 r test_result th
84d0: 61 74 20 75 73 65 73 20 4f 53 2f 38 20 72 65 70 at uses OS/8 rep
84e0: 6c 69 65 73 2e 0a 0a 20 20 64 65 66 20 6f 73 38 lies... def os8
84f0: 5f 74 65 73 74 5f 72 65 73 75 6c 74 20 28 73 65 _test_result (se
8500: 6c 66 2c 20 72 65 70 6c 79 2c 20 65 78 70 65 63 lf, reply, expec
8510: 74 65 64 2c 20 63 61 6c 6c 65 72 2c 20 64 65 62 ted, caller, deb
8520: 75 67 3d 46 61 6c 73 65 29 3a 0a 20 20 20 20 72 ug=False):. r
8530: 65 74 75 72 6e 20 73 65 6c 66 2e 74 65 73 74 5f eturn self.test_
8540: 72 65 73 75 6c 74 20 28 72 65 70 6c 79 2c 20 65 result (reply, e
8550: 78 70 65 63 74 65 64 2c 20 73 65 6c 66 2e 5f 6f xpected, self._o
8560: 73 38 5f 72 65 70 6c 69 65 73 2c 20 63 61 6c 6c s8_replies, call
8570: 65 72 2c 20 64 65 62 75 67 29 0a 0a 0a 20 20 23 er, debug)... #
8580: 23 23 23 20 6d 6b 5f 6f 73 38 5f 6e 61 6d 65 20 ### mk_os8_name
8590: 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23 # ##############
85a0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
85b0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
85c0: 23 23 23 23 23 0a 20 20 23 20 43 72 65 61 74 65 #####. # Create
85d0: 20 61 6e 20 4f 53 2f 38 20 66 69 6c 65 6e 61 6d an OS/8 filenam
85e0: 65 3a 20 6f 66 20 74 68 65 20 66 6f 72 6d 20 58 e: of the form X
85f0: 58 58 58 58 58 2e 59 59 0a 20 20 23 20 46 72 6f XXXXX.YY. # Fro
8600: 6d 20 61 20 50 4f 53 49 58 20 70 61 74 68 2e 0a m a POSIX path..
8610: 0a 20 20 64 65 66 20 6d 6b 5f 6f 73 38 5f 6e 61 . def mk_os8_na
8620: 6d 65 28 73 65 6c 66 2c 20 64 65 76 2c 20 70 61 me(self, dev, pa
8630: 74 68 29 3a 0a 20 20 20 20 62 6e 73 20 3d 20 6f th):. bns = o
8640: 73 2e 70 61 74 68 2e 62 61 73 65 6e 61 6d 65 20 s.path.basename
8650: 28 70 61 74 68 29 0a 20 20 20 20 62 6e 73 20 3d (path). bns =
8660: 20 72 65 2e 73 75 62 28 22 2d 7c 3a 7c 5c 28 7c re.sub("-|:|\(|
8670: 5c 29 7c 21 22 2c 20 22 22 2c 20 62 6e 73 29 0a \)|!", "", bns).
8680: 20 20 20 20 62 6e 73 20 3d 20 62 6e 73 2e 75 70 bns = bns.up
8690: 70 65 72 28 29 0a 20 20 20 20 69 66 20 22 2e 22 per(). if "."
86a0: 20 6e 6f 74 20 69 6e 20 62 6e 73 3a 0a 20 20 20 not in bns:.
86b0: 20 20 20 72 65 74 75 72 6e 20 64 65 76 20 2b 20 return dev +
86c0: 62 6e 73 5b 3a 6d 69 6e 28 36 2c 20 6c 65 6e 28 bns[:min(6, len(
86d0: 62 6e 73 29 29 5d 0a 20 20 20 20 65 6c 73 65 3a bns))]. else:
86e0: 0a 20 20 20 20 20 20 64 6f 74 20 3d 20 62 6e 73 . dot = bns
86f0: 2e 69 6e 64 65 78 28 27 2e 27 29 0a 20 20 20 20 .index('.').
8700: 20 20 72 65 74 75 72 6e 20 64 65 76 20 2b 20 62 return dev + b
8710: 6e 73 5b 3a 6d 69 6e 28 36 2c 20 64 6f 74 2c 20 ns[:min(6, dot,
8720: 6c 65 6e 28 62 6e 73 29 29 5d 20 2b 20 22 2e 22 len(bns))] + "."
8730: 20 2b 20 62 6e 73 5b 64 6f 74 2b 31 3a 20 64 6f + bns[dot+1: do
8740: 74 2b 33 5d 0a 0a 0a 20 20 23 23 23 23 20 6f 73 t+3]... #### os
8750: 38 5f 63 6d 64 5f 20 23 23 23 23 23 23 23 23 23 8_cmd_ #########
8760: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
8770: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
8780: 23 23 23 23 23 23 23 23 23 23 0a 20 20 23 20 53 ##########. # S
8790: 65 6e 64 20 74 68 65 20 67 69 76 65 6e 20 63 6f end the given co
87a0: 6d 6d 61 6e 64 20 74 6f 20 4f 53 2f 38 2e 0a 20 mmand to OS/8..
87b0: 20 23 20 72 65 70 6c 69 65 73 20 69 73 20 61 6e # replies is an
87c0: 20 61 72 72 61 79 20 6f 66 20 70 6f 73 73 69 62 array of possib
87d0: 6c 65 20 72 65 70 6c 69 65 73 20 74 68 61 74 20 le replies that
87e0: 63 6f 6d 6d 61 6e 64 20 77 69 6c 6c 20 67 65 74 command will get
87f0: 2e 0a 20 20 23 20 52 65 74 75 72 6e 73 20 74 68 .. # Returns th
8800: 65 20 69 6e 64 65 78 20 69 6e 74 6f 20 74 68 65 e index into the
8810: 20 72 65 70 6c 69 65 73 20 61 72 72 61 79 20 74 replies array t
8820: 68 61 74 20 70 65 78 70 65 63 74 20 67 6f 74 2c hat pexpect got,
8830: 0a 20 20 23 20 6f 72 20 2d 31 20 69 66 20 74 68 . # or -1 if th
8840: 65 20 63 6f 6d 6d 61 6e 64 20 63 6f 75 6c 64 20 e command could
8850: 6e 6f 74 20 62 65 20 72 75 6e 2e 0a 20 20 23 20 not be run.. #
8860: 72 65 70 6c 69 65 73 20 69 73 20 61 6e 20 6f 70 replies is an op
8870: 74 69 6f 6e 61 6c 20 61 72 67 75 6d 65 6e 74 20 tional argument
8880: 77 68 69 63 68 20 64 65 66 61 75 6c 74 73 20 74 which defaults t
8890: 6f 20 5f 6f 73 38 5f 72 65 70 6c 69 65 73 5f 72 o _os8_replies_r
88a0: 65 78 0a 0a 20 20 64 65 66 20 6f 73 38 5f 63 6d ex.. def os8_cm
88b0: 64 20 28 73 65 6c 66 2c 20 63 6d 64 2c 20 72 65 d (self, cmd, re
88c0: 70 6c 69 65 73 3d 4e 6f 6e 65 2c 20 64 65 62 75 plies=None, debu
88d0: 67 3d 46 61 6c 73 65 2c 20 74 69 6d 65 6f 75 74 g=False, timeout
88e0: 3d 36 30 29 3a 0a 20 20 20 20 69 66 20 72 65 70 =60):. if rep
88f0: 6c 69 65 73 20 3d 3d 20 4e 6f 6e 65 3a 20 72 65 lies == None: re
8900: 70 6c 69 65 73 20 3d 20 73 65 6c 66 2e 5f 6f 73 plies = self._os
8910: 38 5f 72 65 70 6c 69 65 73 5f 72 65 78 0a 20 20 8_replies_rex.
8920: 20 20 69 66 20 73 65 6c 66 2e 5f 63 6f 6e 74 65 if self._conte
8930: 78 74 20 21 3d 20 27 6f 73 38 27 3a 20 0a 20 20 xt != 'os8': .
8940: 20 20 20 20 70 72 69 6e 74 28 22 4f 53 2f 38 20 print("OS/8
8950: 69 73 20 6e 6f 74 20 72 75 6e 6e 69 6e 67 2e 20 is not running.
8960: 43 61 6e 6e 6f 74 20 65 78 65 63 75 74 65 3a 20 Cannot execute:
8970: 22 20 2b 20 63 6d 64 29 0a 20 20 20 20 20 20 72 " + cmd). r
8980: 65 74 75 72 6e 20 2d 31 0a 20 20 20 20 73 65 6c eturn -1. sel
8990: 66 2e 6f 73 38 5f 73 65 6e 64 5f 6c 69 6e 65 20 f.os8_send_line
89a0: 28 63 6d 64 29 0a 0a 20 20 20 20 72 65 70 6c 79 (cmd).. reply
89b0: 20 3d 20 73 65 6c 66 2e 63 68 69 6c 64 5f 65 78 = self.child_ex
89c0: 70 65 63 74 20 28 72 65 70 6c 69 65 73 2c 20 74 pect (replies, t
89d0: 69 6d 65 6f 75 74 20 3d 20 74 69 6d 65 6f 75 74 imeout = timeout
89e0: 29 0a 20 20 20 20 72 65 74 75 72 6e 20 72 65 70 ). return rep
89f0: 6c 79 0a 20 20 20 20 0a 0a 20 20 23 23 23 23 20 ly. .. ####
8a00: 6f 73 38 5f 63 66 6d 5f 6d 6f 6e 69 74 6f 72 20 os8_cfm_monitor
8a10: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
8a20: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
8a30: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
8a40: 23 23 0a 20 20 23 20 43 6f 6e 66 69 72 6d 20 72 ##. # Confirm r
8a50: 65 74 75 72 6e 20 74 6f 20 4f 53 2f 38 20 6d 6f eturn to OS/8 mo
8a60: 6e 69 74 6f 72 2e 0a 20 20 23 20 54 68 69 73 20 nitor.. # This
8a70: 66 75 6e 63 74 69 6f 6e 20 69 73 20 6e 65 63 65 function is nece
8a80: 73 73 61 72 79 20 73 6f 20 74 68 61 74 20 77 65 ssary so that we
8a90: 20 6b 6e 6f 77 20 6f 75 72 20 63 6f 6d 6d 61 6e know our comman
8aa0: 64 20 68 61 73 20 72 65 74 75 72 6e 65 64 20 74 d has returned t
8ab0: 6f 20 4f 53 2f 38 2e 0a 20 20 23 20 57 69 74 68 o OS/8.. # With
8ac0: 6f 75 74 20 74 68 69 73 20 74 65 73 74 2c 20 74 out this test, t
8ad0: 68 65 20 6e 65 78 74 20 63 68 69 6c 64 5f 65 78 he next child_ex
8ae0: 70 65 63 74 20 68 69 74 73 20 61 20 6d 6f 6e 69 pect hits a moni
8af0: 74 6f 72 20 70 72 6f 6d 70 74 20 69 6e 73 74 65 tor prompt inste
8b00: 61 64 20 6f 66 0a 20 20 23 20 77 68 61 74 20 69 ad of. # what i
8b10: 74 20 77 69 6c 6c 20 62 65 20 6c 6f 6f 6b 69 6e t will be lookin
8b20: 67 20 66 6f 72 2e 0a 20 20 23 20 49 66 20 63 61 g for.. # If ca
8b30: 6c 6c 65 72 20 69 73 20 6e 6f 74 20 65 6d 70 74 ller is not empt
8b40: 79 2c 20 69 74 20 77 69 6c 6c 20 65 6d 69 74 20 y, it will emit
8b50: 61 6e 20 65 72 72 6f 72 20 73 74 72 69 6e 67 20 an error string
8b60: 69 66 20 74 68 65 20 70 72 6f 6d 70 74 20 77 61 if the prompt wa
8b70: 73 6e 27 74 20 73 65 65 6e 2e 0a 20 20 23 20 52 sn't seen.. # R
8b80: 65 74 75 72 6e 73 20 54 72 75 65 20 69 66 20 77 eturns True if w
8b90: 65 20 61 72 65 20 77 68 65 72 65 20 77 65 20 65 e are where we e
8ba0: 78 70 65 63 74 2e 0a 0a 20 20 64 65 66 20 6f 73 xpect... def os
8bb0: 38 5f 63 66 6d 5f 6d 6f 6e 69 74 6f 72 20 28 73 8_cfm_monitor (s
8bc0: 65 6c 66 2c 20 63 61 6c 6c 65 72 2c 20 64 65 62 elf, caller, deb
8bd0: 75 67 3d 46 61 6c 73 65 29 3a 0a 20 20 20 20 72 ug=False):. r
8be0: 65 70 6c 79 20 3d 20 73 65 6c 66 2e 63 68 69 6c eply = self.chil
8bf0: 64 5f 65 78 70 65 63 74 28 73 65 6c 66 2e 5f 6f d_expect(self._o
8c00: 73 38 5f 72 65 70 6c 69 65 73 5f 72 65 78 29 0a s8_replies_rex).
8c10: 20 20 20 20 72 65 74 75 72 6e 20 73 65 6c 66 2e return self.
8c20: 6f 73 38 5f 74 65 73 74 5f 72 65 73 75 6c 74 28 os8_test_result(
8c30: 72 65 70 6c 79 2c 20 22 4d 6f 6e 69 74 6f 72 20 reply, "Monitor
8c40: 50 72 6f 6d 70 74 22 2c 20 63 61 6c 6c 65 72 2c Prompt", caller,
8c50: 20 64 65 62 75 67 3d 64 65 62 75 67 29 0a 0a 0a debug=debug)...
8c60: 20 20 23 23 23 23 20 6f 73 38 5f 63 74 72 6c 5f #### os8_ctrl_
8c70: 63 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23 c ##############
8c80: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
8c90: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
8ca0: 23 23 23 23 0a 20 20 23 20 52 65 74 75 72 6e 20 ####. # Return
8cb0: 74 6f 20 4f 53 2f 38 20 6d 6f 6e 69 74 6f 72 20 to OS/8 monitor
8cc0: 75 73 69 6e 67 20 74 68 65 20 5e 43 20 67 69 76 using the ^C giv
8cd0: 65 6e 20 65 73 63 61 70 65 20 63 68 61 72 61 63 en escape charac
8ce0: 74 65 72 2e 0a 20 20 23 20 57 65 20 77 69 6c 6c ter.. # We will
8cf0: 20 70 72 6f 62 61 62 6c 79 2c 20 62 75 74 20 6e probably, but n
8d00: 6f 74 20 61 6c 77 61 79 73 20 67 65 74 20 61 6e ot always get an
8d10: 20 65 63 68 6f 20 6f 66 20 5e 43 2e 0a 20 20 23 echo of ^C.. #
8d20: 20 46 6f 72 20 65 78 61 6d 70 6c 65 20 42 55 49 For example BUI
8d30: 4c 44 20 69 73 20 6b 6e 6f 77 6e 20 4e 4f 54 20 LD is known NOT
8d40: 74 6f 2e 0a 20 20 23 20 4f 75 72 20 74 65 73 74 to.. # Our test
8d50: 69 6e 67 20 6d 61 6b 65 73 20 69 74 20 6f 70 74 ing makes it opt
8d60: 69 6f 6e 61 6c 2e 0a 20 20 23 20 57 65 20 6c 69 ional.. # We li
8d70: 73 74 65 6e 20 66 6f 72 20 61 6e 20 75 70 61 72 sten for an upar
8d80: 6f 77 20 61 6e 64 20 61 73 73 75 6d 65 20 74 68 ow and assume th
8d90: 65 20 43 20 66 6f 6c 6c 6f 77 73 2c 20 61 6e 64 e C follows, and
8da0: 20 6c 69 73 74 65 6e 20 61 67 61 69 6e 0a 20 20 listen again.
8db0: 23 20 66 6f 72 20 74 68 65 20 6d 6f 6e 69 74 6f # for the monito
8dc0: 72 20 70 72 6f 6d 70 74 2e 0a 20 20 23 20 4f 70 r prompt.. # Op
8dd0: 74 69 6f 6e 61 6c 20 63 61 6c 6c 65 72 20 61 72 tional caller ar
8de0: 67 75 6d 65 6e 74 20 65 6e 61 62 6c 65 73 20 61 gument enables a
8df0: 20 6d 65 73 73 61 67 65 20 69 66 20 74 68 65 20 message if the
8e00: 5e 43 20 65 73 63 61 70 65 20 66 61 69 6c 65 64 ^C escape failed
8e10: 2e 0a 20 20 23 20 4e 6f 74 65 3a 20 4f 53 2f 38 .. # Note: OS/8
8e20: 20 77 69 6c 6c 20 72 65 73 70 6f 6e 64 20 74 6f will respond to
8e30: 20 74 68 69 73 20 65 73 63 61 70 65 20 49 4d 4d this escape IMM
8e40: 45 44 49 41 54 45 4c 59 2c 0a 20 20 23 20 65 76 EDIATELY,. # ev
8e50: 65 6e 20 69 66 20 69 74 20 68 61 73 20 70 65 6e en if it has pen
8e60: 64 69 6e 67 20 6f 75 74 70 75 74 2e 0a 20 20 23 ding output.. #
8e70: 20 59 6f 75 20 77 69 6c 6c 20 6e 65 65 64 20 74 You will need t
8e80: 6f 20 6d 61 6b 65 20 73 75 72 65 20 61 6c 6c 20 o make sure all
8e90: 70 65 6e 64 69 6e 67 20 6f 75 74 70 75 74 20 69 pending output i
8ea0: 73 20 69 6e 0a 20 20 23 20 61 20 6b 6e 6f 77 6e s in. # a known
8eb0: 20 73 74 61 74 65 20 61 6e 64 20 74 68 65 20 72 state and the r
8ec0: 75 6e 6e 69 6e 67 20 70 72 6f 67 72 61 6d 20 69 unning program i
8ed0: 73 20 71 75 69 65 73 63 65 6e 74 0a 20 20 23 20 s quiescent. #
8ee0: 62 65 66 6f 72 65 20 63 61 6c 6c 69 6e 67 20 74 before calling t
8ef0: 68 69 73 20 6d 65 74 68 6f 64 2e 20 4f 74 68 65 his method. Othe
8f00: 72 77 69 73 65 20 70 65 78 70 65 63 74 20 6d 61 rwise pexpect ma
8f10: 79 20 67 65 74 20 6c 6f 73 74 2e 0a 0a 20 20 64 y get lost... d
8f20: 65 66 20 6f 73 38 5f 63 74 72 6c 5f 63 20 28 73 ef os8_ctrl_c (s
8f30: 65 6c 66 2c 20 63 61 6c 6c 65 72 20 3d 20 22 22 elf, caller = ""
8f40: 2c 20 64 65 62 75 67 3d 46 61 6c 73 65 29 3a 0a , debug=False):.
8f50: 20 20 20 20 73 65 6c 66 2e 6f 73 38 5f 73 65 6e self.os8_sen
8f60: 64 5f 63 74 72 6c 20 28 22 63 22 29 0a 20 20 20 d_ctrl ("c").
8f70: 20 72 65 70 6c 79 20 3d 20 73 65 6c 66 2e 63 68 reply = self.ch
8f80: 69 6c 64 5f 65 78 70 65 63 74 28 73 65 6c 66 2e ild_expect(self.
8f90: 5f 6f 73 38 5f 72 65 70 6c 69 65 73 5f 72 65 78 _os8_replies_rex
8fa0: 29 0a 20 20 20 20 75 70 61 72 72 6f 77 20 3d 20 ). uparrow =
8fb0: 73 65 6c 66 2e 6f 73 38 5f 74 65 73 74 5f 72 65 self.os8_test_re
8fc0: 73 75 6c 74 28 72 65 70 6c 79 2c 20 22 50 49 50 sult(reply, "PIP
8fd0: 20 43 6f 6e 74 69 6e 75 65 22 2c 20 22 22 29 0a Continue", "").
8fe0: 20 20 20 20 69 66 20 75 70 61 72 72 6f 77 3a 0a if uparrow:.
8ff0: 20 20 20 20 20 20 72 65 70 6c 79 20 3d 20 73 65 reply = se
9000: 6c 66 2e 63 68 69 6c 64 5f 65 78 70 65 63 74 28 lf.child_expect(
9010: 73 65 6c 66 2e 5f 6f 73 38 5f 72 65 70 6c 69 65 self._os8_replie
9020: 73 5f 72 65 78 29 0a 20 20 20 20 72 65 74 75 72 s_rex). retur
9030: 6e 20 73 65 6c 66 2e 6f 73 38 5f 74 65 73 74 5f n self.os8_test_
9040: 72 65 73 75 6c 74 28 72 65 70 6c 79 2c 20 22 4d result(reply, "M
9050: 6f 6e 69 74 6f 72 20 50 72 6f 6d 70 74 22 2c 20 onitor Prompt",
9060: 63 61 6c 6c 65 72 29 0a 0a 0a 20 20 23 23 23 23 caller)... ####
9070: 20 6f 73 38 5f 65 73 63 61 70 65 20 23 23 23 23 os8_escape ####
9080: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
9090: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
90a0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 20 ##############.
90b0: 20 23 20 52 65 74 75 72 6e 20 74 6f 20 4f 53 2f # Return to OS/
90c0: 38 20 6d 6f 6e 69 74 6f 72 20 75 73 69 6e 67 20 8 monitor using
90d0: 74 68 65 20 65 73 63 61 70 65 20 28 5e 5d 29 20 the escape (^])
90e0: 63 68 61 72 61 63 74 65 72 2e 0a 20 20 23 20 57 character.. # W
90f0: 65 20 6e 65 65 64 20 74 6f 20 6c 69 73 74 65 6e e need to listen
9100: 20 66 6f 72 20 74 68 65 20 24 20 65 63 68 6f 20 for the $ echo
9110: 6f 72 20 65 6c 73 65 20 63 66 6d 5f 6d 6f 6e 69 or else cfm_moni
9120: 74 6f 72 20 67 65 74 73 20 63 6f 6e 66 75 73 65 tor gets confuse
9130: 64 2e 0a 20 20 23 20 43 6f 6e 66 69 72 6d 20 77 d.. # Confirm w
9140: 65 20 67 6f 74 20 6f 75 72 20 6d 6f 6e 69 74 6f e got our monito
9150: 72 20 70 72 6f 6d 70 74 2e 0a 20 20 23 20 4f 70 r prompt.. # Op
9160: 74 69 6f 6e 61 6c 20 63 61 6c 6c 65 72 20 61 72 tional caller ar
9170: 67 75 6d 65 6e 74 20 65 6e 61 62 6c 65 73 20 61 gument enables a
9180: 20 6d 65 73 73 61 67 65 20 69 66 20 65 73 63 61 message if esca
9190: 70 65 20 66 61 69 6c 65 64 2e 0a 20 20 23 20 4e pe failed.. # N
91a0: 6f 74 65 3a 20 4f 53 2f 38 20 77 69 6c 6c 20 72 ote: OS/8 will r
91b0: 65 73 70 6f 6e 64 20 74 6f 20 74 68 69 73 20 65 espond to this e
91c0: 73 63 61 70 65 20 49 4d 4d 45 44 49 41 54 45 4c scape IMMEDIATEL
91d0: 59 2c 0a 20 20 23 20 65 76 65 6e 20 69 66 20 69 Y,. # even if i
91e0: 74 20 68 61 73 20 70 65 6e 64 69 6e 67 20 6f 75 t has pending ou
91f0: 74 70 75 74 2e 0a 20 20 23 20 59 6f 75 20 77 69 tput.. # You wi
9200: 6c 6c 20 6e 65 65 64 20 74 6f 20 6d 61 6b 65 20 ll need to make
9210: 73 75 72 65 20 61 6c 6c 20 70 65 6e 64 69 6e 67 sure all pending
9220: 20 6f 75 74 70 75 74 20 69 73 20 69 6e 0a 20 20 output is in.
9230: 23 20 61 20 6b 6e 6f 77 6e 20 73 74 61 74 65 20 # a known state
9240: 61 6e 64 20 74 68 65 20 72 75 6e 6e 69 6e 67 20 and the running
9250: 70 72 6f 67 72 61 6d 20 69 73 20 71 75 69 65 73 program is quies
9260: 63 65 6e 74 0a 20 20 23 20 62 65 66 6f 72 65 20 cent. # before
9270: 63 61 6c 6c 69 6e 67 20 74 68 69 73 20 6d 65 74 calling this met
9280: 68 6f 64 2e 20 4f 74 68 65 72 77 69 73 65 20 70 hod. Otherwise p
9290: 65 78 70 65 63 74 20 6d 61 79 20 67 65 74 20 6c expect may get l
92a0: 6f 73 74 2e 0a 0a 20 20 64 65 66 20 6f 73 38 5f ost... def os8_
92b0: 65 73 63 61 70 65 20 28 73 65 6c 66 2c 20 63 61 escape (self, ca
92c0: 6c 6c 65 72 20 3d 20 22 22 2c 20 64 65 62 75 67 ller = "", debug
92d0: 3d 46 61 6c 73 65 29 3a 0a 20 20 20 20 73 65 6c =False):. sel
92e0: 66 2e 6f 73 38 5f 73 65 6e 64 5f 63 74 72 6c 20 f.os8_send_ctrl
92f0: 28 27 5b 27 29 0a 20 20 20 20 73 65 6c 66 2e 63 ('['). self.c
9300: 68 69 6c 64 5f 65 78 70 65 63 74 28 22 5c 5c 24 hild_expect("\\$
9310: 22 29 0a 20 20 20 20 72 65 74 75 72 6e 20 73 65 "). return se
9320: 6c 66 2e 6f 73 38 5f 63 66 6d 5f 6d 6f 6e 69 74 lf.os8_cfm_monit
9330: 6f 72 20 28 63 61 6c 6c 65 72 29 0a 0a 0a 20 20 or (caller)...
9340: 23 23 23 23 20 73 69 6d 68 5f 72 65 73 74 61 72 #### simh_restar
9350: 74 5f 6f 73 38 20 23 23 23 23 23 23 23 23 23 23 t_os8 ##########
9360: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
9370: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
9380: 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 #############.
9390: 23 20 41 62 73 74 72 61 63 74 69 6f 6e 20 6f 6e # Abstraction on
93a0: 20 72 65 74 75 72 6e 69 6e 67 20 74 6f 20 4f 53 returning to OS
93b0: 2f 38 20 6d 6f 6e 69 74 6f 72 20 66 72 6f 6d 20 /8 monitor from
93c0: 77 69 74 68 69 6e 20 53 49 4d 48 2e 0a 20 20 23 within SIMH.. #
93d0: 20 49 74 20 69 73 20 63 6f 6d 6d 6f 6e 20 70 72 It is common pr
93e0: 61 63 74 69 63 65 20 74 6f 20 22 6c 6f 61 64 20 actice to "load
93f0: 61 64 64 72 65 73 73 20 37 36 30 30 3b 20 73 74 address 7600; st
9400: 61 72 74 22 20 61 74 20 74 68 65 20 63 6f 6e 73 art" at the cons
9410: 6f 6c 65 2e 0a 20 20 0a 20 20 64 65 66 20 73 69 ole.. . def si
9420: 6d 68 5f 72 65 73 74 61 72 74 5f 6f 73 38 20 28 mh_restart_os8 (
9430: 73 65 6c 66 2c 20 63 61 6c 6c 65 72 20 3d 20 22 self, caller = "
9440: 22 2c 20 64 65 62 75 67 3d 46 61 6c 73 65 29 3a ", debug=False):
9450: 0a 20 20 20 20 23 20 4e 6f 74 65 20 77 65 27 72 . # Note we'r
9460: 65 20 63 61 6c 6c 69 6e 67 20 73 69 6d 68 20 77 e calling simh w
9470: 69 74 68 20 6f 73 38 20 72 65 70 6c 69 65 73 20 ith os8 replies
9480: 62 65 63 61 75 73 65 20 77 65 20 77 69 6c 6c 0a because we will.
9490: 20 20 20 20 23 20 62 65 20 73 77 69 74 63 68 69 # be switchi
94a0: 6e 67 20 63 6f 6e 74 65 78 74 73 2e 0a 20 20 20 ng contexts..
94b0: 20 23 20 73 69 6d 68 5f 63 6d 64 20 6d 61 6e 61 # simh_cmd mana
94c0: 67 65 73 20 74 68 65 20 63 6f 6e 74 65 78 74 2c ges the context,
94d0: 20 61 6e 64 20 63 68 65 63 6b 73 20 66 6f 72 20 and checks for
94e0: 73 75 63 63 65 73 73 0a 20 20 20 20 23 20 62 79 success. # by
94f0: 20 65 78 70 65 63 74 69 6e 67 20 61 20 63 6f 6d expecting a com
9500: 6d 61 6e 64 20 70 72 6f 6d 70 74 2e 0a 20 20 20 mand prompt..
9510: 20 72 65 70 6c 79 20 3d 20 73 65 6c 66 2e 73 69 reply = self.si
9520: 6d 68 5f 63 6d 64 20 28 27 67 6f 20 37 36 30 30 mh_cmd ('go 7600
9530: 27 2c 20 73 65 6c 66 2e 5f 6f 73 38 5f 72 65 70 ', self._os8_rep
9540: 6c 69 65 73 5f 72 65 78 2c 20 64 65 62 75 67 3d lies_rex, debug=
9550: 64 65 62 75 67 29 0a 20 20 20 20 23 20 57 65 20 debug). # We
9560: 74 65 73 74 20 6f 75 72 20 72 65 70 6c 79 20 77 test our reply w
9570: 69 74 68 20 6f 73 38 5f 74 65 73 74 20 72 65 73 ith os8_test res
9580: 75 6c 74 20 62 65 63 61 75 73 65 20 77 65 27 72 ult because we'r
9590: 65 20 69 6e 20 4f 53 2f 38 20 6e 6f 77 2e 0a 20 e in OS/8 now..
95a0: 20 20 20 73 65 6c 66 2e 6f 73 38 5f 74 65 73 74 self.os8_test
95b0: 5f 72 65 73 75 6c 74 28 72 65 70 6c 79 2c 20 22 _result(reply, "
95c0: 4d 6f 6e 69 74 6f 72 20 50 72 6f 6d 70 74 22 2c Monitor Prompt",
95d0: 20 63 61 6c 6c 65 72 29 0a 0a 20 20 20 20 0a 20 caller).. .
95e0: 20 23 23 23 23 20 73 69 6d 68 5f 72 65 73 75 6d #### simh_resum
95f0: 65 5f 6f 73 38 20 23 23 23 23 23 23 23 23 23 23 e_os8 ##########
9600: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
9610: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
9620: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
9630: 0a 20 20 23 20 43 6f 6e 74 69 6e 75 65 20 65 78 . # Continue ex
9640: 65 63 75 74 69 6f 6e 20 6f 66 20 4f 53 2f 38 2e ecution of OS/8.
9650: 0a 20 20 23 20 54 68 69 73 20 68 61 73 20 62 65 . # This has be
9660: 65 6e 20 65 78 74 72 65 6d 65 6c 79 20 74 72 69 en extremely tri
9670: 63 6b 79 20 74 6f 20 67 65 74 20 72 69 67 68 74 cky to get right
9680: 2e 0a 20 20 23 20 57 68 61 74 20 77 65 20 6d 75 .. # What we mu
9690: 73 74 20 64 6f 20 69 73 20 67 69 76 65 20 4f 53 st do is give OS
96a0: 2f 38 20 61 20 63 68 61 6e 63 65 20 74 6f 20 77 /8 a chance to w
96b0: 61 6b 65 20 75 70 2e 0a 20 20 23 20 57 65 20 64 ake up.. # We d
96c0: 6f 20 74 68 69 73 20 62 79 20 61 73 6b 69 6e 67 o this by asking
96d0: 20 70 65 78 70 65 63 74 20 74 6f 20 73 68 6f 77 pexpect to show
96e0: 20 75 73 20 6f 75 72 20 22 63 6f 6e 74 5c 6e 22 us our "cont\n"
96f0: 20 65 63 68 6f 20 61 6e 64 20 74 68 65 6e 0a 20 echo and then.
9700: 20 23 20 77 65 20 64 6f 20 61 6e 20 6f 73 38 5f # we do an os8_
9710: 6b 62 64 5f 64 65 6c 61 79 28 29 0a 20 20 23 20 kbd_delay(). #
9720: 57 65 20 63 61 72 65 66 75 6c 6c 79 20 75 73 65 We carefully use
9730: 20 73 69 6d 68 5f 73 65 6e 64 5f 6c 69 6e 65 20 simh_send_line
9740: 74 6f 20 73 65 6e 64 20 74 68 65 20 63 6f 6d 6d to send the comm
9750: 61 6e 64 20 73 6f 20 74 68 61 74 20 77 65 0a 20 and so that we.
9760: 20 23 20 6b 6e 6f 77 20 74 6f 20 73 65 74 20 74 # know to set t
9770: 68 65 20 6f 73 38 20 63 6f 6e 74 65 78 74 2e 0a he os8 context..
9780: 20 20 23 20 57 41 52 4e 49 4e 47 21 20 55 73 69 # WARNING! Usi
9790: 6e 67 20 73 69 6d 68 5f 72 65 73 75 6d 65 5f 6f ng simh_resume_o
97a0: 73 38 20 77 69 74 68 6f 75 74 20 68 61 76 69 6e s8 without havin
97b0: 67 20 62 6f 6f 74 65 64 20 4f 53 2f 38 0a 20 20 g booted OS/8.
97c0: 23 20 68 61 73 20 75 6e 64 65 66 69 6e 65 64 20 # has undefined
97d0: 72 65 73 6c 74 73 2e 0a 0a 20 20 64 65 66 20 73 reslts... def s
97e0: 69 6d 68 5f 72 65 73 75 6d 65 5f 6f 73 38 20 28 imh_resume_os8 (
97f0: 73 65 6c 66 29 3a 0a 20 20 20 20 73 65 6c 66 2e self):. self.
9800: 73 69 6d 68 5f 73 65 6e 64 5f 6c 69 6e 65 20 28 simh_send_line (
9810: 22 63 6f 6e 74 22 29 0a 20 20 20 20 23 20 47 69 "cont"). # Gi
9820: 76 65 20 4f 53 2f 38 20 61 20 63 68 61 6e 63 65 ve OS/8 a chance
9830: 20 74 6f 20 77 61 6b 65 20 75 70 2e 0a 20 20 20 to wake up..
9840: 20 73 65 6c 66 2e 63 68 69 6c 64 5f 65 78 70 65 self.child_expe
9850: 63 74 28 22 63 6f 6e 74 5c 72 22 29 0a 20 20 20 ct("cont\r").
9860: 20 73 65 6c 66 2e 6f 73 38 5f 6b 62 64 5f 64 65 self.os8_kbd_de
9870: 6c 61 79 28 29 0a 0a 0a 20 20 23 23 23 23 20 6f lay()... #### o
9880: 73 38 5f 7a 65 72 6f 5f 63 6f 72 65 20 23 23 23 s8_zero_core ###
9890: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
98a0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
98b0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
98c0: 0a 20 20 23 20 53 74 61 72 74 69 6e 67 20 66 72 . # Starting fr
98d0: 6f 6d 20 4f 53 2f 38 20 63 6f 6e 74 65 78 74 2c om OS/8 context,
98e0: 20 62 6f 75 6e 63 65 20 6f 75 74 20 74 6f 20 53 bounce out to S
98f0: 49 4d 48 20 63 6f 6e 74 65 78 74 20 61 6e 64 20 IMH context and
9900: 7a 65 72 6f 20 61 6c 6c 0a 20 20 23 20 6f 66 20 zero all. # of
9910: 63 6f 72 65 20 65 78 63 65 70 74 69 6e 67 3a 0a core excepting:.
9920: 20 20 23 0a 20 20 23 20 30 2e 20 7a 65 72 6f 20 #. # 0. zero
9930: 70 61 67 65 20 2d 20 6d 61 6e 79 20 61 70 70 73 page - many apps
9940: 20 70 75 74 20 74 65 6d 70 6f 72 61 72 79 20 64 put temporary d
9950: 61 74 61 20 68 65 72 65 0a 20 20 23 20 31 2e 20 ata here. # 1.
9960: 74 68 65 20 74 6f 70 20 70 61 67 65 73 20 6f 66 the top pages of
9970: 20 66 69 65 6c 64 73 20 31 20 26 20 32 20 2d 20 fields 1 & 2 -
9980: 4f 53 2f 38 20 69 73 20 72 65 73 69 64 65 6e 74 OS/8 is resident
9990: 20 68 65 72 65 0a 20 20 23 20 32 2e 20 74 68 65 here. # 2. the
99a0: 20 74 6f 70 20 70 61 67 65 20 6f 66 20 66 69 65 top page of fie
99b0: 6c 64 20 32 20 2d 20 4f 53 2f 38 27 73 20 54 44 ld 2 - OS/8's TD
99c0: 38 45 20 64 72 69 76 65 72 20 28 69 66 20 61 6e 8E driver (if an
99d0: 79 29 20 6c 69 76 65 73 20 68 65 72 65 0a 20 20 y) lives here.
99e0: 23 0a 20 20 23 20 57 65 20 74 68 65 6e 20 72 65 #. # We then re
99f0: 73 74 61 72 74 20 4f 53 2f 38 2c 20 77 68 69 63 start OS/8, whic
9a00: 68 20 6d 65 61 6e 73 20 77 65 20 61 62 73 6f 6c h means we absol
9a10: 75 74 65 6c 79 20 6e 65 65 64 20 74 6f 20 64 6f utely need to do
9a20: 20 23 31 20 61 6e 64 0a 20 20 23 20 6d 61 79 20 #1 and. # may
9a30: 6e 65 65 64 20 74 6f 20 64 6f 20 23 32 2e 20 20 need to do #2.
9a40: 57 65 20 63 6f 75 6c 64 20 70 72 6f 62 61 62 6c We could probabl
9a50: 79 20 67 65 74 20 61 77 61 79 20 77 69 74 68 20 y get away with
9a60: 7a 65 72 6f 69 6e 67 20 70 61 67 65 20 30 2e 0a zeroing page 0..
9a70: 20 20 23 0a 20 20 23 20 41 6c 6c 20 6f 66 20 74 #. # All of t
9a80: 68 65 20 61 62 6f 76 65 20 65 78 70 6c 61 69 6e he above explain
9a90: 73 20 77 68 79 20 77 65 20 68 61 76 65 20 74 68 s why we have th
9aa0: 69 73 20 73 70 65 63 69 61 6c 20 4f 53 2f 38 20 is special OS/8
9ab0: 61 6c 74 65 72 6e 61 74 69 76 65 0a 20 20 23 20 alternative. #
9ac0: 74 6f 20 74 68 65 20 7a 65 72 6f 5f 63 6f 72 65 to the zero_core
9ad0: 28 29 20 6d 65 74 68 6f 64 2e 0a 0a 20 20 64 65 () method... de
9ae0: 66 20 6f 73 38 5f 7a 65 72 6f 5f 63 6f 72 65 20 f os8_zero_core
9af0: 28 73 65 6c 66 29 3a 0a 20 20 20 20 72 65 70 6c (self):. repl
9b00: 79 20 3d 20 73 65 6c 66 2e 73 69 6d 68 5f 63 6d y = self.simh_cm
9b10: 64 20 28 27 64 65 20 30 30 32 30 30 2d 30 37 35 d ('de 00200-075
9b20: 37 37 20 30 27 29 0a 20 20 20 20 73 65 6c 66 2e 77 0'). self.
9b30: 73 69 6d 68 5f 74 65 73 74 5f 72 65 73 75 6c 74 simh_test_result
9b40: 28 72 65 70 6c 79 2c 20 22 50 72 6f 6d 70 74 22 (reply, "Prompt"
9b50: 2c 20 22 6f 73 38 5f 7a 65 72 6f 5f 63 6f 72 65 , "os8_zero_core
9b60: 20 30 30 32 30 30 2d 30 37 35 37 37 22 29 0a 20 00200-07577").
9b70: 20 20 20 72 65 70 6c 79 20 3d 20 73 65 6c 66 2e reply = self.
9b80: 73 69 6d 68 5f 63 6d 64 20 28 27 64 65 20 31 30 simh_cmd ('de 10
9b90: 30 30 30 2d 31 37 35 37 37 20 30 27 29 0a 20 20 000-17577 0').
9ba0: 20 20 73 65 6c 66 2e 73 69 6d 68 5f 74 65 73 74 self.simh_test
9bb0: 5f 72 65 73 75 6c 74 28 72 65 70 6c 79 2c 20 22 _result(reply, "
9bc0: 50 72 6f 6d 70 74 22 2c 20 22 6f 73 38 5f 7a 65 Prompt", "os8_ze
9bd0: 72 6f 5f 63 6f 72 65 20 64 65 20 31 30 30 30 30 ro_core de 10000
9be0: 2d 31 37 35 37 37 20 30 22 29 0a 20 20 20 20 72 -17577 0"). r
9bf0: 65 70 6c 79 20 3d 20 73 65 6c 66 2e 73 69 6d 68 eply = self.simh
9c00: 5f 63 6d 64 20 28 27 64 65 20 32 30 30 30 30 2d _cmd ('de 20000-
9c10: 32 37 35 37 37 20 30 27 29 0a 20 20 20 20 73 65 27577 0'). se
9c20: 6c 66 2e 73 69 6d 68 5f 74 65 73 74 5f 72 65 73 lf.simh_test_res
9c30: 75 6c 74 28 72 65 70 6c 79 2c 20 22 50 72 6f 6d ult(reply, "Prom
9c40: 70 74 22 2c 20 22 6f 73 38 5f 7a 65 72 6f 5f 63 pt", "os8_zero_c
9c50: 6f 72 65 20 64 65 20 32 30 30 30 30 2d 32 37 35 ore de 20000-275
9c60: 37 37 20 30 22 29 0a 20 20 20 20 72 65 70 6c 79 77 0"). reply
9c70: 20 3d 20 73 65 6c 66 2e 73 69 6d 68 5f 63 6d 64 = self.simh_cmd
9c80: 20 28 27 64 65 20 33 30 30 30 30 2d 37 37 37 37 ('de 30000-7777
9c90: 37 20 30 27 29 0a 20 20 20 20 73 65 6c 66 2e 73 7 0'). self.s
9ca0: 69 6d 68 5f 74 65 73 74 5f 72 65 73 75 6c 74 28 imh_test_result(
9cb0: 72 65 70 6c 79 2c 20 22 50 72 6f 6d 70 74 22 2c reply, "Prompt",
9cc0: 20 22 6f 73 38 5f 7a 65 72 6f 5f 63 6f 72 65 20 "os8_zero_core
9cd0: 64 65 20 33 30 30 30 30 2d 33 37 35 37 37 20 30 de 30000-37577 0
9ce0: 22 29 0a 20 20 20 20 73 65 6c 66 2e 73 69 6d 68 "). self.simh
9cf0: 5f 72 65 73 74 61 72 74 5f 6f 73 38 20 28 29 0a _restart_os8 ().
9d00: 0a 0a 20 20 23 23 23 23 20 6f 73 38 5f 73 71 75 .. #### os8_squ
9d10: 69 73 68 20 23 23 23 23 23 23 23 23 23 23 23 23 ish ############
9d20: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
9d30: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
9d40: 23 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 23 ############. #
9d50: 20 57 72 61 70 73 20 74 68 65 20 4f 53 2f 38 20 Wraps the OS/8
9d60: 53 51 55 49 53 48 20 63 6f 6d 6d 61 6e 64 20 66 SQUISH command f
9d70: 6f 72 20 61 20 67 69 76 65 6e 20 64 65 76 69 63 or a given devic
9d80: 65 2e 0a 0a 20 20 64 65 66 20 6f 73 38 5f 73 71 e... def os8_sq
9d90: 75 69 73 68 20 28 73 65 6c 66 2c 20 64 65 76 69 uish (self, devi
9da0: 63 65 2c 20 63 61 6c 6c 65 72 20 3d 20 22 22 29 ce, caller = "")
9db0: 3a 0a 20 20 20 20 72 65 70 6c 79 20 3d 20 73 65 :. reply = se
9dc0: 6c 66 2e 6f 73 38 5f 63 6d 64 20 28 22 53 51 55 lf.os8_cmd ("SQU
9dd0: 49 53 48 20 22 20 2b 20 64 65 76 69 63 65 20 2b ISH " + device +
9de0: 20 22 3a 22 29 0a 20 20 20 20 73 65 6c 66 2e 6f ":"). self.o
9df0: 73 38 5f 74 65 73 74 5f 72 65 73 75 6c 74 20 28 s8_test_result (
9e00: 72 65 70 6c 79 2c 20 22 41 52 45 20 59 4f 55 20 reply, "ARE YOU
9e10: 53 55 52 45 3f 22 2c 20 63 61 6c 6c 65 72 29 0a SURE?", caller).
9e20: 20 20 20 20 72 65 70 6c 79 20 3d 20 73 65 6c 66 reply = self
9e30: 2e 6f 73 38 5f 63 6d 64 20 28 22 59 22 29 0a 20 .os8_cmd ("Y").
9e40: 20 20 20 73 65 6c 66 2e 6f 73 38 5f 74 65 73 74 self.os8_test
9e50: 5f 72 65 73 75 6c 74 20 28 72 65 70 6c 79 2c 20 _result (reply,
9e60: 22 4d 6f 6e 69 74 6f 72 20 50 72 6f 6d 70 74 22 "Monitor Prompt"
9e70: 2c 20 63 61 6c 6c 65 72 29 0a 0a 0a 20 20 23 23 , caller)... ##
9e80: 23 23 20 6f 73 38 5f 70 69 70 5f 74 6f 20 23 23 ## os8_pip_to ##
9e90: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
9ea0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
9eb0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
9ec0: 23 0a 20 20 23 20 53 65 6e 64 20 61 20 63 6f 70 #. # Send a cop
9ed0: 79 20 6f 66 20 61 20 6c 6f 63 61 6c 20 66 69 6c y of a local fil
9ee0: 65 20 74 6f 20 4f 53 2f 38 20 75 73 69 6e 67 20 e to OS/8 using
9ef0: 50 49 50 2e 0a 20 20 23 0a 20 20 23 20 54 68 65 PIP.. #. # The
9f00: 20 66 69 6c 65 20 69 73 20 73 65 6e 74 20 76 69 file is sent vi
9f10: 61 20 74 68 65 20 53 49 4d 48 20 70 61 70 65 72 a the SIMH paper
9f20: 20 74 61 70 65 20 64 65 76 69 63 65 20 74 68 72 tape device thr
9f30: 6f 75 67 68 20 50 49 50 0a 20 20 23 20 73 70 65 ough PIP. # spe
9f40: 63 69 66 79 69 6e 67 20 61 20 74 72 61 6e 73 66 cifying a transf
9f50: 65 72 20 6f 70 74 69 6f 6e 2e 20 20 49 66 20 6e er option. If n
9f60: 6f 20 6f 70 74 69 6f 6e 20 69 73 20 73 70 65 63 o option is spec
9f70: 69 66 69 65 64 2c 0a 20 20 23 20 41 53 43 49 49 ified,. # ASCII
9f80: 20 69 73 20 61 73 73 75 6d 65 64 2e 0a 20 20 23 is assumed.. #
9f90: 0a 20 20 23 20 49 6e 20 41 53 43 49 49 20 6d 6f . # In ASCII mo
9fa0: 64 65 2c 20 77 65 20 70 72 65 2d 70 72 6f 63 65 de, we pre-proce
9fb0: 73 73 20 77 69 74 68 20 74 78 74 32 70 74 70 20 ss with txt2ptp
9fc0: 77 68 69 63 68 20 74 72 61 6e 73 6c 61 74 65 73 which translates
9fd0: 0a 20 20 23 20 50 4f 53 49 58 20 41 53 43 49 49 . # POSIX ASCII
9fe0: 20 63 6f 6e 76 65 6e 74 69 6f 6e 73 20 74 6f 20 conventions to
9ff0: 4f 53 2f 38 20 63 6f 6e 76 65 6e 74 69 6f 6e 73 OS/8 conventions
a000: 2e 20 20 49 6e 20 61 6c 6c 20 6f 74 68 65 72 0a . In all other.
a010: 20 20 23 20 6d 6f 64 65 73 2c 20 77 65 20 64 6f # modes, we do
a020: 20 6e 6f 74 20 64 6f 20 61 6e 79 20 74 72 61 6e not do any tran
a030: 73 6c 61 74 69 6f 6e 2e 0a 20 20 23 0a 20 20 23 slation.. #. #
a040: 20 48 6f 77 65 76 65 72 2c 20 77 65 20 73 68 6f However, we sho
a050: 75 6c 64 20 73 75 70 70 6c 79 20 61 20 73 61 63 uld supply a sac
a060: 72 69 66 69 63 69 61 6c 20 4e 55 4c 4c 20 61 73 rificial NULL as
a070: 20 61 6e 20 61 64 64 69 74 69 6f 6e 61 6c 20 63 an additional c
a080: 68 61 72 61 63 74 65 72 0a 20 20 23 20 62 65 63 haracter. # bec
a090: 61 75 73 65 20 74 68 65 20 4f 53 2f 38 20 50 54 ause the OS/8 PT
a0a0: 52 20 64 72 69 76 65 72 20 74 68 72 6f 77 73 20 R driver throws
a0b0: 74 68 65 20 6c 61 73 74 20 63 68 61 72 61 63 74 the last charact
a0c0: 65 72 20 61 77 61 79 2e 20 28 4e 4f 54 20 44 4f er away. (NOT DO
a0d0: 4e 45 20 59 45 54 29 0a 20 20 23 0a 20 20 23 20 NE YET). #. #
a0e0: 45 6e 74 72 79 20 63 6f 6e 74 65 78 74 20 73 68 Entry context sh
a0f0: 6f 75 6c 64 20 62 65 20 69 6e 73 69 64 65 20 4f ould be inside O
a100: 53 2f 38 2e 20 20 45 78 69 74 20 63 6f 6e 74 65 S/8. Exit conte
a110: 78 74 20 69 73 20 69 6e 73 69 64 65 20 4f 53 2f xt is inside OS/
a120: 38 2e 0a 20 20 23 0a 0a 20 20 64 65 66 20 6f 73 8.. #.. def os
a130: 38 5f 70 69 70 5f 74 6f 20 28 73 65 6c 66 2c 20 8_pip_to (self,
a140: 70 61 74 68 2c 20 6f 73 38 6e 61 6d 65 2c 20 6f path, os8name, o
a150: 70 74 69 6f 6e 20 3d 20 4e 6f 6e 65 2c 20 64 65 ption = None, de
a160: 62 75 67 3d 46 61 6c 73 65 29 3a 0a 20 20 20 20 bug=False):.
a170: 69 66 20 6f 70 74 69 6f 6e 20 3d 3d 20 4e 6f 6e if option == Non
a180: 65 3a 20 6f 70 74 69 6f 6e 20 3d 20 22 22 0a 20 e: option = "".
a190: 20 20 20 23 20 49 66 20 6f 73 38 6e 61 6d 65 20 # If os8name
a1a0: 69 73 20 6a 75 73 74 20 61 20 64 65 76 69 63 65 is just a device
a1b0: 2c 20 73 79 6e 74 68 65 73 69 7a 65 20 61 6e 20 , synthesize an
a1c0: 75 70 63 61 73 65 64 20 6e 61 6d 65 20 66 72 6f upcased name fro
a1d0: 6d 0a 20 20 20 20 23 20 74 68 65 20 50 4f 53 49 m. # the POSI
a1e0: 58 20 66 69 6c 65 20 62 61 73 65 6e 61 6d 65 2e X file basename.
a1f0: 0a 20 20 20 20 69 66 20 6e 6f 74 20 6f 73 2e 70 . if not os.p
a200: 61 74 68 2e 65 78 69 73 74 73 28 70 61 74 68 29 ath.exists(path)
a210: 3a 0a 20 20 20 20 20 20 70 72 69 6e 74 28 70 61 :. print(pa
a220: 74 68 20 2b 20 22 20 6e 6f 74 20 66 6f 75 6e 64 th + " not found
a230: 2e 20 53 6b 69 70 70 69 6e 67 2e 22 29 0a 20 20 . Skipping.").
a240: 20 20 20 20 72 65 74 75 72 6e 0a 20 20 20 20 6d return. m
a250: 20 3d 20 72 65 2e 6d 61 74 63 68 28 73 65 6c 66 = re.match(self
a260: 2e 5f 6f 73 38 5f 66 69 6c 65 5f 72 65 2c 20 6f ._os8_file_re, o
a270: 73 38 6e 61 6d 65 29 0a 20 20 20 20 69 66 20 6d s8name). if m
a280: 20 21 3d 20 4e 6f 6e 65 20 61 6e 64 20 28 6d 2e != None and (m.
a290: 67 72 6f 75 70 28 32 29 20 3d 3d 20 4e 6f 6e 65 group(2) == None
a2a0: 20 6f 72 20 6d 2e 67 72 6f 75 70 28 32 29 20 3d or m.group(2) =
a2b0: 3d 20 22 22 29 3a 0a 20 20 20 20 20 20 20 20 64 = ""):. d
a2c0: 65 73 74 20 3d 20 73 65 6c 66 2e 6d 6b 5f 6f 73 est = self.mk_os
a2d0: 38 5f 6e 61 6d 65 28 6f 73 38 6e 61 6d 65 2c 20 8_name(os8name,
a2e0: 70 61 74 68 29 0a 20 20 20 20 65 6c 73 65 3a 0a path). else:.
a2f0: 20 20 20 20 20 20 20 20 64 65 73 74 20 3d 20 6f dest = o
a300: 73 38 6e 61 6d 65 0a 0a 20 20 20 20 23 20 47 72 s8name.. # Gr
a310: 6f 73 73 20 68 61 63 6b 3a 0a 20 20 20 20 23 20 oss hack:. #
a320: 54 68 65 20 63 6f 6d 6d 61 6e 64 20 64 65 63 6f The command deco
a330: 64 65 72 20 70 72 6f 6d 70 74 20 74 68 61 74 20 der prompt that
a340: 63 6f 6d 65 73 20 77 68 65 6e 20 77 65 20 63 6f comes when we co
a350: 6e 74 69 6e 75 65 20 61 20 50 54 52 2f 50 54 50 ntinue a PTR/PTP
a360: 0a 20 20 20 20 23 20 64 6f 65 73 20 6e 6f 74 20 . # does not
a370: 68 61 76 65 20 61 20 6e 65 77 6c 69 6e 65 2e 20 have a newline.
a380: 20 42 75 74 20 65 76 65 72 79 74 68 69 6e 67 20 But everything
a390: 65 6c 73 65 20 74 68 61 74 20 6d 61 74 63 68 65 else that matche
a3a0: 73 20 6f 6e 0a 20 20 20 20 23 20 61 20 63 6f 6d s on. # a com
a3b0: 6d 61 6e 64 20 64 65 63 6f 64 65 72 20 70 72 6f mand decoder pro
a3c0: 6d 70 74 20 4e 45 45 44 53 20 74 68 61 74 20 6e mpt NEEDS that n
a3d0: 65 77 6c 69 6e 65 2e 20 4f 74 68 65 72 77 69 73 ewline. Otherwis
a3e0: 65 20 77 65 20 6d 61 74 63 68 0a 20 20 20 20 23 e we match. #
a3f0: 20 6f 6e 20 61 73 74 65 72 69 73 6b 73 20 69 6e on asterisks in
a400: 20 66 69 6c 65 20 73 70 65 63 73 2e 0a 20 20 20 file specs..
a410: 20 23 20 52 65 6d 65 6d 62 65 72 20 74 6f 20 64 # Remember to d
a420: 65 63 72 65 6d 65 6e 74 20 72 65 70 6c 69 65 73 ecrement replies
a430: 20 6f 6e 20 74 68 69 73 20 72 65 78 20 6c 69 73 on this rex lis
a440: 74 20 69 66 20 77 65 20 75 73 65 0a 20 20 20 20 t if we use.
a450: 23 20 5f 6f 73 38 5f 72 65 70 6c 69 65 73 0a 0a # _os8_replies..
a460: 20 20 20 20 70 69 70 5f 72 65 78 20 3d 20 5b 72 pip_rex = [r
a470: 65 2e 63 6f 6d 70 69 6c 65 28 22 5c 5c 2a 24 22 e.compile("\\*$"
a480: 2e 65 6e 63 6f 64 65 28 29 29 5d 0a 20 20 20 20 .encode())].
a490: 70 69 70 5f 72 65 78 2e 65 78 74 65 6e 64 28 73 pip_rex.extend(s
a4a0: 65 6c 66 2e 5f 6f 73 38 5f 72 65 70 6c 69 65 73 elf._os8_replies
a4b0: 5f 72 65 78 29 0a 20 20 20 20 0a 20 20 20 20 64 _rex). . d
a4c0: 69 64 5f 63 6f 6e 76 65 72 73 69 6f 6e 20 3d 20 id_conversion =
a4d0: 46 61 6c 73 65 0a 20 20 20 20 69 66 20 6f 70 74 False. if opt
a4e0: 69 6f 6e 20 3d 3d 20 22 22 20 6f 72 20 6f 70 74 ion == "" or opt
a4f0: 69 6f 6e 20 3d 3d 20 22 2f 41 22 3a 0a 20 20 20 ion == "/A":.
a500: 20 20 20 23 20 43 6f 6e 76 65 72 74 20 74 65 78 # Convert tex
a510: 74 20 66 69 6c 65 20 74 6f 20 53 49 4d 48 20 70 t file to SIMH p
a520: 61 70 65 72 20 74 61 70 65 20 66 6f 72 6d 61 74 aper tape format
a530: 20 69 6e 20 63 75 72 72 65 6e 74 20 64 69 72 20 in current dir
a540: 6f 66 20 70 61 74 68 2e 0a 20 20 20 20 20 20 69 of path.. i
a550: 66 20 73 65 6c 66 2e 76 65 72 62 6f 73 65 3a 20 f self.verbose:
a560: 70 72 69 6e 74 28 22 46 6f 72 6d 61 74 20 63 6f print("Format co
a570: 6e 76 65 72 74 69 6e 67 20 22 20 2b 20 70 61 74 nverting " + pat
a580: 68 29 0a 20 20 20 20 20 20 62 64 69 72 20 3d 20 h). bdir =
a590: 70 69 64 70 38 69 2e 64 69 72 73 2e 62 75 69 6c pidp8i.dirs.buil
a5a0: 64 0a 20 20 20 20 20 20 23 20 43 72 65 61 74 65 d. # Create
a5b0: 20 75 6e 69 71 75 69 66 69 65 64 20 74 65 6d 70 uniquified temp
a5c0: 20 70 61 74 68 20 6e 61 6d 65 2e 0a 20 20 20 20 path name..
a5d0: 20 20 70 74 20 20 20 3d 20 70 61 74 68 20 2b 20 pt = path +
a5e0: 22 2d 22 20 2b 20 73 74 72 28 6f 73 2e 67 65 74 "-" + str(os.get
a5f0: 70 69 64 28 29 29 20 2b 20 22 2e 70 74 5f 74 65 pid()) + ".pt_te
a600: 6d 70 22 0a 20 20 20 20 20 20 74 6f 6f 6c 20 3d mp". tool =
a610: 20 6f 73 2e 70 61 74 68 2e 6a 6f 69 6e 20 28 62 os.path.join (b
a620: 64 69 72 2c 20 27 62 69 6e 27 2c 20 27 74 78 74 dir, 'bin', 'txt
a630: 32 70 74 70 27 29 0a 20 20 20 20 20 20 73 75 62 2ptp'). sub
a640: 70 72 6f 63 65 73 73 2e 63 61 6c 6c 20 28 74 6f process.call (to
a650: 6f 6c 20 2b 20 27 20 3c 20 27 20 2b 20 70 61 74 ol + ' < ' + pat
a660: 68 20 2b 20 27 20 3e 20 27 20 2b 20 70 74 2c 20 h + ' > ' + pt,
a670: 73 68 65 6c 6c 20 3d 20 54 72 75 65 29 0a 20 20 shell = True).
a680: 20 20 20 20 64 69 64 5f 63 6f 6e 76 65 72 73 69 did_conversi
a690: 6f 6e 20 3d 20 54 72 75 65 0a 20 20 20 20 65 6c on = True. el
a6a0: 69 66 20 6f 70 74 69 6f 6e 20 6e 6f 74 20 69 6e if option not in
a6b0: 20 73 65 6c 66 2e 5f 76 61 6c 69 64 5f 70 69 70 self._valid_pip
a6c0: 5f 6f 70 74 69 6f 6e 73 3a 0a 20 20 20 20 20 20 _options:.
a6d0: 70 72 69 6e 74 28 22 49 6e 76 61 6c 69 64 20 50 print("Invalid P
a6e0: 49 50 20 6f 70 74 69 6f 6e 3a 20 22 20 2b 20 6f IP option: " + o
a6f0: 70 74 69 6f 6e 20 2b 20 22 2e 20 49 67 6e 6f 72 ption + ". Ignor
a700: 69 6e 67 3a 20 22 20 2b 20 70 61 74 68 20 2b 20 ing: " + path +
a710: 5c 0a 20 20 20 20 20 20 20 20 20 20 22 20 74 6f \. " to
a720: 20 4f 53 2f 38 2e 22 29 0a 20 20 20 20 20 20 72 OS/8."). r
a730: 65 74 75 72 6e 0a 20 20 20 20 65 6c 73 65 3a 0a eturn. else:.
a740: 20 20 20 20 20 20 70 74 20 3d 20 70 61 74 68 0a pt = path.
a750: 0a 20 20 20 20 23 20 54 4f 44 4f 3a 20 53 61 63 . # TODO: Sac
a760: 72 69 66 69 63 69 61 6c 20 65 78 74 72 61 20 63 rificial extra c
a770: 68 61 72 61 63 74 65 72 20 63 6f 64 65 20 67 6f haracter code go
a780: 65 73 20 68 65 72 65 2e 0a 0a 20 20 20 20 23 20 es here... #
a790: 50 61 70 65 72 20 74 61 70 65 20 63 72 65 61 74 Paper tape creat
a7a0: 65 64 2c 20 73 6f 20 61 74 74 61 63 68 20 69 74 ed, so attach it
a7b0: 20 72 65 61 64 2d 6f 6e 6c 79 20 61 6e 64 20 63 read-only and c
a7c0: 6f 70 79 20 69 74 20 69 6e 2e 20 20 57 65 27 72 opy it in. We'r
a7d0: 65 0a 20 20 20 20 23 20 72 65 6c 79 69 6e 67 20 e. # relying
a7e0: 6f 6e 20 74 78 74 32 70 74 70 20 74 6f 20 69 6e on txt2ptp to in
a7f0: 73 65 72 74 20 74 68 65 20 43 74 72 6c 2d 5a 20 sert the Ctrl-Z
a800: 45 4f 46 20 6d 61 72 6b 65 72 20 61 74 20 74 68 EOF marker at th
a810: 65 20 65 6e 64 20 6f 66 0a 20 20 20 20 23 20 74 e end of. # t
a820: 68 65 20 66 69 6c 65 2e 0a 20 20 20 20 72 65 70 he file.. rep
a830: 6c 79 20 3d 20 73 65 6c 66 2e 73 69 6d 68 5f 63 ly = self.simh_c
a840: 6d 64 20 28 27 61 74 74 61 63 68 20 2d 72 20 70 md ('attach -r p
a850: 74 72 20 27 20 2b 20 70 74 2c 20 64 65 62 75 67 tr ' + pt, debug
a860: 3d 64 65 62 75 67 29 0a 20 20 20 20 73 65 6c 66 =debug). self
a870: 2e 73 69 6d 68 5f 74 65 73 74 5f 72 65 73 75 6c .simh_test_resul
a880: 74 28 72 65 70 6c 79 2c 20 22 50 72 6f 6d 70 74 t(reply, "Prompt
a890: 22 2c 20 22 6f 73 38 5f 70 69 70 5f 74 6f 20 61 ", "os8_pip_to a
a8a0: 74 74 61 63 68 69 6e 67 20 70 74 72 22 29 0a 20 ttaching ptr").
a8b0: 20 20 20 23 20 45 6e 74 65 72 20 4f 53 2f 38 2e # Enter OS/8.
a8c0: 0a 20 20 20 20 73 65 6c 66 2e 73 69 6d 68 5f 72 . self.simh_r
a8d0: 65 73 74 61 72 74 5f 6f 73 38 20 28 63 61 6c 6c estart_os8 (call
a8e0: 65 72 3d 22 6f 73 38 5f 70 69 70 5f 74 6f 22 29 er="os8_pip_to")
a8f0: 0a 20 20 20 20 0a 20 20 20 20 72 65 70 6c 79 20 . . reply
a900: 3d 20 73 65 6c 66 2e 6f 73 38 5f 63 6d 64 20 28 = self.os8_cmd (
a910: 27 52 20 50 49 50 27 2c 20 64 65 62 75 67 3d 64 'R PIP', debug=d
a920: 65 62 75 67 29 0a 20 20 20 20 23 20 48 61 73 20 ebug). # Has
a930: 50 49 50 20 53 74 61 72 74 75 70 20 62 65 65 6e PIP Startup been
a940: 20 73 75 63 63 65 73 73 66 75 6c 3f 0a 20 20 20 successful?.
a950: 20 69 66 20 73 65 6c 66 2e 6f 73 38 5f 74 65 73 if self.os8_tes
a960: 74 5f 72 65 73 75 6c 74 20 28 72 65 70 6c 79 2c t_result (reply,
a970: 20 22 43 6f 6d 6d 61 6e 64 20 44 65 63 6f 64 65 "Command Decode
a980: 72 20 50 72 6f 6d 70 74 22 2c 20 22 6f 73 38 5f r Prompt", "os8_
a990: 70 69 70 5f 74 6f 20 30 22 2c 20 5c 0a 20 20 20 pip_to 0", \.
a9a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
a9b0: 20 20 20 20 20 20 20 20 20 20 64 65 62 75 67 3d debug=
a9c0: 64 65 62 75 67 29 20 3d 3d 20 46 61 6c 73 65 3a debug) == False:
a9d0: 20 72 65 74 75 72 6e 0a 0a 20 20 20 20 23 20 47 return.. # G
a9e0: 69 76 65 20 66 69 6c 65 20 61 6e 64 20 74 65 73 ive file and tes
a9f0: 74 20 66 6f 72 20 72 65 61 64 79 20 74 6f 20 73 t for ready to s
aa00: 65 6e 64 2e 0a 20 20 20 20 69 66 20 64 65 62 75 end.. if debu
aa10: 67 3a 20 70 72 69 6e 74 20 28 22 6f 73 38 5f 70 g: print ("os8_p
aa20: 69 70 5f 74 6f 3a 20 53 65 6e 64 69 6e 67 3a 20 ip_to: Sending:
aa30: 22 20 2b 20 64 65 73 74 20 2b 20 27 3c 50 54 52 " + dest + '<PTR
aa40: 3a 27 20 2b 20 6f 70 74 69 6f 6e 29 0a 20 20 20 :' + option).
aa50: 20 72 65 70 6c 79 20 3d 20 73 65 6c 66 2e 6f 73 reply = self.os
aa60: 38 5f 63 6d 64 20 28 64 65 73 74 20 2b 20 27 3c 8_cmd (dest + '<
aa70: 50 54 52 3a 27 20 2b 20 6f 70 74 69 6f 6e 2c 20 PTR:' + option,
aa80: 64 65 62 75 67 3d 64 65 62 75 67 29 0a 20 20 20 debug=debug).
aa90: 20 69 66 20 73 65 6c 66 2e 6f 73 38 5f 74 65 73 if self.os8_tes
aaa0: 74 5f 72 65 73 75 6c 74 20 28 72 65 70 6c 79 2c t_result (reply,
aab0: 20 22 50 49 50 20 43 6f 6e 74 69 6e 75 65 22 2c "PIP Continue",
aac0: 20 22 6f 73 38 5f 70 69 70 5f 74 6f 20 31 22 2c "os8_pip_to 1",
aad0: 20 64 65 62 75 67 3d 64 65 62 75 67 29 20 3d 3d debug=debug) ==
aae0: 20 46 61 6c 73 65 3a 0a 20 20 20 20 20 20 23 20 False:. #
aaf0: 49 66 20 77 65 20 67 6f 74 20 22 50 49 50 20 43 If we got "PIP C
ab00: 6f 6e 74 69 6e 75 65 22 20 77 65 20 6b 65 65 70 ontinue" we keep
ab10: 20 67 6f 69 6e 67 2e 20 4f 74 68 65 72 77 69 73 going. Otherwis
ab20: 65 20 72 65 74 75 72 6e 2e 0a 20 20 20 20 20 20 e return..
ab30: 23 20 53 65 6e 64 20 65 73 63 61 70 65 20 69 66 # Send escape if
ab40: 20 72 65 70 6c 79 20 69 6e 64 69 63 61 74 65 73 reply indicates
ab50: 20 77 65 20 64 69 64 6e 27 74 20 67 6f 20 62 61 we didn't go ba
ab60: 63 6b 20 74 6f 20 74 68 65 20 6d 6f 6e 69 74 6f ck to the monito
ab70: 72 2e 0a 20 20 20 20 20 20 69 66 20 73 65 6c 66 r.. if self
ab80: 2e 5f 6f 73 38 5f 72 65 70 6c 69 65 73 5b 72 65 ._os8_replies[re
ab90: 70 6c 79 5d 5b 32 5d 20 3d 3d 20 46 61 6c 73 65 ply][2] == False
aba0: 3a 0a 20 20 20 20 20 20 20 20 73 65 6c 66 2e 6f :. self.o
abb0: 73 38 5f 73 65 6e 64 5f 63 74 72 6c 20 28 27 5b s8_send_ctrl ('[
abc0: 27 29 0a 20 20 20 20 20 20 72 65 74 75 72 6e 0a '). return.
abd0: 0a 20 20 20 20 23 20 46 69 6e 69 73 68 20 74 72 . # Finish tr
abe0: 61 6e 73 66 65 72 0a 20 20 20 20 23 20 54 68 65 ansfer. # The
abf0: 20 74 65 73 74 20 66 6f 72 20 73 75 63 63 65 73 test for succes
ac00: 73 20 69 73 20 69 6d 70 6c 69 63 69 74 2e 0a 20 s is implicit..
ac10: 20 20 20 73 65 6c 66 2e 6f 73 38 5f 73 65 6e 64 self.os8_send
ac20: 5f 63 74 72 6c 20 28 27 5b 27 29 0a 20 20 20 20 _ctrl ('[').
ac30: 72 65 70 6c 79 20 3d 20 73 65 6c 66 2e 63 68 69 reply = self.chi
ac40: 6c 64 5f 65 78 70 65 63 74 20 28 70 69 70 5f 72 ld_expect (pip_r
ac50: 65 78 29 0a 20 20 20 20 69 66 20 72 65 70 6c 79 ex). if reply
ac60: 20 21 3d 20 30 3a 0a 20 20 20 20 20 20 73 65 6c != 0:. sel
ac70: 66 2e 6f 73 38 5f 74 65 73 74 5f 72 65 73 75 6c f.os8_test_resul
ac80: 74 20 28 72 65 70 6c 79 20 2d 20 31 2c 20 22 43 t (reply - 1, "C
ac90: 6f 6d 6d 61 6e 64 20 44 65 63 6f 64 65 72 20 50 ommand Decoder P
aca0: 72 6f 6d 70 74 22 2c 20 22 6f 73 38 5f 70 69 70 rompt", "os8_pip
acb0: 5f 74 6f 20 32 22 2c 20 64 65 62 75 67 3d 64 65 _to 2", debug=de
acc0: 62 75 67 29 0a 20 20 20 20 23 20 49 66 20 77 65 bug). # If we
acd0: 20 64 69 64 20 6e 6f 74 20 72 65 74 75 72 6e 20 did not return
ace0: 74 6f 20 6d 6f 6e 69 74 6f 72 20 68 69 74 20 65 to monitor hit e
acf0: 73 63 61 70 65 20 74 6f 20 65 78 69 74 20 50 49 scape to exit PI
ad00: 50 2e 0a 20 20 20 20 69 66 20 73 65 6c 66 2e 5f P.. if self._
ad10: 6f 73 38 5f 72 65 70 6c 69 65 73 5b 72 65 70 6c os8_replies[repl
ad20: 79 20 2d 20 31 5d 5b 32 5d 20 3d 3d 20 46 61 6c y - 1][2] == Fal
ad30: 73 65 3a 0a 20 20 20 20 20 20 20 20 73 65 6c 66 se:. self
ad40: 2e 6f 73 38 5f 73 65 6e 64 5f 63 74 72 6c 20 28 .os8_send_ctrl (
ad50: 27 5b 27 29 20 20 20 20 20 20 23 20 53 75 63 63 '[') # Succ
ad60: 65 73 73 20 6f 72 20 4e 6f 6e 2d 66 61 74 61 6c ess or Non-fatal
ad70: 20 65 72 72 6f 72 2e 0a 20 20 20 20 20 20 20 20 error..
ad80: 23 20 4d 75 73 74 20 65 78 69 74 20 50 49 50 20 # Must exit PIP
ad90: 61 6e 64 20 77 61 69 74 20 66 6f 72 20 6d 6f 6e and wait for mon
ada0: 69 74 6f 72 20 70 72 6f 6d 70 74 2e 20 43 6f 6d itor prompt. Com
adb0: 70 6c 61 69 6e 20 69 66 20 77 65 20 64 6f 6e 27 plain if we don'
adc0: 74 20 67 65 74 20 69 74 21 0a 20 20 20 20 20 20 t get it!.
add0: 20 20 72 65 70 6c 79 20 3d 20 73 65 6c 66 2e 63 reply = self.c
ade0: 68 69 6c 64 5f 65 78 70 65 63 74 20 28 73 65 6c hild_expect (sel
adf0: 66 2e 5f 6f 73 38 5f 72 65 70 6c 69 65 73 5f 72 f._os8_replies_r
ae00: 65 78 29 0a 20 20 20 20 20 20 20 20 73 65 6c 66 ex). self
ae10: 2e 6f 73 38 5f 74 65 73 74 5f 72 65 73 75 6c 74 .os8_test_result
ae20: 20 28 72 65 70 6c 79 2c 20 22 4d 6f 6e 69 74 6f (reply, "Monito
ae30: 72 20 50 72 6f 6d 70 74 22 2c 20 22 6f 73 38 5f r Prompt", "os8_
ae40: 70 69 70 5f 74 6f 20 33 22 29 0a 20 20 20 20 23 pip_to 3"). #
ae50: 20 64 65 74 61 63 68 20 70 74 72 0a 20 20 20 20 detach ptr.
ae60: 23 20 73 65 6c 66 2e 65 73 63 5f 74 6f 5f 73 69 # self.esc_to_si
ae70: 6d 68 20 28 29 0a 20 20 20 20 23 20 73 65 6c 66 mh (). # self
ae80: 2e 73 69 6d 68 5f 63 6d 64 20 28 27 64 65 74 61 .simh_cmd ('deta
ae90: 63 68 20 70 74 72 20 27 29 0a 20 20 20 20 23 20 ch ptr '). #
aea0: 73 65 6c 66 2e 6f 73 38 5f 72 65 73 74 61 72 74 self.os8_restart
aeb0: 20 28 29 0a 20 20 20 20 0a 20 20 20 20 23 20 52 (). . # R
aec0: 65 6d 6f 76 65 20 74 68 65 20 74 65 6d 70 20 66 emove the temp f
aed0: 69 6c 65 20 69 66 20 77 65 20 63 72 65 61 74 65 ile if we create
aee0: 64 20 6f 6e 65 2e 0a 20 20 20 20 69 66 20 64 69 d one.. if di
aef0: 64 5f 63 6f 6e 76 65 72 73 69 6f 6e 3a 0a 20 20 d_conversion:.
af00: 20 20 20 20 6f 73 2e 72 65 6d 6f 76 65 20 28 70 os.remove (p
af10: 74 29 0a 0a 0a 20 20 23 23 23 23 20 6f 73 38 5f t)... #### os8_
af20: 70 69 70 5f 66 72 6f 6d 20 23 23 23 23 23 23 23 pip_from #######
af30: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
af40: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
af50: 23 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 23 ############. #
af60: 20 46 65 74 63 68 20 61 20 66 69 6c 65 20 66 72 Fetch a file fr
af70: 6f 6d 20 4f 53 2f 38 20 74 6f 20 61 20 6c 6f 63 om OS/8 to a loc
af80: 61 6c 20 70 61 74 68 20 75 73 69 6e 67 20 50 49 al path using PI
af90: 50 2e 0a 20 20 23 0a 20 20 23 20 54 68 65 20 4f P.. #. # The O
afa0: 53 2f 38 20 73 6f 75 72 63 65 20 66 69 6c 65 6e S/8 source filen
afb0: 61 6d 65 20 69 73 20 73 79 6e 74 68 65 73 69 7a ame is synthesiz
afc0: 65 64 20 66 72 6f 6d 20 74 68 65 20 62 61 73 65 ed from the base
afd0: 6e 61 6d 65 20 6f 66 20 74 68 65 20 70 61 74 68 name of the path
afe0: 2c 0a 20 20 23 20 75 70 63 61 73 69 6e 67 20 69 ,. # upcasing i
aff0: 66 20 6e 65 63 65 73 73 61 72 79 2e 0a 20 20 23 f necessary.. #
b000: 0a 20 20 23 20 54 68 65 20 66 69 6c 65 20 69 73 . # The file is
b010: 20 73 65 6e 74 20 76 69 61 20 74 68 65 20 53 49 sent via the SI
b020: 4d 48 20 70 61 70 65 72 20 74 61 70 65 20 64 65 MH paper tape de
b030: 76 69 63 65 20 74 68 72 6f 75 67 68 20 50 49 50 vice through PIP
b040: 0a 20 20 23 20 73 70 65 63 69 66 79 69 6e 67 20 . # specifying
b050: 61 20 74 72 61 6e 73 66 65 72 20 6f 70 74 69 6f a transfer optio
b060: 6e 2e 20 20 49 66 20 6e 6f 20 6f 70 74 69 6f 6e n. If no option
b070: 20 69 73 20 73 70 65 63 69 66 69 65 64 2c 0a 20 is specified,.
b080: 20 23 20 41 53 43 49 49 20 69 73 20 61 73 73 75 # ASCII is assu
b090: 6d 65 64 2e 0a 20 20 23 0a 20 20 23 20 49 6e 20 med.. #. # In
b0a0: 41 53 43 49 49 20 6d 6f 64 65 2c 20 77 65 20 70 ASCII mode, we p
b0b0: 6f 73 74 2d 70 72 6f 63 65 73 73 20 77 69 74 68 ost-process with
b0c0: 20 70 74 70 32 74 78 74 20 77 68 69 63 68 20 74 ptp2txt which t
b0d0: 72 61 6e 73 6c 61 74 65 73 0a 20 20 23 20 50 4f ranslates. # PO
b0e0: 53 49 58 20 41 53 43 49 49 20 63 6f 6e 76 65 6e SIX ASCII conven
b0f0: 74 69 6f 6e 73 20 74 6f 20 4f 53 2f 38 20 63 6f tions to OS/8 co
b100: 6e 76 65 6e 74 69 6f 6e 73 2e 20 20 49 6e 20 61 nventions. In a
b110: 6c 6c 20 6f 74 68 65 72 0a 20 20 23 20 6d 6f 64 ll other. # mod
b120: 65 73 2c 20 77 65 20 64 6f 20 6e 6f 74 20 64 6f es, we do not do
b130: 20 61 6e 79 20 74 72 61 6e 73 6c 61 74 69 6f 6e any translation
b140: 2e 0a 20 20 23 0a 20 20 23 20 45 6e 74 72 79 20 .. #. # Entry
b150: 63 6f 6e 74 65 78 74 20 73 68 6f 75 6c 64 20 62 context should b
b160: 65 20 69 6e 73 69 64 65 20 4f 53 2f 38 2e 20 20 e inside OS/8.
b170: 45 78 69 74 20 63 6f 6e 74 65 78 74 20 69 73 20 Exit context is
b180: 69 6e 73 69 64 65 20 4f 53 2f 38 2e 0a 0a 20 20 inside OS/8...
b190: 64 65 66 20 6f 73 38 5f 70 69 70 5f 66 72 6f 6d def os8_pip_from
b1a0: 20 28 73 65 6c 66 2c 20 6f 73 38 6e 61 6d 65 2c (self, os8name,
b1b0: 20 70 61 74 68 2c 20 6f 70 74 69 6f 6e 20 3d 20 path, option =
b1c0: 4e 6f 6e 65 2c 20 64 65 62 75 67 3d 46 61 6c 73 None, debug=Fals
b1d0: 65 29 3a 0a 20 20 20 20 69 66 20 6f 70 74 69 6f e):. if optio
b1e0: 6e 20 3d 3d 20 4e 6f 6e 65 3a 20 6f 70 74 69 6f n == None: optio
b1f0: 6e 20 3d 20 22 22 0a 20 20 20 20 23 20 49 66 20 n = "". # If
b200: 70 61 74 68 20 69 73 20 6e 6f 74 20 61 20 66 69 path is not a fi
b210: 6c 65 2c 20 75 73 65 20 74 68 65 20 6e 61 6d 65 le, use the name
b220: 20 70 6f 72 74 69 6f 6e 20 6f 66 20 6f 73 38 6e portion of os8n
b230: 61 6d 65 2e 0a 20 20 20 20 69 66 20 6f 73 2e 70 ame.. if os.p
b240: 61 74 68 2e 69 73 64 69 72 28 70 61 74 68 29 3a ath.isdir(path):
b250: 0a 20 20 20 20 20 20 63 6f 6c 6f 6e 20 3d 20 6f . colon = o
b260: 73 38 6e 61 6d 65 2e 66 69 6e 64 28 27 3a 27 29 s8name.find(':')
b270: 0a 20 20 20 20 20 20 69 66 20 63 6f 6c 6f 6e 20 . if colon
b280: 3d 3d 20 2d 31 3a 20 20 20 20 20 20 20 20 20 20 == -1:
b290: 20 20 20 20 20 20 23 20 4e 6f 20 64 65 76 2c 20 # No dev,
b2a0: 6a 75 73 74 20 61 20 6e 61 6d 65 2e 0a 20 20 20 just a name..
b2b0: 20 20 20 20 20 70 61 74 68 20 3d 20 70 61 74 68 path = path
b2c0: 20 2b 20 22 2f 22 20 2b 20 6f 73 38 6e 61 6d 65 + "/" + os8name
b2d0: 0a 20 20 20 20 20 20 65 6c 73 65 3a 0a 20 20 20 . else:.
b2e0: 20 20 20 20 20 70 61 74 68 20 3d 20 70 61 74 68 path = path
b2f0: 20 2b 20 22 2f 22 20 2b 20 6f 73 38 6e 61 6d 65 + "/" + os8name
b300: 5b 63 6f 6c 6f 6e 2b 31 3a 5d 0a 0a 20 20 20 20 [colon+1:]..
b310: 69 66 20 6f 70 74 69 6f 6e 20 21 3d 20 22 22 20 if option != ""
b320: 61 6e 64 20 6f 70 74 69 6f 6e 20 6e 6f 74 20 69 and option not i
b330: 6e 20 73 65 6c 66 2e 5f 76 61 6c 69 64 5f 70 69 n self._valid_pi
b340: 70 5f 6f 70 74 69 6f 6e 73 3a 0a 20 20 20 20 20 p_options:.
b350: 20 70 72 69 6e 74 28 22 49 6e 76 61 6c 69 64 20 print("Invalid
b360: 50 49 50 20 6f 70 74 69 6f 6e 3a 20 22 20 2b 20 PIP option: " +
b370: 6f 70 74 69 6f 6e 20 2b 20 5c 0a 20 20 20 20 20 option + \.
b380: 20 20 20 20 20 22 2e 20 49 67 6e 6f 72 69 6e 67 ". Ignoring
b390: 20 6f 73 38 5f 70 69 70 5f 66 72 6f 6d 20 6f 6e os8_pip_from on
b3a0: 3a 20 22 20 2b 20 70 61 74 68 29 0a 20 20 20 20 : " + path).
b3b0: 20 20 72 65 74 75 72 6e 0a 0a 20 20 20 20 72 65 return.. re
b3c0: 70 6c 79 20 3d 20 73 65 6c 66 2e 73 69 6d 68 5f ply = self.simh_
b3d0: 63 6d 64 20 28 27 61 74 74 61 63 68 20 70 74 70 cmd ('attach ptp
b3e0: 20 27 20 2b 20 70 61 74 68 2c 20 64 65 62 75 67 ' + path, debug
b3f0: 3d 64 65 62 75 67 29 0a 20 20 20 20 73 65 6c 66 =debug). self
b400: 2e 73 69 6d 68 5f 74 65 73 74 5f 72 65 73 75 6c .simh_test_resul
b410: 74 28 72 65 70 6c 79 2c 20 22 50 72 6f 6d 70 74 t(reply, "Prompt
b420: 22 2c 20 22 6f 73 38 5f 70 69 70 5f 66 72 6f 6d ", "os8_pip_from
b430: 20 61 74 74 61 63 68 6e 67 20 70 74 70 22 29 0a attachng ptp").
b440: 20 20 20 20 23 20 45 6e 74 65 72 20 4f 53 2f 38 # Enter OS/8
b450: 2e 0a 20 20 20 20 73 65 6c 66 2e 73 69 6d 68 5f .. self.simh_
b460: 72 65 73 74 61 72 74 5f 6f 73 38 20 28 63 61 6c restart_os8 (cal
b470: 6c 65 72 3d 22 6f 73 38 5f 70 69 70 5f 66 72 6f ler="os8_pip_fro
b480: 6d 20 30 22 29 0a 20 20 20 20 0a 20 20 20 20 72 m 0"). . r
b490: 65 70 6c 79 20 3d 20 73 65 6c 66 2e 6f 73 38 5f eply = self.os8_
b4a0: 63 6d 64 20 28 27 52 20 50 49 50 27 2c 20 64 65 cmd ('R PIP', de
b4b0: 62 75 67 3d 64 65 62 75 67 29 0a 20 20 20 20 23 bug=debug). #
b4c0: 20 48 61 73 20 50 49 50 20 53 74 61 72 74 75 70 Has PIP Startup
b4d0: 20 62 65 65 6e 20 73 75 63 63 65 73 73 66 75 6c been successful
b4e0: 3f 0a 20 20 20 20 69 66 20 73 65 6c 66 2e 6f 73 ?. if self.os
b4f0: 38 5f 74 65 73 74 5f 72 65 73 75 6c 74 20 28 72 8_test_result (r
b500: 65 70 6c 79 2c 20 22 43 6f 6d 6d 61 6e 64 20 44 eply, "Command D
b510: 65 63 6f 64 65 72 20 50 72 6f 6d 70 74 22 2c 20 ecoder Prompt",
b520: 22 6f 73 38 5f 70 69 70 5f 66 72 6f 6d 20 30 22 "os8_pip_from 0"
b530: 29 20 3d 3d 20 46 61 6c 73 65 3a 20 72 65 74 75 ) == False: retu
b540: 72 6e 0a 20 20 20 20 0a 20 20 20 20 23 20 49 73 rn. . # Is
b550: 73 75 65 20 66 69 6c 65 20 74 72 61 6e 73 66 65 sue file transfe
b560: 72 20 73 70 65 63 2e 0a 20 20 20 20 72 65 70 6c r spec.. repl
b570: 79 20 3d 20 73 65 6c 66 2e 6f 73 38 5f 63 6d 64 y = self.os8_cmd
b580: 20 28 27 50 54 50 3a 3c 27 20 2b 20 6f 73 38 6e ('PTP:<' + os8n
b590: 61 6d 65 20 2b 20 6f 70 74 69 6f 6e 2c 20 64 65 ame + option, de
b5a0: 62 75 67 3d 64 65 62 75 67 29 0a 20 20 20 20 23 bug=debug). #
b5b0: 20 54 65 73 74 20 66 6f 72 20 53 75 63 63 65 73 Test for Succes
b5c0: 73 0a 20 20 20 20 69 66 20 73 65 6c 66 2e 6f 73 s. if self.os
b5d0: 38 5f 74 65 73 74 5f 72 65 73 75 6c 74 20 28 72 8_test_result (r
b5e0: 65 70 6c 79 2c 20 22 43 6f 6d 6d 61 6e 64 20 44 eply, "Command D
b5f0: 65 63 6f 64 65 72 20 50 72 6f 6d 70 74 22 2c 20 ecoder Prompt",
b600: 22 6f 73 38 5f 70 69 70 5f 66 72 6f 6d 20 31 22 "os8_pip_from 1"
b610: 29 20 3d 3d 20 46 61 6c 73 65 3a 0a 20 20 20 20 ) == False:.
b620: 20 20 23 20 54 68 65 72 65 20 69 73 20 61 6e 20 # There is an
b630: 65 6d 70 74 79 20 50 54 50 20 66 69 6c 65 20 77 empty PTP file w
b640: 65 20 6e 65 65 64 20 74 6f 20 72 65 6d 6f 76 65 e need to remove
b650: 2e 0a 20 20 20 20 20 20 6f 73 2e 72 65 6d 6f 76 .. os.remov
b660: 65 28 70 61 74 68 29 0a 20 20 20 20 20 20 23 20 e(path). #
b670: 57 61 73 20 74 68 69 73 20 61 20 66 61 74 61 6c Was this a fatal
b680: 20 65 72 72 6f 72 3f 0a 20 20 20 20 20 20 69 66 error?. if
b690: 20 73 65 6c 66 2e 5f 6f 73 38 5f 72 65 70 6c 69 self._os8_repli
b6a0: 65 73 5b 72 65 70 6c 79 5d 5b 32 5d 20 3d 3d 20 es[reply][2] ==
b6b0: 46 61 6c 73 65 3a 0a 20 20 20 20 20 20 20 20 73 False:. s
b6c0: 65 6c 66 2e 6f 73 38 5f 73 65 6e 64 5f 63 74 72 elf.os8_send_ctr
b6d0: 6c 20 28 27 5b 27 29 20 20 20 20 20 20 23 20 4e l ('[') # N
b6e0: 6f 6e 2d 66 61 74 61 6c 20 65 72 72 6f 72 2e 20 on-fatal error.
b6f0: 4d 75 73 74 20 65 78 69 74 20 50 49 50 0a 20 20 Must exit PIP.
b700: 20 20 20 20 72 65 74 75 72 6e 0a 0a 20 20 20 20 return..
b710: 73 65 6c 66 2e 6f 73 38 5f 73 65 6e 64 5f 63 74 self.os8_send_ct
b720: 72 6c 20 28 27 5b 27 29 20 20 20 20 20 20 23 20 rl ('[') #
b730: 65 78 69 74 20 50 49 50 0a 20 20 20 20 23 20 4d exit PIP. # M
b740: 75 73 74 20 77 61 69 74 20 66 6f 72 20 6d 6f 6e ust wait for mon
b750: 69 74 6f 72 20 70 72 6f 6d 70 74 2e 20 43 6f 6d itor prompt. Com
b760: 70 6c 61 69 6e 20 69 66 20 77 65 20 64 6f 6e 27 plain if we don'
b770: 74 20 67 65 74 20 69 74 21 0a 20 20 20 20 72 65 t get it!. re
b780: 70 6c 79 20 3d 20 73 65 6c 66 2e 63 68 69 6c 64 ply = self.child
b790: 5f 65 78 70 65 63 74 20 28 73 65 6c 66 2e 5f 6f _expect (self._o
b7a0: 73 38 5f 72 65 70 6c 69 65 73 5f 72 65 78 29 0a s8_replies_rex).
b7b0: 20 20 20 20 73 65 6c 66 2e 6f 73 38 5f 74 65 73 self.os8_tes
b7c0: 74 5f 72 65 73 75 6c 74 20 28 72 65 70 6c 79 2c t_result (reply,
b7d0: 20 22 4d 6f 6e 69 74 6f 72 20 50 72 6f 6d 70 74 "Monitor Prompt
b7e0: 22 2c 20 22 6f 73 38 5f 70 69 70 5f 66 72 6f 6d ", "os8_pip_from
b7f0: 20 32 22 29 0a 0a 20 20 20 20 72 65 70 6c 79 20 2").. reply
b800: 3d 20 73 65 6c 66 2e 73 69 6d 68 5f 63 6d 64 20 = self.simh_cmd
b810: 28 27 64 65 74 61 63 68 20 70 74 70 27 2c 20 64 ('detach ptp', d
b820: 65 62 75 67 3d 64 65 62 75 67 29 20 20 23 20 43 ebug=debug) # C
b830: 6c 65 61 6e 20 66 6c 75 73 68 20 6f 66 20 62 75 lean flush of bu
b840: 66 66 65 72 73 2e 0a 20 20 20 20 73 65 6c 66 2e ffers.. self.
b850: 73 69 6d 68 5f 74 65 73 74 5f 72 65 73 75 6c 74 simh_test_result
b860: 28 72 65 70 6c 79 2c 20 22 50 72 6f 6d 70 74 22 (reply, "Prompt"
b870: 2c 20 22 6f 73 38 5f 70 69 70 5f 66 72 6f 6d 20 , "os8_pip_from
b880: 64 65 74 61 63 68 69 6e 67 20 70 74 70 22 29 0a detaching ptp").
b890: 20 20 20 20 23 20 45 6e 74 65 72 20 4f 53 2f 38 # Enter OS/8
b8a0: 2e 0a 20 20 20 20 73 65 6c 66 2e 73 69 6d 68 5f .. self.simh_
b8b0: 72 65 73 74 61 72 74 5f 6f 73 38 28 63 61 6c 6c restart_os8(call
b8c0: 65 72 3d 22 6f 73 38 5f 70 69 70 5f 66 72 6f 6d er="os8_pip_from
b8d0: 20 33 22 29 0a 0a 20 20 20 20 69 66 20 6f 70 74 3").. if opt
b8e0: 69 6f 6e 20 3d 3d 20 22 22 20 6f 72 20 6f 70 74 ion == "" or opt
b8f0: 69 6f 6e 20 3d 3d 20 22 2f 41 22 3a 0a 20 20 20 ion == "/A":.
b900: 20 20 20 69 66 20 73 65 6c 66 2e 76 65 72 62 6f if self.verbo
b910: 73 65 3a 20 70 72 69 6e 74 28 22 46 6f 72 6d 61 se: print("Forma
b920: 74 20 63 6f 6e 76 65 72 74 69 6e 67 20 22 20 2b t converting " +
b930: 20 70 61 74 68 29 0a 20 20 20 20 20 20 23 20 43 path). # C
b940: 6f 6e 76 65 72 74 20 74 65 78 74 20 66 69 6c 65 onvert text file
b950: 20 74 6f 20 53 49 4d 48 20 70 61 70 65 72 20 74 to SIMH paper t
b960: 61 70 65 20 66 6f 72 6d 61 74 0a 20 20 20 20 20 ape format.
b970: 20 62 64 69 72 20 3d 20 70 69 64 70 38 69 2e 64 bdir = pidp8i.d
b980: 69 72 73 2e 62 75 69 6c 64 0a 20 20 20 20 20 20 irs.build.
b990: 23 20 43 72 65 61 74 65 20 75 6e 69 71 75 69 66 # Create uniquif
b9a0: 69 65 64 20 74 65 6d 70 20 70 61 74 68 20 6e 61 ied temp path na
b9b0: 6d 65 2e 0a 20 20 20 20 20 20 70 66 20 3d 20 70 me.. pf = p
b9c0: 61 74 68 20 2b 20 22 2d 22 20 2b 20 73 74 72 28 ath + "-" + str(
b9d0: 6f 73 2e 67 65 74 70 69 64 28 29 29 20 2b 20 22 os.getpid()) + "
b9e0: 2e 70 66 5f 74 65 6d 70 22 0a 20 20 20 20 20 20 .pf_temp".
b9f0: 6f 73 2e 72 65 6e 61 6d 65 28 70 61 74 68 2c 20 os.rename(path,
ba00: 70 66 29 0a 20 20 20 20 20 20 74 6f 6f 6c 20 3d pf). tool =
ba10: 20 6f 73 2e 70 61 74 68 2e 6a 6f 69 6e 20 28 62 os.path.join (b
ba20: 64 69 72 2c 20 27 62 69 6e 27 2c 20 27 70 74 70 dir, 'bin', 'ptp
ba30: 32 74 78 74 27 29 0a 20 20 20 20 20 20 73 75 62 2txt'). sub
ba40: 70 72 6f 63 65 73 73 2e 63 61 6c 6c 20 28 74 6f process.call (to
ba50: 6f 6c 20 2b 20 27 20 3c 20 27 20 2b 20 70 66 20 ol + ' < ' + pf
ba60: 2b 20 27 20 3e 20 27 20 2b 20 70 61 74 68 2c 20 + ' > ' + path,
ba70: 73 68 65 6c 6c 20 3d 20 54 72 75 65 29 0a 20 20 shell = True).
ba80: 20 20 20 20 6f 73 2e 72 65 6d 6f 76 65 28 70 66 os.remove(pf
ba90: 29 0a ).