Major at-socat-bridge update

-Now uses both smd11 and smd7 for separate AT streams
-smd11 is linked to ttyOUT
-smd7 is linked to ttyOUT2

ttyOUT is intended for automated AT commands (for parse scripts, etc)

ttyOUT2 is intended for manual user initiated AT commands; the new atcmd bin is now linked to /bin as well for utilization of ttyOUT2 by shell. Just type the command atcmd to run it.

Separating these streams will improve responsiveness and help the progress of more development.
This commit is contained in:
iamromulan
2024-03-16 17:49:52 -04:00
parent eb1ae610a0
commit 127db81532
13 changed files with 109 additions and 163 deletions

38
socat-at-bridge/atcmd Normal file
View File

@@ -0,0 +1,38 @@
#!/bin/bash
while true; do
echo "Type \"exit\" to end the session"
echo "Enter AT Command:"
read user_input
if [[ "$user_input" == "exit" ]]; then
echo "Exiting..."
exit 0
else
# Create a temporary file for output
tmpfile=$(mktemp /tmp/microcom_output.XXXXXX)
# Send the input to microcom, redirect output to the temporary file
# Note: Adjust the path to microcom as necessary
echo "$user_input" > /dev/ttyOUT2
microcom -d /dev/ttyOUT2 > "$tmpfile" &
microcom_pid=$!
# Use tail to monitor the temporary file's output
tail -f "$tmpfile" | while read line; do
echo "$line"
if [[ "$line" == *OK || "$line" == *ERROR ]]; then
kill -SIGINT $microcom_pid
break
fi
done
# Wait for microcom to finish
wait $microcom_pid
# Cleanup
rm "$tmpfile"
fi
done

View File

@@ -1,14 +0,0 @@
[Unit]
Description=Read from /dev/ttyIN and write to smd7
BindsTo=socat-smd7.service
After=socat-smd7.service
[Service]
ExecStart=/bin/bash -c "/bin/cat /dev/ttyIN > /dev/smd7"
ExecStartPost=/bin/sleep 2s
StandardInput=tty-force
Restart=always
RestartSec=1s
[Install]
WantedBy=multi-user.target

View File

@@ -1,14 +0,0 @@
[Unit]
Description=Read from /dev/smd7 and write to ttyIN
BindsTo=socat-smd7.service
After=socat-smd7.service
[Service]
ExecStart=/bin/bash -c "/bin/cat /dev/smd7 > /dev/ttyIN"
ExecStartPost=/bin/sleep 2s
StandardInput=tty-force
Restart=always
RestartSec=1s
[Install]
WantedBy=multi-user.target

View File

@@ -1,13 +0,0 @@
[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/ttyIN,raw,echo=0 pty,link=/dev/ttyOUT,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

View File

@@ -1,9 +0,0 @@
[Unit]
Description=Kill port_bridge process on boot
[Service]
Type=oneshot
ExecStart=/usrdata/socat-at-bridge/killsmd7bridge
[Install]
WantedBy=multi-user.target

View File

@@ -1,14 +0,0 @@
[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

View File

@@ -1,14 +0,0 @@
[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

View File

@@ -1,13 +0,0 @@
[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