如何调用“AT 命令"?在 Codesys 中用于 GSM 调制解调器?不标准的send_sms等 [英] How can I call an "AT command" in Codesys for a GSM modem? Not standard send_sms, etc

查看:32
本文介绍了如何调用“AT 命令"?在 Codesys 中用于 GSM 调制解调器?不标准的send_sms等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 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".

推荐答案

首先,为了增加您对 AT 命令的总体理解,请阅读 V.250 规范.这将使您成为 AT 命令专家.

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
");
do {
    line = readLinePort(the_modem);
} while (! is_final_result_code(line))
// Sending of ATE0 command finished (successfully or not)
...
closePort(the_modem);

无论你做什么,永远不要使用 delaysleep 或类似的东西来代替等待最终结果的代码.您可以查看 atinout 的代码以获取 is_final_result_code 函数的示例(您还可以与 isFinalResponseError 和 isFinalResponseSuccess 进行比较rel="nofollow noreferrer">ST-Ericsson的U300 RIL,虽然注意CONNECT不是最终结果码,是中间结果码,所以名称为FinalResponseSuccess不是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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆