From 369e3ad673a2724be05287264a4b4658cec36285 Mon Sep 17 00:00:00 2001 From: iamromulan <50184035+iamromulan@users.noreply.github.com> Date: Mon, 26 Feb 2024 22:43:47 -0500 Subject: [PATCH] Add new files for 2nd Socat bridge -Create a new set of systemd units to chose from for the creation of ttyIN2 and ttyOUT2 for a 2nd separate AT channel -Create a new script that kills the smd7 port bridge when smd7 is needed for use by ttyOUT or ttyOUT2 --- socat-at-bridge/killsmd7bridge | 4 ++++ .../socat-smd7-from-ttyIN.service | 14 ++++++++++++++ .../socat-smd7-to-ttyIN.service | 14 ++++++++++++++ .../smd7_tty2_systemd_units/socat-smd7.service | 13 +++++++++++++ .../socat-smd11-from-ttyIN.service | 14 ++++++++++++++ .../socat-smd11-to-ttyIN.service | 14 ++++++++++++++ .../systemd_tty2_units/socat-smd11.service | 13 +++++++++++++ 7 files changed, 86 insertions(+) create mode 100644 socat-at-bridge/killsmd7bridge create mode 100644 socat-at-bridge/smd7_tty2_systemd_units/socat-smd7-from-ttyIN.service create mode 100644 socat-at-bridge/smd7_tty2_systemd_units/socat-smd7-to-ttyIN.service create mode 100644 socat-at-bridge/smd7_tty2_systemd_units/socat-smd7.service create mode 100644 socat-at-bridge/systemd_tty2_units/socat-smd11-from-ttyIN.service create mode 100644 socat-at-bridge/systemd_tty2_units/socat-smd11-to-ttyIN.service create mode 100644 socat-at-bridge/systemd_tty2_units/socat-smd11.service diff --git a/socat-at-bridge/killsmd7bridge b/socat-at-bridge/killsmd7bridge new file mode 100644 index 0000000..9f63b06 --- /dev/null +++ b/socat-at-bridge/killsmd7bridge @@ -0,0 +1,4 @@ +#!/bin/bash + +# Look for the process by its command and kill it so socat can have smd7 instead +pkill -f "/usr/bin/port_bridge smd7 at_usb2 1" diff --git a/socat-at-bridge/smd7_tty2_systemd_units/socat-smd7-from-ttyIN.service b/socat-at-bridge/smd7_tty2_systemd_units/socat-smd7-from-ttyIN.service new file mode 100644 index 0000000..4821e57 --- /dev/null +++ b/socat-at-bridge/smd7_tty2_systemd_units/socat-smd7-from-ttyIN.service @@ -0,0 +1,14 @@ +[Unit] +Description=Read from /dev/ttyIN2 and write to smd7 +BindsTo=socat-smd7.service +After=socat-smd7.service + +[Service] +ExecStart=/bin/bash -c "/bin/cat /dev/ttyIN2 > /dev/smd7" +ExecStartPost=/bin/sleep 2s +StandardInput=tty-force +Restart=always +RestartSec=1s + +[Install] +WantedBy=multi-user.target diff --git a/socat-at-bridge/smd7_tty2_systemd_units/socat-smd7-to-ttyIN.service b/socat-at-bridge/smd7_tty2_systemd_units/socat-smd7-to-ttyIN.service new file mode 100644 index 0000000..75755b3 --- /dev/null +++ b/socat-at-bridge/smd7_tty2_systemd_units/socat-smd7-to-ttyIN.service @@ -0,0 +1,14 @@ +[Unit] +Description=Read from /dev/smd7 and write to ttyIN2 +BindsTo=socat-smd7.service +After=socat-smd7.service + +[Service] +ExecStart=/bin/bash -c "/bin/cat /dev/smd7 > /dev/ttyIN2" +ExecStartPost=/bin/sleep 2s +StandardInput=tty-force +Restart=always +RestartSec=1s + +[Install] +WantedBy=multi-user.target diff --git a/socat-at-bridge/smd7_tty2_systemd_units/socat-smd7.service b/socat-at-bridge/smd7_tty2_systemd_units/socat-smd7.service new file mode 100644 index 0000000..6b8b1bd --- /dev/null +++ b/socat-at-bridge/smd7_tty2_systemd_units/socat-smd7.service @@ -0,0 +1,13 @@ +[Unit] +Description=Socat Serial Emulation for smd7 +After=ql-netd.service + +[Service] +ExecStart=/usrdata/socat-at-bridge/socat-armel-static -d -d pty,link=/dev/ttyIN2,raw,echo=0 pty,link=/dev/ttyOUT2,raw,echo=1 +# Add a delay to prevent the clients from starting too early +ExecStartPost=/bin/sleep 2s +Restart=always +RestartSec=1s + +[Install] +WantedBy=multi-user.target diff --git a/socat-at-bridge/systemd_tty2_units/socat-smd11-from-ttyIN.service b/socat-at-bridge/systemd_tty2_units/socat-smd11-from-ttyIN.service new file mode 100644 index 0000000..b2199fa --- /dev/null +++ b/socat-at-bridge/systemd_tty2_units/socat-smd11-from-ttyIN.service @@ -0,0 +1,14 @@ +[Unit] +Description=Read from /dev/ttyIN2 and write to smd11 +BindsTo=socat-smd11.service +After=socat-smd11.service + +[Service] +ExecStart=/bin/bash -c "/bin/cat /dev/ttyIN2 > /dev/smd11" +ExecStartPost=/bin/sleep 2s +StandardInput=tty-force +Restart=always +RestartSec=1s + +[Install] +WantedBy=multi-user.target diff --git a/socat-at-bridge/systemd_tty2_units/socat-smd11-to-ttyIN.service b/socat-at-bridge/systemd_tty2_units/socat-smd11-to-ttyIN.service new file mode 100644 index 0000000..00a0ae2 --- /dev/null +++ b/socat-at-bridge/systemd_tty2_units/socat-smd11-to-ttyIN.service @@ -0,0 +1,14 @@ +[Unit] +Description=Read from /dev/smd11 and write to ttyIN2 +BindsTo=socat-smd11.service +After=socat-smd11.service + +[Service] +ExecStart=/bin/bash -c "/bin/cat /dev/smd11 > /dev/ttyIN2" +ExecStartPost=/bin/sleep 2s +StandardInput=tty-force +Restart=always +RestartSec=1s + +[Install] +WantedBy=multi-user.target diff --git a/socat-at-bridge/systemd_tty2_units/socat-smd11.service b/socat-at-bridge/systemd_tty2_units/socat-smd11.service new file mode 100644 index 0000000..9add91d --- /dev/null +++ b/socat-at-bridge/systemd_tty2_units/socat-smd11.service @@ -0,0 +1,13 @@ +[Unit] +Description=Socat Serial Emulation for smd11 +After=ql-netd.service + +[Service] +ExecStart=/usrdata/socat-at-bridge/socat-armel-static -d -d pty,link=/dev/ttyIN2,raw,echo=0 pty,link=/dev/ttyOUT2,raw,echo=1 +# Add a delay to prevent the clients from starting too early +ExecStartPost=/bin/sleep 2s +Restart=always +RestartSec=1s + +[Install] +WantedBy=multi-user.target