威纶通官方论坛

触摸屏连接GSM发送短信

[复制链接]
发表于 2012-1-31 17:30:45 | 显示全部楼层 |阅读模式
程序可以可以实现点击发送后将固定的信息发送至任意的号码。
使用的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

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2012-1-31 22:11:20 | 显示全部楼层
把手机用USB数据线跟触摸屏连接能否实现此功能?
 楼主| 发表于 2012-2-2 16:39:11 | 显示全部楼层
回复 2# 松川德设备


    普通的手机不可以,是通过特定的GSM modem,这类modem可以再淘宝上买到,价格200左右。
发表于 2012-3-19 19:04:32 | 显示全部楼层
听说过这个功能的  没用过 看看
发表于 2012-5-22 08:47:07 | 显示全部楼层
INPORT命令有超时吗,多长时间,如果一直没有数据,是返回错误,还是一直等下去?
INPORT所要读取的数据长度比如是8,如果只送来6,是继续等其余2个吗?还是遇到某一特殊字符就算结束了呢?
请mogoo解答,谢谢
发表于 2012-9-1 16:39:50 | 显示全部楼层
正要用到类似的功能
发表于 2013-1-29 15:03:50 | 显示全部楼层
学习了  楼主高手
发表于 2013-2-18 23:52:08 | 显示全部楼层
见过西门子的这种模块,不过自己没有弄过。
发表于 2014-5-8 21:37:41 | 显示全部楼层
sdfsd fsd fdsf
发表于 2014-6-4 08:40:50 | 显示全部楼层
谢谢,可以学习一下通信
您需要登录后才可以发帖 登录 | 注册

本版积分规则

回复帖子

Archiver|小黑屋|威纶通官网 ( 粤ICP备06054553号 )

GMT+8, 2024-5-7 16:00

Powered by Discuz! X3.4

© 2001-2023 Comsenz Inc.

快速回复 返回顶部 返回列表