26 lines
664 B
Bash
26 lines
664 B
Bash
#!/bin/sh
|
|
|
|
ping $SOCAT_SOCKET_LIN_IP -w 3 -c 1
|
|
|
|
if [ $? -eq 0 ]
|
|
then
|
|
|
|
if [ -x "$(command -v socat)" ]; then
|
|
echo "start listening socket-uart services with server IP $SOCAT_SOCKET_LIN_IP on port $SOCAT_SOCKET_LIN_PORT"
|
|
cmd='socat -s pty,link=/dev/ttyUM2,raw,echo=0 tcp:$SOCAT_SOCKET_LIN_IP:$SOCAT_SOCKET_LIN_PORT'
|
|
|
|
if [[ -n $SOCAT_SOCKET_LIN_MSS ]]; then
|
|
eval $cmd,mss=$SOCAT_SOCKET_LIN_MSS
|
|
else
|
|
eval $cmd
|
|
fi
|
|
|
|
else
|
|
echo "socat command not available on your target or environment"
|
|
# return 1 so that systemd knows the service failed to start
|
|
exit 1
|
|
fi
|
|
|
|
fi
|
|
exit 1
|