serSendString will send a string out on the serial port.
Input:
port : SINT (0..127) (default 0)
Selects which serial port to use.
str : STRING
The string to send.
timeout : DINT (default -1)
The number of milliseconds to wait (Only used when hardware handshake is enabled. See serSetHandshake).
0
|
-
|
Disable timeout. The function will return immediately.
|
-1
|
-
|
Wait forever. The function will only return when data is send.
|
Supported from firmware 4.68 / R1.10.00
Returns: INT
1
|
-
|
Success.
|
-1
|
-
|
The serial port is not open.
|
-2
|
|
The serial port is no longer present.
|
-3
|
-
|
Timeout waiting for send.
|
Declaration:
FUNCTION serSendString;
VAR_INPUT
port : SINT := 0;
str : STRING;
timeout : DINT := -1;
END_VAR;
Example:
INCLUDE rtcu.inc
VAR_OUTPUT
led : BOOL;
END_VAR;
PROGRAM test;
VAR
RX : serFrameReceiver;
rxbuffer :ARRAY[0..63]of SINT;
txbuffer :ARRAY[0..63]of SINT;
portNum : SINT := 0;
END_VAR;
serOpen(port:=portNum, baud:=9600, bit:=8, parity:=0);
RX(port:=portNum, enable:=TRUE, frame:=ADDR(rxbuffer), maxSize:=SIZEOF(rxbuffer), sof:=16#0D, eof:=16#0A);
txbuffer[0]:=16#0D;
txbuffer[1]:=16#41;
txbuffer[2]:=16#42;
txbuffer[3]:=16#43;
txbuffer[4]:=16#0D;
txbuffer[5]:=16#0A;
serSendData(port:=portNum, data:=ADDR(txbuffer), size:=6);
serSendChar(port:=portNum, ch:=16#0D);
serSendString(port:=portNum, str:="Hello world");
serSendChar(port:=portNum, ch:=16#0D);
serSendChar(port:=portNum, ch:=16#0A);
BEGIN
RX();
IF RX.ready THEN
led:=NOT led;
serFrameReceiveDone(port:=portNum);
END_IF;
END;
END_PROGRAM;
|