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