本文介绍了如何在控制台中等待预期的响应并进入下一个命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我正在使用AT命令[CMD1,CMD2,CMD3]与GSM调制解调器通信我的c#控制台应用程序,预期响应为[RSP1 for CMD1 ,RSP2对于CMD2 ,RSP3 for CMD3]从GSM调制解调器获得响应我正在使用串行端口数据接收
事件。但很多时候我从串口获得响应,这不是预期的"???????"。


我想要做的是我想在控制台应用程序中等待我预期的响应,并且一旦预期的响应收到了想要触发下一个命令等等...... / p>

请帮助我如何编写我的代码来处理这个....目前我正在使用Thread.sleep等待预期的响应并触发下一个命令但没有按预期运行

解决方案


Hello,

I am communicating my c# Console application with GSM modem using AT Command [ CMD1 , CMD2 , CMD3 ] with expected response as [ RSP1 for CMD1 , RSP2 for CMD2 , RSP3 for CMD3] for getting response from GSM modem I am using Serial Port Data Receive event. But many times I am getting response from serial port which is not expected "???????".

What I want to do is I want to wait for my expected response in console application and once expected response received wanted to fire next command and so on....

Please help me how can I  write my code to handle this ....Currently I am using Thread.sleep to wait for expected response and fire next command but not running as expected

解决方案


这篇关于如何在控制台中等待预期的响应并进入下一个命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 02:08