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 - xConnect- BOOL- FALSE - Connect to server (slave). - Output - xConnected- BOOL- Client (master) is connected to server (slave). - xError- BOOL- Error - eErrorID- Error status - udiNumMsgSent- UDINT- Number of request messages send since connect. - udiNumMsgReply- UDINT- Number of reply messages received since connect. - udiNumMsgExcReply- UDINT- Number of exception reply messages received since connect. - udiNumMsgExcReplyIllFct- UDINT- Number of exception reply messages received since connect, signaling illegal function. - udiNumMsgExcReplyIllDataAdr- UDINT- Number of exception reply messages received since connect, signaling illegal data address. - udiNumReplyTimeouts- UDINT- Number of reply timeouts since connect. - udiNumReqNotProcessed- UDINT- Number of requests not processed in time (“request starvation”) since connect. - udiNumReqParamError- UDINT- Number of requests started with parameter error, for example “Read Coils” -> “Quantity of coils” = 0. - udiLastTransactionTime- UDINT- Transaction time in ms - time difference between request message send und reply message received. - Input - iPort- SysCom.SYS_COM_PORTS- SysCom.SYS_COM_PORTS.SYS_COMPORT_NONE - Serial port, only read when rising edge on xConnect occurs. - dwBaudrate- SysCom.SYS_COM_BAUDRATE- SysCom.SYS_COM_BAUDRATE.SYS_BR_115200 - Baud rate, only read when rising edge on xConnect occurs. - byDataBits- BYTE- 8 - Number of data bits/BYTE, 4-8, only read when rising edge on xConnect occurs. - eParity- SysCom.SYS_COM_PARITY- SysCom.SYS_COM_PARITY.SYS_NOPARITY - Parity, only read when rising edge on xConnect occurs. - eStopBits- SysCom.SYS_COM_STOPBITS- SysCom.SYS_COM_STOPBITS.SYS_ONESTOPBIT - Stop bits, only read when rising edge on xConnect occurs. - eDTRcontrol- SYS_COM_DTR_CONTROL- SysCom.SYS_COM_DTR_CONTROL.SYS_DTR_CONTROL_DISABLE - DTR control, only read when rising edge on xConnect occurs. - eRTScontrol- SysCom.SYS_COM_RTS_CONTROL- SysCom.SYS_COM_RTS_CONTROL.SYS_RTS_CONTROL_DISABLE - RTS control, only read when rising edge on xConnect occurs. - eRtuAscii- RtuAscii.RTU - RTU / ASCII, only read when rising edge on xConnect occurs. - udiLogOptions- UDINT- LoggingOptions.ClientConnectDisconnect - Logging options. 
