Files
quectel-rgmii-toolkit/socat-at-bridge/atcmd
iamromulan 127db81532 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.
2024-03-16 17:49:52 -04:00

39 lines
972 B
Bash

#!/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