Sample Cicode To Send Sms From Scada
Sample Cicode To Send Sms From Scada
1) Selected Driver Manufacturer : Generic Model : ASCII Based Protocol Devices Communication : Serial 2) connect I/O Device to PSTN - Not Selected 3) Detected Serial Ports: COM6 (Current serial port where modem is connected) 4) Link I/O Device to an external tag database - Not selected 5) Finish -----------------------------------------------------------------------------After the step I configured the Ports Settings 1) Baud Rate = 115200 Data Bits = 8 Stop Bits = 1 Parity = NONE Port Name = PORT3_BOARD1 Make sure that you do not define an I/O Device if it is there then delete it leave only a port (and a COMX board). In the port's "Special Options" field put: -nt ri
*Note: I try to connect through Hyper Terminal and is connected and working fine where able to send SMS through Hyper Terminal with the following AT Command AT+cmgs=016******* <CR> >Hello <Ctrl+Z> -----------------------------------------------------------------------------------After that write a cicode to call COMOpen() and COMWrite() the cicode as follow : INT FUNCTION StartSerial(STRING sPort) INT length; INT SerialWriteError; INT hPort; STRING buffer; STRING CR; STRING CtrlZ; hPort = ComOpen(sPort, 0); IF hPort < 0 THEN
Prompt("Cannot open port " + sPort); RETURN -1; ELSE Prompt("Open Port Success" + sPort);
buffer = "AT+CMGS=0163712151"; // your phone number where sms to be sent// length = StrLength(buffer); SerialWriteError = ComWrite(hPort, buffer, length, -1);
StrSetChar(CR, 0, 13); // put CR into string StrSetChar(CR, 1, 0); // terminate so may be used as a normal Citect string buffer = CR; length = StrLength(buffer); SerialWriteError = ComWrite(hPort, buffer, length, -1); SleepMS(200);
buffer = "test sms"; // test to be sent// length = StrLength(buffer); SerialWriteError = ComWrite(hPort, buffer, length, -1); SleepMS(200);
StrSetChar(CtrlZ,0,26); StrSetChar(CtrlZ,1,0); buffer = CtrlZ; length = StrLength(buffer); SerialWriteError = ComWrite(hPort, buffer, length, -1); SleepMS(200); IF SerialWriteError THEN Prompt ("Error Writing port"); ComReset (hPort); END END RETURN 0; END --------------------------------------------------------------------------------------------Next I created a button to run the cicode function - StartSerial(PORT3_BOARD1) // name of the port created