ClientSerial (FB)¶
FUNCTION_BLOCK ClientSerial EXTENDS Client IMPLEMENTS ISysComUser
MODBUS serial client (master).
Please note: some input variables related to connection configuration are read when rising edge on xConnect occurs. To change connection configuration the application needs to - disconnect (xConnect := FALSE and execute the FB) - modify the related input variables - connect (xConnect := TRUE and execute the FB)
The Client provides some statistics of sent request messages and received valid reply messages. Invalid messages are dropped at the communication level, so doesnt appear in the statistics. To analyse situations where invalid reply messages might occur, you can use udiLogOptions with LoggingOptions.WarnOnReceivedInvalidFrames.
Please visit https://forge.codesys.com/prj/codesys-example/modbus/home to find examples.
- InOut:
Scope
Name
Type
Initial
Comment
Inherited from
Input
xConnectBOOLFALSE
Connect to server (slave).
Output
xConnectedBOOLClient (master) is connected to server (slave).
xErrorBOOLError
eErrorIDError status
udiNumMsgSentUDINTNumber of request messages send since connect.
udiNumMsgReplyUDINTNumber of reply messages received since connect.
udiNumMsgExcReplyUDINTNumber of exception reply messages received since connect.
udiNumMsgExcReplyIllFctUDINTNumber of exception reply messages received since connect, signaling illegal function.
udiNumMsgExcReplyIllDataAdrUDINTNumber of exception reply messages received since connect, signaling illegal data address.
udiNumReplyTimeoutsUDINTNumber of reply timeouts since connect.
udiNumReqNotProcessedUDINTNumber of requests not processed in time (“request starvation”) since connect.
udiNumReqParamErrorUDINTNumber of requests started with parameter error, for example “Read Coils” -> “Quantity of coils” = 0.
udiLastTransactionTimeUDINTTransaction time in ms - time difference between request message send und reply message received.
Input
iPortSysCom.SYS_COM_PORTSSysCom.SYS_COM_PORTS.SYS_COMPORT_NONE
Serial port, only read when rising edge on xConnect occurs.
dwBaudrateSysCom.SYS_COM_BAUDRATESysCom.SYS_COM_BAUDRATE.SYS_BR_115200
Baud rate, only read when rising edge on xConnect occurs.
byDataBitsBYTE8
Number of data bits/BYTE, 4-8, only read when rising edge on xConnect occurs.
eParitySysCom.SYS_COM_PARITYSysCom.SYS_COM_PARITY.SYS_NOPARITY
Parity, only read when rising edge on xConnect occurs.
eStopBitsSysCom.SYS_COM_STOPBITSSysCom.SYS_COM_STOPBITS.SYS_ONESTOPBIT
Stop bits, only read when rising edge on xConnect occurs.
eDTRcontrolSYS_COM_DTR_CONTROLSysCom.SYS_COM_DTR_CONTROL.SYS_DTR_CONTROL_DISABLE
DTR control, only read when rising edge on xConnect occurs.
eRTScontrolSysCom.SYS_COM_RTS_CONTROLSysCom.SYS_COM_RTS_CONTROL.SYS_RTS_CONTROL_DISABLE
RTS control, only read when rising edge on xConnect occurs.
eRtuAsciiRtuAscii.RTU
RTU / ASCII, only read when rising edge on xConnect occurs.
udiLogOptionsUDINTLoggingOptions.ClientConnectDisconnect
Logging options.