Portál AbcLinuxu, 5. května 2025 11:48
#!/bin/bash #AT+CLAC AT command lists all AT commands supported by the mobile MODEM="/dev/ttyAMA0" function get_response { local ECHO # cat will read the response, then die on timeout cat <&5 >$TMP & echo "$1" >&5 # wait for cat to die wait $! exec 6<$TMP read ECHO <&6 if [ "$ECHO" != "$1" ] then exec 6<&- return 1 fi read ECHO <&6 read RESPONSE <&6 exec 6<&- return 0 } TMP="./response" # Clear out old response : > $TMP # Set modem with timeout of 5/10 a second stty -F "$MODEM" 115200 -echo igncr -icanon onlcr ixon min 0 time 5 # Open modem on FD 5 exec 5<>"$MODEM" get_response "AT" || echo "Bad response" RESPONSE=$(cat $TMP) echo "Response was '${RESPONSE}'" exec 5<&-
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.