4. Configuration
196
Utilization example in ST language, after the library Nexto Serial is inserted in the project:
PROGRAM MainPrg
VAR
Config: SERIAL_CFG;
Port: SERIAL_PORT := COM1;
Parameters: SERIAL_PARAMETERS := (BAUDRATE := BAUD9600,
DATABITS := DATABITS_8,
STOPBITS := STOPBITS_1,
PARITY := PARITY_NONE,
HANDSHAKE := RS232_RTS,
UART_RX_THRESHOLD := 8,
MODE :=NORMAL_MODE,
ENABLE_RX_ON_TX := FALSE,
ENABLE_DCD_EVENT := FALSE,
ENABLE_CTS_EVENT := FALSE);
Status: SERIAL_STATUS;
END_VAR
//INPUTS:
Config.REQUEST := TRUE;
Config.PORT := Port;
Config.PARAMETERS := Parameters;
//FUNCTION:
Config();
//OUTPUTS:
Config.DONE;
Config.EXEC;
Config.ERROR;
Status := Config.STATUS; // If it’s necessary to treat the error
SERIAL_GET_CFG
The function block is used to capture the desired serial port configuration.
Figure 4-94. Block to Capture the Serial Configuration
This variable, when true, enables the function block use.
Select the serial port, as described in the SERIAL_PORT data type.
Table 4-131. SERIAL_GET_CFG Input Parameters