导航

4G频段测试

Posted on 2022-12-19 19:10  初之萌萌  阅读(248)  评论(0编辑  收藏  举报

目的

4G模块设置不同频段后,再检测参数是否设置成功

 

设置频段命令

echo -en "AT*BAND=5,0,0,0,1,0,2,2\r\n" > /dev/ttyUSB1

查询当前频段命令

microcom /dev/ttyUSB1 或者 cat /dev/ttyUSB1

echo -en "AT*BAND?" > /dev/ttyUSB1

 

#! /bin/sh

cat<<EOF


----------------------
*****Input a Band*****
----------------------
LTEB1
---------------------- Enter
"q" or "Ctrl+C" to exit the program EOF read -p "pls input a band: " num command3=$num if [ $num = "q" ];then exit fi if [ ! -n "$num" ]; then echo "you need to input a band" exit fi tty4g="/dev/ttyUSB1" tempfile="/irlab/temp.txt" LTEB1="5,0,0,0,1,0,2,2" str=`eval echo '$'"$command3"` if [ -e "/dev/ttyUSB1" ]; then if [ "$command3"x = "LTEB1"x ]; then echo -en "AT*BAND=5,0,0,0,1,0,2,2\r\n" > /dev/ttyUSB1 else echo -e "'$command3' input error, pls re-start..." command3="error" fi else echo "4G module is not inserted" exit fi if [ $command3 != "error" ]; then PID=`ps | grep $tty4g | grep -v grep` if [ "${PID}" != "" ]; then killall -9 cat fi echo "" > ${tempfile} sleep 1 cat $tty4g > ${tempfile} & sleep 1 echo -en "AT*BAND?" > /dev/ttyUSB1 sleep 1 str=`eval echo '$'"$command3"` echo "$command3 ${str}" one=$(echo $str | cut -d "," -f 1,5,6,7) query=`grep "*BAND:" $tempfile | tail -1` echo "$query" two=$(echo $query | cut -d ":" -f 2 | cut -d "," -f 1,5,6,7) echo "start=$one" echo "end=$two" if [ "$one" = "$two" ]; then echo -e "-----------band set success-----------" else echo -e "-----------band set fail------------" fi sleep 1 PID=`ps | grep ${tty4g} | grep -v grep` if [ "${PID}" != "" ]; then killall -9 cat fi rm -f $tempfile fi