File:  [HATARI the Atari ST Emulator] / hatari / tools / hatari-local-rs232.sh
Revision 1.1.1.3 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 9 08:56:04 2019 UTC (7 years, 3 months ago) by root
Branches: hatari, MAIN
CVS tags: hatari02210, hatari02200, hatari02100, hatari02000, hatari01900, HEAD
hatari 1.9.0

#!/bin/sh
#
# Start two Hatari instances connected through emulated rs232 connection.
# Given arguments (if any) are passed to the invoked Hatari instances.
# Their rs232 connection goes through shared local fifo file.
#
# To run development version of Hatari, use something like:
#	PATH=../../build/src:$PATH hatari-local-rs232.sh <options>

# open fifos
for i in 1 2; do
	mkfifo rs232-$i
	if [ $? -ne 0 ]; then
		echo "ERROR: creating FIFO 'midi$i' for RS232 communication failed!"
		exit 1
	fi
done

# show full path
hatari=$(which hatari)

# pass all args to the Hatari instances
args=$*

# connect the Hatari instances with fifos
echo "$hatari --rs232-in rs232-1 --rs232-out rs232-2 $args &"
hatari --rs232-in rs232-1 --rs232-out rs232-2 $args &
echo "$hatari --rs232-in rs232-2 --rs232-out rs232-1 $args &"
hatari --rs232-in rs232-2 --rs232-out rs232-1 $args &

# Without this Hataris would deadlock as fifos
# block the process until both ends are opened.
# Hatari opens rs232 output first (for writing),
# so this needs to read it.
catpids=""
cat rs232-2 >/dev/null &
catpids="$catpids $!"
cat rs232-1 >/dev/null &
catpids="$catpids $!"

# after connections are open, fifo files can be removed
sleep 2
for i in 1 2; do
	rm rs232-$i
done
# as can the 'cat' processes
kill -9 $catpids

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.