vb.net 在VB.NET中使用宽带或GSM读取短信
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13150060/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Read SMS using Broadband or GSM in VB.NET
提问by Joa.know
Anybody here have an idea how to read SMS in SIM using VB.NET? I'm using a Broadband Modem. I can already send SMS, but I can't find out how to read SMS from the SIM and display in a datagridview.
这里有人知道如何使用 VB.NET 在 SIM 卡中读取短信吗?我正在使用宽带调制解调器。我已经可以发送短信了,但是我不知道如何从 SIM 卡中读取短信并以datagridview.
Here is my code to send SMS:
这是我发送短信的代码:
SerialPort1.Write("AT" & vbCrLf)
SerialPort1.Write("AT+CMGF=1" & vbCrLf)
SerialPort1.Write("AT+CMGS=" & Chr(34) & num & Chr(34) & vbCrLf)
SerialPort1.Write(message & Chr(26))
How about reading SMS?
看短信怎么样?
Many thanks in Advance.
提前谢谢了。
回答by urlreader
maybe a better way is to use a library for sending/receiving sms: http://www.scampers.org/steve/sms/libraries.htm#gsmcomm_download
也许更好的方法是使用库来发送/接收短信:http: //www.scampers.org/steve/sms/libraries.htm#gsmcomm_download
we used this one and it works pretty good.
我们使用了这个,效果很好。
回答by fvu
According to this blog entrythe sequence of commands is
根据此博客条目,命令序列是
AT+CMGF=1select SMS text modem
AT+CMGF=1选择 SMS 文本调制解调器
AT+CPMS="SM"select messagestore (in this case SIM)
AT+CPMS="SM"选择消息存储(在本例中为 SIM)
AT+CMGR=1to actually read the message @ index 1
AT+CMGR=1实际阅读消息@ index 1
But be sure to visit the blog, it's a lot more detailed than the short form instructions I gave here. Also, it's always best to first test out these sequences in Hyperterminal and have a detailed look at the returned data.
但是一定要访问博客,它比我在这里给出的简短说明要详细得多。此外,最好首先在超级终端中测试这些序列并详细查看返回的数据。
A full list of AT commands can be found in many places, this description of the Nokia AT command setbut which should be quite similar tot your modem is just one possible source. Of course the manual that comes with your specific modem type is always best, but detailed info like this is quite often not included in the box.
可以在许多地方找到完整的 AT 命令列表,诺基亚 AT 命令集的描述但应该与您的调制解调器非常相似,这只是一个可能的来源。当然,您的特定调制解调器类型随附的手册总是最好的,但包装盒中通常不包含此类详细信息。
Another thing: you should always check the return values of each AT command (in most cases OKor the piece of info you requested) because if you just fire off the entire sequence of commands any error the modem may have sent will pass unnoticed. Also, I've encountered several modems that don't appreciate being sent to while they're treating the previous command.
另一件事:您应该始终检查每个 AT 命令的返回值(在大多数情况下OK或您请求的信息),因为如果您只是触发整个命令序列,则调制解调器可能发送的任何错误都不会被注意到。此外,我遇到了几个调制解调器,它们在处理上一个命令时不喜欢被发送。

