【发布时间】:2014-11-10 19:33:19
【问题描述】:
我想得到 AT 命令响应。
我想从我的 GSM 调制解调器读取短信。
我在谷歌上找到了一些代码,这个脚本发送 AT 命令但没有得到响应。
这是我的代码:
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("COM6", 115200);
Thread.Sleep(1000);
_serialPort.Open();
Thread.Sleep(1000);
_serialPort.WriteLine("AT" + "\r");
Thread.Sleep(1000);
string status = _serialPort.ReadLine();
labelStatus.Text = "|-"+ status + "-|";
_serialPort.Close();
}
}
}
此代码无效。
没有得到响应,而是发送 AT 命令。
如何获得响应?
谢谢
【问题讨论】:
-
你怎么知道发送正在工作?您是否使用终端模拟器验证了您的调制解调器设置?
-
我写下我的手机号码和短信,然后我从我的 GSM 调制解调器接收短信。
-
好的,所以你知道发送作品。您是否使用终端模拟器检查过 GSM 调制解调器的响应?
-
什么是终端模拟器? >>> @iheanyi
-
@RafafTahsin 它通常是一个 GUI 应用程序,用于管理与调制解调器等设备的串行连接,并允许您来回发送/接收文本消息。这是使用已知可以工作的程序来测试或验证新的串行通信代码的好方法。
标签: c# at-command