如何调用"AT命令"?在Codesys中使用GSM调制解调器?不是标准的send_sms等 [英] How can I call an "AT command" in Codesys for a GSM modem? Not standard send_sms, etc
问题描述
我有一个GSM调制解调器和一个PLC.PLC看到调制解调器(我使用* .lib和功能块"openPort"),但是我不明白如何发送"AT命令".到调制解调器,例如"ate0&".
I have a GSM modem and a PLC. The PLC sees a modem (I use a *.lib and functional block "openPort"), but I don't understand how send an "AT command" to the modem, for example, "ate0".
推荐答案
First, to increase your understanding of AT commands in general, read the V.250 specification. That will go a long way in making you an AT command expert.
然后对于实际的实现,我不知道Codesys,因此以下是处理AT命令应具有的结构的伪代码:
Then for the actual implementation, I do not know Codesys, so the following is pseudo code of the structure you should have for handling AT commands:
the_modem = openPort();
...
// Start sending ATE0
writePort(the_modem, "ATE0\r");
do {
line = readLinePort(the_modem);
} while (! is_final_result_code(line))
// Sending of ATE0 command finished (successfully or not)
...
closePort(the_modem);
无论您做什么,都永远不要使用 delay
, sleep
或类似方法代替等待最终结果代码.您可以查看 atinout 的代码,以获取 is_final_result_code
函数的示例(您还可以在 isFinalResponseSuccess
进行比较.rel ="nofollow noreferrer"> ST-Ericsson的U300 RIL ,尽管请注意 CONNECT
不是最终结果代码,它是中间结果代码,因此名称isFinalResponseSuccess并非100%正确).
Whatever you do, never, never use delay
, sleep
or similar as a substitute for waiting for the final result code. You can look at the code for atinout for an example for the is_final_result_code
function (you can also compare to isFinalResponseError
and isFinalResponseSuccess
in ST-Ericsson's U300 RIL, although note that CONNECT
is not a final result code. It is an intermediate result code, so the name isFinalResponseSuccess is not 100% correct).
这篇关于如何调用"AT命令"?在Codesys中使用GSM调制解调器?不是标准的send_sms等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!