PiDP-8/I Software

Check-in [be3a3d9bd0]
Log In

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Merged pidp8i-tmux down to trunk
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: be3a3d9bd0c7b6a192f420d40a37623e04f3108155db345eba56094f510ee6f4
User & Date: tangent 2019-10-05 11:27:39.687
Context
2019-10-21
04:34
Fixed some heading levels in the top-level README.md file check-in: a8298c604e user: tangent tags: trunk
2019-10-05
11:27
Merged pidp8i-tmux down to trunk check-in: be3a3d9bd0 user: tangent tags: trunk
11:17
Merged usb-floppy down to trunk check-in: 348a62931c user: tangent tags: trunk
2019-10-04
18:53
Move README.md runtime configuration section below compile configuration section. Closed-Leaf check-in: 3d0d5dc385 user: ryan tags: pidp8i-tmux
Changes
Unified Diff Ignore Whitespace Patch
Changes to README.md.
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
build and run `systemctl` commands for you when you pass it arguments:

    $ pidp8i start
    $ pidp8i stop
    $ pidp8i restart
    $ pidp8i status -l

If you run it without arguments, it attaches to the GNU screen(1)
session, just as it always has.

The last command above shows that *all* arguments are passed to
`systemctl`, not just the first, so you can pass any flags that
`systemctl` accepts.

Our systemd service starts at boot by default after you install the







|







286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
build and run `systemctl` commands for you when you pass it arguments:

    $ pidp8i start
    $ pidp8i stop
    $ pidp8i restart
    $ pidp8i status -l

If you run it without arguments, it attaches to the screen manager
session, just as it always has.

The last command above shows that *all* arguments are passed to
`systemctl`, not just the first, so you can pass any flags that
`systemctl` accepts.

Our systemd service starts at boot by default after you install the
728
729
730
731
732
733
734



























735
736
737
738
739
740
741
    the file acts as build documentation as well as a "welcome" message.


#### --help

Run `./configure --help` for more information on your options here.





























## <a id="os8di"></a>The OS/8 RK05 Disk Image

For the first several years of the PiDP-8/I project, the OS/8 RK05 disk
image included with the PiDP-8/I software (called `os8.rk05`) was based
on an image of a real RK05 disk pack that someone allegedly found in a
salvaged PDP-8 system.  Parts of the image were corrupt, and not all of







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
    the file acts as build documentation as well as a "welcome" message.


#### --help

Run `./configure --help` for more information on your options here.


<a id="runtime"></a>
## Runtime Configuration

The `pidp8i` command may be configured by the optional `pidp8i.rc` file,
located by default in `/opt/pidp8i/etc/`.  This is a Bourne shell script
which is sourced by `pidp8i` if it exists, and recognizes the following
variables:


<a id="rc-screen-manager"></a>
### SCREEN_MANAGER=screen

By default, pidp8i installs and uses [GNU screen(1)][gnuscreen] to
manage screen sessions.  However, if you prefer to use [tmux(1)][tmux]
as a screen manager for the pidp8i session, you may set
`SCREEN_MANAGER=tmux`.  Note that if you make this change, you are
responsible for installing tmux; on Raspbian, this is done by:

        $ sudo apt-get install tmux

Switching between configured screen managers must be done while pidp8i
is stopped.

[gnuscreen]: https://www.gnu.org/software/screen/
[tmux]:      https://tmux.github.io/


## <a id="os8di"></a>The OS/8 RK05 Disk Image

For the first several years of the PiDP-8/I project, the OS/8 RK05 disk
image included with the PiDP-8/I software (called `os8.rk05`) was based
on an image of a real RK05 disk pack that someone allegedly found in a
salvaged PDP-8 system.  Parts of the image were corrupt, and not all of
Changes to bin/pidp8i.in.
1
2
3
4
5
6
7
8
9
10
11
#!/bin/bash
########################################################################
# pidp8i.in - Collection of scriptlets for dealing with the pidp8i
#   systemd user service and its associated screen(1) session.
#
# Copyright © 2015-2019 Oscar Vermeulen and Warren Young
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,



|







1
2
3
4
5
6
7
8
9
10
11
#!/bin/bash
########################################################################
# pidp8i.in - Collection of scriptlets for dealing with the pidp8i
#   systemd user service and its associated screen manager session.
#
# Copyright © 2015-2019 Oscar Vermeulen and Warren Young
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
33
34
35
36
37
38
39






40




41
42

43
44
45




46

47
48
49
50
51
52
53
54
55




56

57
58
59
60
61
62
63
64
65
66
bootdir="@BOOTDIR@"
prefix="@ABSPREFIX@"
sim="$prefix/bin/pidp8i-sim"
scanswitch="$prefix/libexec/scanswitch"
systemctl=$(uname -r | grep -qw Microsoft && echo /bin/nothing || echo /bin/systemctl)
ggrep=$(which ggrep grep 2> /dev/null | head -1)







is_running() {




    procs=`screen -list pidp8i | $ggrep -Pc '\d\.pidp8i'`
    test -n "$procs" && test $procs -gt 0 && return 0 || return 1

}

sim_child_pid() {




    screen -ls pidp8i | grep -Eo '[[:digit:]]+\.pidp8i' | grep -Eo '^[[:digit:]]+'

}

# Were we given a command line argument?
if [ -z "$1" ]
then
    # No, so just try to attach to the running simulator
    if is_running
    then
        echo Joining simulator session already in progress...




        screen -r -S pidp8i

    else
        cat <<ERROR
Either the simulator isn't running, or it isn't running under a screen(1)
session owned by @INSTUSR@.  Did you start the simulator via systemd?

ERROR
		exit 1
    fi
fi








>
>
>
>
>
>

>
>
>
>
|
|
>



>
>
>
>
|
>









>
>
>
>
|
>


|







33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
bootdir="@BOOTDIR@"
prefix="@ABSPREFIX@"
sim="$prefix/bin/pidp8i-sim"
scanswitch="$prefix/libexec/scanswitch"
systemctl=$(uname -r | grep -qw Microsoft && echo /bin/nothing || echo /bin/systemctl)
ggrep=$(which ggrep grep 2> /dev/null | head -1)

if [ -e "$prefix/etc/pidp8i.rc" ]
then
    . "$prefix/etc/pidp8i.rc"
fi
[ -n "$SCREEN_MANAGER" ] || SCREEN_MANAGER=screen

is_running() {
    if [ "$SCREEN_MANAGER" = "tmux" ]
    then
        tmux has-session -t pidp8i 2>/dev/null
    else
        procs=`screen -list pidp8i | $ggrep -Pc '\d\.pidp8i'`
        test -n "$procs" && test $procs -gt 0 && return 0 || return 1
    fi
}

sim_child_pid() {
    if [ "$SCREEN_MANAGER" = "tmux" ]
    then
        tmux list-sessions -F '#{session_name} #{pid}' | awk '/^pidp8i / {print $2}'
    else
        screen -ls pidp8i | grep -Eo '[[:digit:]]+\.pidp8i' | grep -Eo '^[[:digit:]]+'
    fi
}

# Were we given a command line argument?
if [ -z "$1" ]
then
    # No, so just try to attach to the running simulator
    if is_running
    then
        echo Joining simulator session already in progress...
        if [ "$SCREEN_MANAGER" = "tmux" ]
        then
            exec tmux attach-session -d -t pidp8i
        else
            exec screen -r -S pidp8i
        fi
    else
        cat <<ERROR
Either the simulator isn't running, or it isn't running under a ${SCREEN_MANAGER}
session owned by @INSTUSR@.  Did you start the simulator via systemd?

ERROR
		exit 1
    fi
fi

120
121
122
123
124
125
126

127




128

129

130

131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153






154


155
156
157
158
159
160
161
    fi

    # We want SIMH to have a sensible working directory: somewhere the
    # user can write files and which makes sense when giving SIMH
    # commands involving file paths.  This default is chosen because it
    # satisfies both criteria.
    # If you change the default here, change that script as well.

    cd "$prefix/share/media" &&




        screen -dm -S pidp8i "$sim" "$bscript" &&

		( ! test -x $systemctl ||

		  systemd-notify --ready --pid=$(sim_child_pid) ) &&

		exit 0
    exit 1
elif [ "$verb" = "stop" ]
then
    # Someone (maybe the user via "pidp8i stop", maybe systemd via
    # "systemctl pidp8i stop") is telling us to stop the background
    # simulator.
    #
    # First figure out what the simulator is called and send it the
    # signal that shuts it down gracefully.
    for sim in pdp8 pidp8i-sim
    do
        if pkill -0 $sim
        then
            # Give it the signal to start shutting down gracefully: stop
            # GPIO thread, save simulator state if savestate enabled...
            # Give it time to complete, then kill it hard in case it
            # doesn't die on its own.
            echo -n "Stopping $sim simulator..."
            for sig in TERM KILL ; do pkill -$sig $sim ; sleep 1 ; done

            # screen(1) might still be running despite its only child
            # dying.  Nuke it hard if so.






            if is_running ; then screen -S pidp8i -X quit ; fi



            exit 0
        fi
    done 

    exit 1
fi







>
|
>
>
>
>
|
>
|
>
|
>
|
<



















|
|
>
>
>
>
>
>
|
>
>







141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160

161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
    fi

    # We want SIMH to have a sensible working directory: somewhere the
    # user can write files and which makes sense when giving SIMH
    # commands involving file paths.  This default is chosen because it
    # satisfies both criteria.
    # If you change the default here, change that script as well.
    set -e
    cd "$prefix/share/media"
    if [ "$SCREEN_MANAGER" = "tmux" ]
    then
        tmux new-session -s pidp8i -d "$sim" "$bscript"
    else
        screen -dm -S pidp8i "$sim" "$bscript"
    fi
    if [ -x $systemctl ]
    then
        systemd-notify --ready --pid=$(sim_child_pid)
    fi
    exit 0

elif [ "$verb" = "stop" ]
then
    # Someone (maybe the user via "pidp8i stop", maybe systemd via
    # "systemctl pidp8i stop") is telling us to stop the background
    # simulator.
    #
    # First figure out what the simulator is called and send it the
    # signal that shuts it down gracefully.
    for sim in pdp8 pidp8i-sim
    do
        if pkill -0 $sim
        then
            # Give it the signal to start shutting down gracefully: stop
            # GPIO thread, save simulator state if savestate enabled...
            # Give it time to complete, then kill it hard in case it
            # doesn't die on its own.
            echo -n "Stopping $sim simulator..."
            for sig in TERM KILL ; do pkill -$sig $sim ; sleep 1 ; done

            # The screen manager might still be running despite its
            # only child dying.  Nuke it hard if so.
            if is_running
            then
                if [ "$SCREEN_MANAGER" = "tmux" ]
                then
                    tmux kill-session -t pidp8i
                else
                    screen -S pidp8i -X quit
                fi
            fi

            exit 0
        fi
    done 

    exit 1
fi