I need to setup a communication between a gsm (maestro 100) and citect
I connected GSM through USB to Serial (RS-232) converter
I run a Communication Express Wizard follow with
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 (Currently connected to COM6)
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
*Note: I tired 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 I wrote 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";
length = StrLength(buffer);
SerialWriteError = ComWrite(hPort, buffer, length, -1);
SleepMS(200);
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";
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)
----------------------------------------------------------------------------------------------
When I Run the project, from the kernel I found that Unit Offline, the message as follow:
Channel PORT3_BOARD1 is Online
2011/08/04: 29:28.287 Error: Unit Offline
UNIT 000c PORT3_BOARD1 IODev Error_in_CMD-3 16
Generic 000012 Driver 00000256 (0x00000100)
----------------------------------------------------------------------------------------------
How do I Solve this communication failure. My Cicode is correct ?
I connected GSM through USB to Serial (RS-232) converter
I run a Communication Express Wizard follow with
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 (Currently connected to COM6)
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
*Note: I tired 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 I wrote 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";
length = StrLength(buffer);
SerialWriteError = ComWrite(hPort, buffer, length, -1);
SleepMS(200);
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";
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)
----------------------------------------------------------------------------------------------
When I Run the project, from the kernel I found that Unit Offline, the message as follow:
Channel PORT3_BOARD1 is Online
2011/08/04: 29:28.287 Error: Unit Offline
UNIT 000c PORT3_BOARD1 IODev Error_in_CMD-3 16
Generic 000012 Driver 00000256 (0x00000100)
----------------------------------------------------------------------------------------------
How do I Solve this communication failure. My Cicode is correct ?