我一直在研究了超过两天,试图让一个应用程序无法正常工作使用AT命令发送短信,我实现了在网上提供一些教程和项目。不幸的是,他们都没有工作。AT命令发送短信在Windows 8.1
[https://docs.google.com/document/d/1VfBbMcKZsutP8Cwg2iu7Rqiyccks1J6N2ZEbkbxnCTU/preview]这段代码给了我执行命令,但不发送消息。
然后我尝试了另一个项目(我使用的是C#和Visual Studio 2013),它具有以下文件,执行后状态更改为消息已发送,但我没有收到消息。我使用华为移动连接 - 3G的应用程序接口 GSM调制解调器
Program.cs的
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CSharp_SMS
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form_SMS_Sender());
}
}
}
Form1.cs的
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CSharp_SMS
{
public partial class Form_SMS_Sender : Form
{
private SerialPort _serialPort;
public Form_SMS_Sender()
{
InitializeComponent();
}
private void buttonSend_Click(object sender, EventArgs e)
{
string number = textBoxNumber.Text;
string message = textBoxMessage.Text;
_serialPort = new SerialPort("COM17", 19200); //Replace "COM7" with corresponding port name
Thread.Sleep(1000);
_serialPort.Open();
Thread.Sleep(1000);
_serialPort.Write("AT+CMGF=1\r");
Thread.Sleep(1000);
_serialPort.Write("AT+CMGS=\"" + number + "\"\r\n");
Thread.Sleep(1000);
_serialPort.Write(message + "\x1A");
Thread.Sleep(1000);
labelStatus.Text = "Status: Message sent";
_serialPort.Close();
}
}
}
有问题的程序?我错过了什么?或者,在Windows 8.1中运行这个问题有问题,因为我还发现有一个名为MS HyperTerminal的程序,这部分对我来说不是很清楚。
即_tutorial_应删除(相关帖子:[1](http://stackoverflow.com/q/28315943/1207195)和[2](http://stackoverflow.com/a/15591673/ 1207195))。什么不工作?有什么异常?根本没有结果?你必须改变一些串口属性,不要等待使用Thred.Sleep(),**检查调制解调器响应**(顺便说一下,第一次睡眠是无用的)。我还建议将该代码移到背景工作者(或者您将挂起UI)。状态变为“发送消息”,因为这是你写的,调制解调器实际告诉你的是未知的(因为你没有阅读它的答案)。 –
您没有进行身份验证。你确定你的SIM卡没有PIN吗? 超级终端直接发送AT命令(不管你输入被立即发送。) –
运行此的东西,如SysIntertnals Portmon运行,所以你可以看到从设备是您目前完全忽视了响应(看发出ATV1/AT + CMEE命令以启用更详细的响应) –