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

前端 未结 1 1507
孤街浪徒
孤街浪徒 2020-11-28 16:05

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, \"

相关标签:
1条回答
  • 2020-11-28 16:45

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

    0 讨论(0)
提交回复
热议问题