How in codesys call an “at command” for gsm modem? Not standart send_sms and e.t.c

筅森魡賤 提交于 2019-11-26 12:33:50

问题


I have a gsm-modem and plc, plc sees a modem (I use a *.lib and functional block \"openPort\"), but I don\'t understand how write in modem an \"at command\", for example, \"ate0\".


回答1:


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.

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);

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).



来源:https://stackoverflow.com/questions/16412250/how-in-codesys-call-an-at-command-for-gsm-modem-not-standart-send-sms-and-e-t

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!