Linux/socat

From Omnia
Revision as of 15:01, 30 March 2018 by Kenneth (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


Client:

killall -s 9 socat; sleep 5
while true ; do /usr/bin/socat pty,link=/dev/virtual0,waitslave tcp:socatserver.oeey.com:3333 ; sleep .001 ; done

Server:

/usr/bin/socat tcp-listen:3333,reuseaddr,fork file:/dev/ttyUSB0,nonblock,waitlock=/var/run/tty0.lock,b115200,raw,echo=0


socat-client.sh:

#!/bin/bash
set -e

if [ -z "$1" -o -z "$2" ]; then
    echo "Usage:    socat-client <server_url> <uart_path>"
    echo "Example:  socat-client target-pi /dev/ttyUSB0"
    exit 1
fi

trap "exit 1" SIGINT SIGKILL SIGTERM
while true; do
    killall -s 9 socat &> /dev/null || true
    echo "Starting socat client"
    /usr/bin/socat pty,link=$2,waitslave,unlink-close=0 tcp:$1:3333
done