serSetHandshake (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

MX2, DX4 pro, AX9 pro, MX2 turbo, AX9 turbo, NX-200, NX-400, NX-900, NX-910, LX2, LX4

Firmware version:

1.00 / 1.00.00


serSetHandshake controls the handshaking on the serial port by using CTS and RTS signals. This function is only supported on serial ports with control signals (typically serial port 1).

By using RTS/CTS handshake, the device will only transmit when CTS is active. RTS will be set to inactive when the receive buffer is more than 80% full, and it will be set back to active when the the receive buffer is less than 40% full.

When sending data it is possible to specify a timeout waiting for the handshake.

 

Input:

port : SINT (0..127) (default 1)

Selects which serial port to use.

 

RtsCts : BOOL

If true, RTS and CTS handshaking is active.

 

Returns: INT

0

- Successful operation.

1

- Specified port does not support this operation.

 

Declaration:

FUNCTION serSetHandshake : INT;
VAR_INPUT
  port   : SINT := 1;   // Port number, only port:=1 is supported
  RtsCts : BOOL := FALSE;// Enable RTS/CTS handshaking
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
 
// Open the serial port, set baudrate, parity and number of bits
serOpen(port:=1, baud:=9600, bit:=8, parity:=0);
 
// Enable RTS/CTS handshaking
serSetHandshake(port:=1, RtsCts:=TRUE);
 
BEGIN
  Sleep(Delay:=1000);
  // Send the string <CR>ABC<CR><LF> on the serial port, using handshake
  serSendString(port:=1, str:="$RABC$R$L");
END;
 
END_PROGRAM;