Linux/socat: Difference between revisions
< Linux
No edit summary |
|||
Line 33: | Line 33: | ||
done | done | ||
</pre> | </pre> | ||
== ser2net == | |||
Alt - see [[Linux/ser2net]] | |||
== keywords == | == keywords == |
Revision as of 16:02, 10 March 2025
socat
Install:
sudo apt install socat
Server:
/usr/bin/socat tcp-listen:3333,reuseaddr,fork file:/dev/ttyUSB0,nonblock,waitlock=/var/run/tty0.lock,b115200,raw,echo=0
/usr/bin/socat tcp-listen:3333,reuseaddr,fork file:/dev/uart,nonblock,waitlock=/var/run/tty0.lock,b115200,raw,echo=0
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
while true ; do /usr/bin/socat pty,link=/dev/uart,waitslave tcp:socatserver.oeey.com:3333 ; sleep .001 ; done
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
ser2net
Alt - see Linux/ser2net