pydw

Check-in [93c183e96a]
Login

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

Overview
Comment:Cleanup (close writable disks) and exit on interrupt
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256:93c183e96aa8f889873e4ce649eea242db6c253d214aba412ecb0787ede17c04
User & Date: ajv-899-334-8894@vsta.org 2016-07-15 22:41:49
Context
2016-07-16
02:14
Enable exception handling. Set up to actually break from one client and start serving the next. Add ^C handler so we can cleanly exit. check-in: 4f9e162437 user: ajv-899-334-8894@vsta.org tags: master, trunk
2016-07-15
22:41
Cleanup (close writable disks) and exit on interrupt check-in: 93c183e96a user: ajv-899-334-8894@vsta.org tags: master, trunk
2016-07-13
03:14
Initial project commit check-in: cba7297ed1 user: ajv-899-334-8894@vsta.org tags: master, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to dw.py.

4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
...
146
147
148
149
150
151
152










153
154
155
156
157
158
159
...
186
187
188
189
190
191
192



193
194
195
196
197
198
199
#
# The Coco world has a "drivewire" RS-232 protocol for serving
#  storage (and, later, date/time, terminals, debugging, ...).
# Later, this protocol was implemented in emulators, and talks
#  over TCP instead of RS-232.
# This Python utility talks that DriveWire-over-TCP protocol
#  to serve disk images along with terminals.
import sys, socket, time
import disk, tty

# Default port number
Pnum = 65504

# Ops not to log
Noisy = frozenset([0x43])
................................................................................
    0xD2: ("readx", disk.readx),
    0xF2: ("re-readx", disk.readx),
    0x45: ("serinit", tty.init),
    0x43: ("serread", tty.read),
    0x63: ("serreadm", tty.readm),
    0xC3: ("serrite", tty.write),
}











# A DriveWire client has connected
def serve(conn):
    global Noise, Ops

    while True:

................................................................................
    startup()

    # Set up the network
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    s.bind( ("", Pnum) )
    s.listen(5)




    # Bring it
    while True:
	conn,tup = s.accept()
	print "DW client", tup

	# Talk to them







|







 







>
>
>
>
>
>
>
>
>
>







 







>
>
>







4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
...
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
...
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
#
# The Coco world has a "drivewire" RS-232 protocol for serving
#  storage (and, later, date/time, terminals, debugging, ...).
# Later, this protocol was implemented in emulators, and talks
#  over TCP instead of RS-232.
# This Python utility talks that DriveWire-over-TCP protocol
#  to serve disk images along with terminals.
import sys, socket, time, signal
import disk, tty

# Default port number
Pnum = 65504

# Ops not to log
Noisy = frozenset([0x43])
................................................................................
    0xD2: ("readx", disk.readx),
    0xF2: ("re-readx", disk.readx),
    0x45: ("serinit", tty.init),
    0x43: ("serread", tty.read),
    0x63: ("serreadm", tty.readm),
    0xC3: ("serrite", tty.write),
}

# Close (and thus flush out) all writable devices
def cleanexit(signo, frame):
    print "Interrupt, exiting..."
    for tup in disk.Drives.itervalues():
	if tup[0]:
	    continue
	tup[1].close()
    print " OK"
    sys.exit(0)

# A DriveWire client has connected
def serve(conn):
    global Noise, Ops

    while True:

................................................................................
    startup()

    # Set up the network
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    s.bind( ("", Pnum) )
    s.listen(5)

    # We want to fclose() all our writable devices before leaving
    signal.signal(signal.SIGINT, cleanexit)

    # Bring it
    while True:
	conn,tup = s.accept()
	print "DW client", tup

	# Talk to them