70 lines
2.7 KiB
Bash
Executable file
70 lines
2.7 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Part of JoeyLib, Copyright (c) 2026 Scott Duensing, under the MIT License.
|
|
# See LICENSE.md for license information.
|
|
# SPDX-License-Identifier: MIT
|
|
#
|
|
# verify-win16-serial.sh - both-directions RS-232 gate for the Win16 port.
|
|
#
|
|
# Runs SERTEST.EXE (examples/sertest: banner, then echo) on Windows 3.11
|
|
# under DOSBox (scripts/lib/win16Gate.sh) with COM1 as a nullmodem
|
|
# connecting to the host peer (scripts/lib/serialLoopPeer.py), which waits
|
|
# for the banner, sends a probe and expects it echoed. That exercises the
|
|
# chain: JoeyLib's Win16 serial HAL -> OpenComm/WriteComm/ReadComm ->
|
|
# KPCOMM.DRV (the communications driver JoeyLib's Windows runs with in place
|
|
# of COMM.DRV) and Windows' virtual COM device -> DOSBox's UART -> host.
|
|
#
|
|
# Then the DTR check (--dtr-check), as verify-dvx-serial.sh does it: the
|
|
# nullmodem runs non-transparent, so DOSBox reports the guest's modem lines to
|
|
# the peer in the byte stream, and SERTEST drops and raises DTR, closes and
|
|
# reopens the port, then hangs up. jlSerialSetDtr must reach the line, and
|
|
# jlSerialClose must leave DTR as it is, up or down: KPCOMM.DRV keeps it at
|
|
# CloseComm when the HAL asks (KPESC_KEEP_DTR_ON_CLOSE).
|
|
#
|
|
# Usage: scripts/verify-win16-serial.sh
|
|
# Env: WIN16_SERIAL_PORT TCP port the peer listens on (default 6804)
|
|
# Requires: Windows on DOSBox (install.sh install emulator:win16), python3;
|
|
# build/win16/bin/SERTEST.EXE (make win16).
|
|
|
|
set -uo pipefail
|
|
|
|
repo=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
|
|
source "$repo/scripts/lib/joeyEnv.sh"
|
|
source "$repo/scripts/lib/win16Gate.sh"
|
|
|
|
label=verify-win16-serial
|
|
win16Need
|
|
program=$(joeyExampleProgram sertest win16)
|
|
[ -f "$program" ] || { echo "$label: build SERTEST.EXE first (make win16)" >&2; exit 2; }
|
|
port="${WIN16_SERIAL_PORT:-6804}"
|
|
# The peer's budget: Windows' boot, the banner and the echo, then the DTR check.
|
|
wall=95
|
|
|
|
work=$(mktemp -d -t joeylib-win16-serial.XXXXXX)
|
|
peerPid=""
|
|
cleanup() {
|
|
joeyStop "$peerPid"
|
|
win16Stop
|
|
rm -rf "$work"
|
|
}
|
|
trap cleanup EXIT
|
|
|
|
python3 "$repo/scripts/lib/serialLoopPeer.py" tcp-server "$port" "$wall" --dtr-check > "$work/peer.log" 2>&1 &
|
|
peerPid=$!
|
|
sleep 1
|
|
mkdir -p "$work/program"
|
|
cp "$program" "$work/program/SERTEST.EXE"
|
|
win16Stage "$work" "$work/program" SERTEST.EXE
|
|
# transparent:0 -- DOSBox sends the guest's modem lines in-band, which the
|
|
# peer's --dtr-check reads.
|
|
WIN16_DOSBOX_ARGS=(--set "serial1=nullmodem server:127.0.0.1 port:$port transparent:0")
|
|
win16Start "$work"
|
|
wait "$peerPid"
|
|
rc=$?
|
|
peerPid=""
|
|
cat "$work/peer.log"
|
|
if [ "$rc" -eq 0 ]; then
|
|
echo "$label: PASS (banner out, probe echoed through COM1; DTR follows jlSerialSetDtr and survives jlSerialClose)"
|
|
else
|
|
echo "$label: FAIL" >&2
|
|
fi
|
|
exit "$rc"
|