ComSerialConfig
This input structure defines a COM port and with which parameters the COM port is used and opened.
If a parameter is changed during the cyclic call of SerialLineControlADS the existing COM port connection is automatically closed and reopened again with the new parameters. In this case it is not necessary to explicitly close the port by reset the input Connect.
TYPE ComSerialConfig :
(* contains the configuration parameters of the com port to be opened. *)
STRUCT
ComPort :UDINT :=1; (* Serial port number [1..255] *)
Baudrate :UDINT :=9600;
Parity :ComParity_t :=PARITY_NONE;
DataBits :INT :=8; (* [4..8] *)
StopBits :ComStopBits_t :=STOPBITS_ONE;
DTR :ComDTRCtrl_t :=DTR_CTRL_HANDSHAKE; (* 'Data Terminal Ready' signal *)
RTS :ComRTSCtrl_t :=RTS_CTRL_HANDSHAKE; (* 'Request to Send' signal (= RFR 'Ready for Receiving') *)
CTS :BOOL :=FALSE; (* 'Clear to Send' signal *)
DSR :BOOL :=FALSE; (* 'Dataset Ready' signal *)
TraceLevel :BYTE :=0; (* None=0;Error=1,Warning=2,Info=3,Verbose=4,Noise=5 *)
Reserved1 :BYTE;
Reserved2 :BYTE;
Reserved3 :BYTE;
END_STRUCT
END_TYPE
ComPort | Any COM port, COM1 .. COM255, can be selected. Which number is given by the driver (e.g. a USB-To-Virtual-Com-Port-Driver), can be figured out with the Windows Hardware Device-Manager. |
Baudrate | All standard communication baud rates can be adjusted. Baud rates are available from 150 baud up to 115200 baud. Default is 9600 baud. |
Parity | The setting of the parity checking for the serial communication is done here. Possible values are given by the enumeration ComParity_t. |
DataBits | The setting of the number of data bits for the serial communication is done here. Possible values are 4,5,6,7 and 8. |
StopBits | The setting of the number of stop bits for the serial communication is done here. Possible values are given by the enumeration ComStopBits_t. |
RTS | The setting of the 'Request to Send' ( = RFR 'Ready for Receiving' ) signal for the serial communication is done here. Possible values are given by the enumeration ComRTSCtrl_t. |
DTR | The setting of the 'Data Terminal Ready' signal for the serial communication is done here. Possible values are given by the enumeration ComDTRCtrl_t. |
CTS | The setting of the 'Clear to Send' signal for the serial communication is done here. If the value is TRUE no data is sent if the CTS input signal of the transmission is not set. |
DSR | The setting of the 'Dataset Ready' signal for the serial communication is done here. If the value is TRUE no data is sent if the DSR input signal of the transmission is not set. Also received data bytes are ignored if parameter DSR is TRUE and the DSR input signal of the transmission is not set. |
TraceLevel | The message output (debug traces) of the TcAdsSerialCommServer is configured with this input variable. This do not concern the error output of the PLC function block SerialLineControlADS. It is a matter of an additional diagnostic possibility. The following Trace Level are available (default = 0):
All messages with a lower or equal level than the given one are output. If level 'None' is chosen no messages are output. As output Debug Traces are used. Under win32 also Log Events (application log) are used for error /warning /info messages. |
Note: Not every configuration of the parameters for the serial communication is always possible. Some settings or combinations of settings are not supported by Windows or the Com-Port-Drivers.
(Example: Often the possibility of 1.5 stop bits or 4 data bits or the combination of 5 data bits and 2 stop bits is not supported. Or the baud rate is limited to a maximum of 115200 baud.)
Further information to the parameters for a serial communication are given in the Microsoft MSDN description of the DCB structure.
PLC libraries to be linked |
COMlibV2.lib [version 2.003.008 or higher] |