How can I call an “AT command” in Codesys for a GSM modem? Not standard send_sms, etc

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

Leave a Comment