From a2d3bc2d87a643146040f67af6457cbbc5f21bc0 Mon Sep 17 00:00:00 2001 From: iamromulan <50184035+iamromulan@users.noreply.github.com> Date: Sat, 16 Mar 2024 22:23:26 -0400 Subject: [PATCH] Delete atcmd --- atcmd | 63 ----------------------------------------------------------- 1 file changed, 63 deletions(-) delete mode 100644 atcmd diff --git a/atcmd b/atcmd deleted file mode 100644 index 9c9a9f9..0000000 --- a/atcmd +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/sh - -# AT Command Script Variables and Functions -TMP_DIR="/tmp" -DEVICE_FILE="/dev/smd7" -TIMEOUT=4 # Set a timeout for the response - -start_listening() { - cat "$DEVICE_FILE" > /tmp/device_readout & - CAT_PID=$! -} - -send_at_command() { - echo "Enter AT command (or type 'exit' to quit): " - read at_command - if [ "$at_command" = "exit" ]; then - return 1 - fi - echo -e "${at_command}\r" > "$DEVICE_FILE" -} - -wait_for_response() { - local start_time=$(date +%s) - local current_time - local elapsed_time - - echo "Command sent, waiting for response..." - while true; do - if grep -qe "OK" -e "ERROR" /tmp/device_readout; then - echo "Response received:" - cat /tmp/device_readout - return 0 - fi - current_time=$(date +%s) - elapsed_time=$((current_time - start_time)) - if [ "$elapsed_time" -ge "$TIMEOUT" ]; then - echo "Error: Response timed out." - return 1 - fi - sleep 1 - done -} - -cleanup() { - kill "$CAT_PID" - wait "$CAT_PID" 2>/dev/null - rm -f /tmp/device_readout -} - - if [ -c "$DEVICE_FILE" ]; then - while true; do - start_listening - send_at_command - if [ $? -eq 1 ]; then - cleanup - break - fi - wait_for_response - cleanup - done - else - echo "Error: Device $DEVICE_FILE does not exist or is not a character special file." - fi