我已经开发了一个短信应用程序(发送/接收短信使用GSM调制解调器)使用这个库- http://www.scampers.org/steve/sms/libraries.htm
我有一个计时器,每3秒检查收到的消息。问题是每隔几分钟我就会得到这个错误:
***
at GsmComm.GsmCommunication.GsmPhone.GsmComm.GsmCommunication.IProtocol.ReceiveAnything(String pattern)
at GsmComm.GsmCommunication.GsmPhone.GsmComm.GsmCommunication.IProtocol.ReceiveMultiple()
at GsmComm.GsmCommunication.GsmPhone.GsmComm.GsmCommunication.IProtocol.ExecAndReceiveMultiple(String command)
at GsmComm.GsmCommunication.GsmPhone.ListMessages(PhoneMessageStatus status)
at GsmComm.GsmCommunication.GsmCommMain.ReadMessages(PhoneMessageStatus status, String storage)
at SMS.BL.TimerCalls_rec.recProcessTimerEvent(Object sender, EventArgs e) in D:CsharpSMS GSMSMSBLTimerCalls_rec.cs:line 57++++++++No data received from phone after waiting for 30000 ms.
这是代码的一部分:
try
{
// Read all SMS messages from the storage
if (CommSetting.comm.IsConnected())
{
DecodedShortMessage[] messages = CommSetting.comm.ReadMessages(PhoneMessageStatus.All, PhoneStorageType.Phone);
foreach (DecodedShortMessage message in messages)
{
ReadMessage(message.Data);
//delete message
indexP = message.Index;
CommSetting.comm.DeleteMessage(indexP, PhoneStorageType.Phone);
}
}
}
catch (Exception err)
{
RIWL.log(err.StackTrace + "++++++++" + err.Message, "Error: ");
}
这是发生错误的行:
DecodedShortMessage[] messages = CommSetting.comm.ReadMessages(PhoneMessageStatus.All, PhoneStorageType.Phone);
知道为什么偶尔调制解调器没有响应吗?发送/接收消息是分开完成的。当发送短信时,阅读被停止,反之亦然。
我还能做些什么来检查串口是否忙吗?
编辑:如果它有任何帮助,在错误发生时,dllhost.exe - COM代理很快出现在进程中。
调制解调器有反应了是斯坎普先生的软件有问题。我们以前使用过GSMComm软件来发送短信,但由于这个原因,我们编写了自己的gsm实现。我不能告诉你,我很抱歉。我们移植了pygsm,从那以后就没有出现过一次超时。