Files
quectel-rgmii-toolkit/socat-at-bridge/atcmd
Cameron Thompson 2bdbf613e8 Update atcmd
2024-03-16 19:27:40 -04:00

40 lines
961 B
Bash

#!/bin/bash
DEVICE=/dev/ttyOUT2
# Function to setup device communication parameters
setup_device() {
stty -F $DEVICE cs8 115200 ignbrk -brkint -icrnl -imaxbel \
-opost -onlcr -isig -icanon -iexten -echo -echoe -echok \
-echoctl -echoke noflsh -ixon -crtscts
}
# Function to read from device until "OK" or "ERROR" is found
read_response() {
{
while IFS= read -r line; do
echo -e "\033[0;32m$line\033[0m"
if [[ "$line" == *"OK" || "$line" == *"ERROR" ]]; then
break
fi
done < "$DEVICE"
} &
READ_PID=$!
wait $READ_PID
}
echo -e "\033[0;36mType 'exit' to end the session.\033[0m"
while true; do
echo -en "\033[0;36mEnter AT Command: \033[0m"
read user_input
if [[ "$user_input" == "exit" ]]; then
echo -e "\033[0;32mExiting...\033[0m"
exit 0
fi
setup_device
echo -e "$user_input\r" > $DEVICE
read_response
done