This function will close a MODBUS ASCII connection, previously opened by the modasciiOpen function.
Input:
net_id : INT
The ID of the MODBUS connection.
Returns: INT
0
|
- Success.
|
-1
|
- Illegal MODBUS connection ID.
|
Declaration:
FUNCTION modasciiClose;
VAR_INPUT
net_id : INT;
END_VAR;
Example:
INCLUDE rtcu.inc
VAR_INPUT
switch : BOOL R_EDGE;
END_VAR;
VAR
mb_net : INT;
mode : SINT;
END_VAR;
PROGRAM ModbusExample;
mb_net := modasciiOpen(mode := mode, unit_id := 1, port := 2, baud := 57600, parity := 0);
BEGIN
IF switch THEN
modasciiClose(net_id := mb_net);
IF mode = 0 THEN
mode := 1;
ELSE
mode := 0;
END_IF;
mb_net := modasciiOpen(mode := mode, unit_id := 1, port := 2, baud := 57600, parity := 0);
END_IF;
END;
END_PROGRAM;
|