C# 用C语言编程GSM调制解调器#
我有一个lightWave类型的usb gsm调制解调器。我在c#中发现了这段代码,它可以从这个调制解调器接收、发送、删除和读取sms消息,但当新消息到达调制解调器时,接收到新消息时应该引发的事件不会被引发。我不知道问题出在哪里;但是,我可以在收到此消息后从sim卡中读取此消息,但我希望在消息到达此部分代码时引发接收消息事件:C# 用C语言编程GSM调制解调器#,c#,.net,com,gsm,modem,C#,.net,Com,Gsm,Modem,我有一个lightWave类型的usb gsm调制解调器。我在c#中发现了这段代码,它可以从这个调制解调器接收、发送、删除和读取sms消息,但当新消息到达调制解调器时,接收到新消息时应该引发的事件不会被引发。我不知道问题出在哪里;但是,我可以在收到此消息后从sim卡中读取此消息,但我希望在消息到达此部分代码时引发接收消息事件: private void Form1_Load(object sender, EventArgs e) { int port = GsmCommMain.Defa
private void Form1_Load(object sender, EventArgs e)
{
int port = GsmCommMain.DefaultPortNumber;
int baudRate = 9600; // We Set 9600 as our Default Baud Rate
int timeout = GsmCommMain.DefaultTimeout;
dlg = new frmConnection();
dlg.StartPosition = FormStartPosition.CenterScreen;
dlg.SetData(port, baudRate, timeout);
if (dlg.ShowDialog(this) == DialogResult.OK)
{
dlg.GetData(out port, out baudRate, out timeout);
CommSetting.Comm_Port = port;
CommSetting.Comm_BaudRate = baudRate;
CommSetting.Comm_TimeOut = timeout;
}
else
{
Close();
return;
}
Cursor.Current = Cursors.WaitCursor;
CommSetting.comm = new GsmCommMain(port, baudRate, timeout);
Cursor.Current = Cursors.Default;
CommSetting.comm.PhoneConnected += new EventHandler(comm_PhoneConnected);
CommSetting.comm.MessageReceived += new MessageReceivedEventHandler(comm_MessageReceived);
//....
}
当收到消息时,不会引发此事件
CommSetting.comm.MessageReceived += new MessageReceivedEventHandler(comm_MessageReceived);
这段代码是用C#编写的,我在at创建的,能帮我什么忙吗?+CMTI
GSM/GPRS调制解调器或移动电话使用+CMTI通知计算机/PC已接收到新的SMS消息及其存储位置
继续在事件句柄处运行线程DataReceivedHandler
if(indata.Contains("+CMTI"))//Alert for message recived read message from the loacation
获取loaction并从该特定sim卡位置读取消息
参考号
ref首先,您必须确保端口、波特率和超时有效。然后检查通信是否正确初始化 要添加处理程序,请仅编写以下代码
comm.MessageReceived += comm_MessageReceived;
并通过以下代码初始化通信
comm = new GsmCommMain(port, baudRate, timeout);
如果不设置握手属性,则必须自己设置硬件握手信号。将RtsEnable和DtrEnable属性设置为true。您必须使用自己的处理程序来接收数据并做出相应的决定,而不是使用GSMcomm。