Annotation of hatari/tools/hatari-local-rs232.sh, revision 1.1.1.3

1.1       root        1: #!/bin/sh
                      2: #
                      3: # Start two Hatari instances connected through emulated rs232 connection.
                      4: # Given arguments (if any) are passed to the invoked Hatari instances.
                      5: # Their rs232 connection goes through shared local fifo file.
1.1.1.2   root        6: #
                      7: # To run development version of Hatari, use something like:
                      8: #      PATH=../../build/src:$PATH hatari-local-rs232.sh <options>
1.1       root        9: 
                     10: # open fifos
                     11: for i in 1 2; do
                     12:        mkfifo rs232-$i
1.1.1.3 ! root       13:        if [ $? -ne 0 ]; then
        !            14:                echo "ERROR: creating FIFO 'midi$i' for RS232 communication failed!"
        !            15:                exit 1
        !            16:        fi
1.1       root       17: done
                     18: 
1.1.1.2   root       19: # show full path
                     20: hatari=$(which hatari)
                     21: 
1.1       root       22: # pass all args to the Hatari instances
1.1.1.2   root       23: args=$*
1.1       root       24: 
                     25: # connect the Hatari instances with fifos
1.1.1.2   root       26: echo "$hatari --rs232-in rs232-1 --rs232-out rs232-2 $args &"
                     27: hatari --rs232-in rs232-1 --rs232-out rs232-2 $args &
                     28: echo "$hatari --rs232-in rs232-2 --rs232-out rs232-1 $args &"
                     29: hatari --rs232-in rs232-2 --rs232-out rs232-1 $args &
1.1       root       30: 
                     31: # Without this Hataris would deadlock as fifos
                     32: # block the process until both ends are opened.
                     33: # Hatari opens rs232 output first (for writing),
                     34: # so this needs to read it.
                     35: catpids=""
                     36: cat rs232-2 >/dev/null &
                     37: catpids="$catpids $!"
                     38: cat rs232-1 >/dev/null &
                     39: catpids="$catpids $!"
                     40: 
                     41: # after connections are open, fifo files can be removed
                     42: sleep 2
                     43: for i in 1 2; do
                     44:        rm rs232-$i
                     45: done
                     46: # as can the 'cat' processes
                     47: 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.