程序可以可以实现点击发送后将固定的信息发送至任意的号码。
使用的GSMmodem 为 菲利科电子 FK11MCE-T3 短信猫,其他型号的短信猫如果是使用西门子TC—35的发票发送的命令类似,具体设置请参照相应的说明书。
宏指令说明
短信发送:
macro_command main()
unsigned char command_b[11]={0x41,0x54,0x2b,0x43,0x4d,0x47,0x53,0x3d,0x33,0x33,0x0d }//发送 “AT+CMGS=0”命令
unsigned char receive_a[100]
unsigned char command_c[85]={0x30,0x38,0x39,0x31,0x36,0x38,0x33,0x31,0x30,0x38,0x37,0x30,0x35,0x35,0x30,0x35,0x46,0x30,0x31,0x31,0x30,0x30,0x30,0x44,0x39,0x31,0x36,0x38,0x33,0x31,0x36,0x37,0x32,0x30,0x39,0x37,0x36,0x37,0x46,0x33,0x30,0x30,0x30,0x38,0x30,0x30,0x31,0x32,0x34,0x45,0x33,0x42,0x34,0x45,0x42,0x41,0x46,0x46,0x30,0x43,0x39,0x35,0x45,0x38,0x38,0x38,0x41,0x42,0x36,0x32,0x35,0x33,0x35,0x46,0x30,0x30,0x34,0x45,0x38,0x36,0x46,0x46,0x30,0x31,0x1A}
unsigned short return_value,source[7],i,k=3
bool tag=1
SetData(tag, "Local HMI", LB, 1, 1)
PURGE(1)
GetData(command_c[28], "Local HMI", RW_A, 0, 12) //发送号码
GetData(source[0], "Local HMI", RW_A, 30, 7) //短信中心号码
for i=0 to 6
k=k+1
HIBYTE(source, command_c[k])
k=k+1
LOBYTE(source, command_c[k])
next i
command_c[38]=0x46
command_c[16]=0x46
OUTPORT(command_b[0], "Free Protocol", 11)
OUTPORT(command_c[0], "Free Protocol", 85)
INPORT(receive_a[0], "Free Protocol", 24, return_value)
if return_value>0 then
SetData(receive_a[0], "Local HMI", LW, 200, 24)
end if
tag=0
SetData(tag, "Local HMI", LB, 1, 1)
end macro_command
读取GSM modem状态
macro_command main()
unsigned char command_b[11]={0x41,0x54,0x2b,0x43,0x4d,0x47,0x53,0x3d,0x33,0x33,0x0d }//发送 “AT+CMGS=0”命令
unsigned char receive_a[100]
unsigned char command_c[85]={0x30,0x38,0x39,0x31,0x36,0x38,0x33,0x31,0x30,0x38,0x37,0x30,0x35,0x35,0x30,0x35,0x46,0x30,0x31,0x31,0x30,0x30,0x30,0x44,0x39,0x31,0x36,0x38,0x33,0x31,0x36,0x37,0x32,0x30,0x39,0x37,0x36,0x37,0x46,0x33,0x30,0x30,0x30,0x38,0x30,0x30,0x31,0x32,0x34,0x45,0x33,0x42,0x34,0x45,0x42,0x41,0x46,0x46,0x30,0x43,0x39,0x35,0x45,0x38,0x38,0x38,0x41,0x42,0x36,0x32,0x35,0x33,0x35,0x46,0x30,0x30,0x34,0x45,0x38,0x36,0x46,0x46,0x30,0x31,0x1A}
unsigned short return_value,source[7],i,k=3
bool tag=1
SetData(tag, "Local HMI", LB, 1, 1)
PURGE(1)
GetData(command_c[28], "Local HMI", RW_A, 0, 12) //发送号码
GetData(source[0], "Local HMI", RW_A, 30, 7) //短信中心号码
for i=0 to 6
k=k+1
HIBYTE(source, command_c[k])
k=k+1
LOBYTE(source, command_c[k])
next i
command_c[38]=0x46
command_c[16]=0x46
OUTPORT(command_b[0], "Free Protocol", 11)
OUTPORT(command_c[0], "Free Protocol", 85)
INPORT(receive_a[0], "Free Protocol", 24, return_value)
if return_value>0 then
SetData(receive_a[0], "Local HMI", LW, 200, 24)
end if
tag=0
SetData(tag, "Local HMI", LB, 1, 1)
end macro_command |