Portál AbcLinuxu, 7. listopadu 2025 10:12
Prostě alternativu, ve které se vyznám.
Myslel jsem, že něco takového musí být snadné přepsat. Teď nemyslím to nahazování pinů, napájení/reset, to se řeší stejně jinde, jen tu detekci.
Tak pokud není jiná cesta, tak to tak necháme a jen učešeme.
#!/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.