32 lines
524 B
Bash
32 lines
524 B
Bash
#!/bin/sh
|
|
|
|
#调试开关
|
|
# 0关闭
|
|
# 1打开
|
|
# 2输出到文件
|
|
switch=1
|
|
out_file="/tmp/modem.log" #输出文件
|
|
#日志信息
|
|
debug()
|
|
{
|
|
time=$(date "+%Y-%m-%d %H:%M:%S") #获取系统时间
|
|
if [ $switch = 1 ]; then
|
|
echo $time $1 #打印输出
|
|
elif [ $switch = 2 ]; then
|
|
echo $time $1 >> $outfile #输出到文件
|
|
fi
|
|
}
|
|
|
|
#发送at命令
|
|
# $1 AT串口
|
|
# $2 AT命令
|
|
at()
|
|
{
|
|
local new_str="${2/[$]/$}"
|
|
local atCommand="${new_str/\"/\"}"
|
|
sms_tool -d $1 at $atCommand 2>&1
|
|
}
|
|
|
|
#测试时打开
|
|
# debug $1
|
|
# at $1 $2 |