ComSerialConfig
This input structure defines which COM port is to be used and opened with which parameters.
If a parameter is changed during cyclic calls of SerialLineControlADS, the existing COM port connection is closed automatically, and the serial COM port is opened with the new parameter. It is not necessary to close the port explicitly by resetting the input Connect.
(* contains the configuration parameters of the com port to be opened. *)
TYPE ComSerialConfig :
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
Name | Description |
---|---|
ComPort | Windows operating system: TwinCAT/BSD® operating system: |
Baud rate | All standard baud rates can be set, from 150 baud up to 128000 baud. The default is 9600 baud. 115200 baud is also a common transfer rate. |
Parity | The parity check for the serial data transmission is set here. Possible values are summarized in the enumeration ComParity_t. |
DataBits | The number of data bits for the serial data transmission is set here. Possible values are 4, 5, 6, 7 and 8. |
StopBits | The number of stop bits for the serial data transmission is set here. Possible values are summarized in the enumeration ComStopBits_t. |
RTS | The 'Request to Send' signal ( = RFR 'Ready for Receiving' ) for the serial data transmission is set here. Possible values are summarized in the enumeration ComRTSCtrl_t. |
DTR | The 'Data Terminal Ready' signal for the serial data transmission is set here. Possible values are summarized in the enumeration ComDTRCtrl_t. |
CTS | The 'Clear to Send' signal for the serial data transmission is set here. If the value is TRUE, no data are sent if the CTS input signal for the data transmission is not set. |
DSR | The 'Dataset Ready' signal for the serial data transmission is set here. If the value is TRUE, no data are sent if the DSR input signal for the data transmission is not set. If DSR is TRUE, received data bytes are ignored, if the DSR input signal for the data transmission is not set. |
TraceLevel | This input can be used to configure the output of messages (debug traces) by the TcAdsSerialCommServer. With level 'Noise', even data received at the serial port and data sent to the serial port are output in the messages. This option requires considerable system resources and should therefore only be selected for temporary testing purposes. Note: If the DebugView Windows tool (from SysInternals) is used, the setting CaptureGlobalWin32 must be active in order to receive the messages. Under TwinCAT/BSD operating systems the messages are stored in /var/log/messages. |
Invalid parameterization Not all parameter settings for serial data transmission may be available in all cases. Some settings or combinations are not supported by the operating system (Windows, TwinCAT/BSD) or by COM port drivers or the hardware. Example: In some cases the 1.5 stop bits or the 4 data bits options, or the combination of 5 data bits & 2 stop bits are not supported. Or the baud rate may be limited to a maximum of 115200 baud. Please also check the interface description of the respective embedded PC / IPC (e.g. Interface description of the CX52x0). |
Further information on the parameters of a serial data transmission under Windows can be found in the Microsoft MSDN description of the DCB structure.
Requirements
Development environment |
Target platform |
PLC libraries to include |
---|---|---|
TwinCAT v3.1.4016 |
PC or CX (x86, x64) |
Tc2_SerialCom |