ServerSerial (FB)
FUNCTION_BLOCK ServerSerial EXTENDS Server IMPLEMENTS ISysComUser
MODBUS serial server (slave).
For details about supported function codes and “data model” see Server.
Please note: some input variables related to connection configuration are read when rising edge on xEnable occurs. To change connection configuration the application needs to - disconnect (xEnable := FALSE and execute the FB) - modify the related input variables - connect (xEnable := TRUE and execute the FB)
The Server provides some statistics of received valid requests messages and sent 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
xEnableBOOLFALSE
Enables the server, take over the configuration information fcsSupported and dataModel. If the “data model” (tableDefinitions) contains configuration errors, the Server will not got busy (xBusy = FALSE).
fcsSupportedConstants.SUPPORTED_FCS_SIMPLE_SERVER
Supported “function codes”, accepted at xEnable FALSE => TRUE. In case fcsSupported is not assigned by the application it defaults to Constants.SUPPORTED_FCS_SIMPLE_SERVER.
dataModel“data model”, accepted at xEnable FALSE => TRUE.
tInactivityInfoTimeUDINT0
“inactivity info time” (in milliseconds). If no valid requests are received in this time xInactive is signaling inactivity - default = 0 -> no “inactivity info”.
Output
xRunningBOOLServer is up and running, waiting for requests.
xErrorBOOLError
eErrorIDError status
xInactiveBOOLNo valid requests received for tInactivityTimeOut.
udiNumMsgRecvUDINTNumber of request messages received since enabling the Server.
udiNumMsgReplyUDINTNumber of reply messages send since enabling the Server.
udiNumMsgExcReplyUDINTNumber of exception reply messages send since enabling the Server.
udiNumMsgExcReplyIllFctUDINTNumber of exception reply messages send since enabling the Server, signaling illegal function.
udiNumMsgExcReplyIllDataAdrUDINTNumber of exception reply messages send since enabling the Server, signaling illegal data address.
udiNumMsgExcReplyIllDataValueUDINTNumber of exception reply messages send since enabling the Server, signaling illegal data value.
xReadRequestBOOLRead request(s) happened since last call, rejected requests included.
udiNumReadRequestsUDINTRead request counter, rejected requests included.
xWriteRequestBOOLWrite request(s) happened since last call, rejected requests included.
udiNumWriteRequestsUDINTWrite request counter, rejected requests included.
Input
uiUnitIdUINT1
Unit-Id / Slave address. Only read when rising edge on xEnable occurs. Slave address has to be in range 1 .. 247 according to MODBUS standard.
iPortSysCom.SYS_COM_PORTSSysCom.SYS_COM_PORTS.SYS_COMPORT_NONE
Serial port. Only read when rising edge on xEnable occurs.
dwBaudrateSysCom.SYS_COM_BAUDRATESysCom.SYS_COM_BAUDRATE.SYS_BR_115200
Baud rate. Only read when rising edge on xEnable occurs.
byDataBitsBYTE8
Number of data bits/BYTE, 4-8. Only read when rising edge on xEnable occurs.
eParitySysCom.SYS_COM_PARITYSysCom.SYS_COM_PARITY.SYS_NOPARITY
Parity. Only read when rising edge on xEnable occurs.
eStopBitsSysCom.SYS_COM_STOPBITSSysCom.SYS_COM_STOPBITS.SYS_ONESTOPBIT
Stop bits. Only read when rising edge on xEnable occurs.
eDTRcontrolSysCom.SYS_COM_DTR_CONTROLSysCom.SYS_COM_DTR_CONTROL.SYS_DTR_CONTROL_DISABLE
DTR control. Only read when rising edge on xEnable occurs.
eRTScontrolSysCom.SYS_COM_RTS_CONTROLSysCom.SYS_COM_RTS_CONTROL.SYS_RTS_CONTROL_DISABLE
RTS control. Only read when rising edge on xEnable occurs.
eRtuAsciiRtuAscii.RTU
RTU / ASCII. Only read when rising edge on xEnable occurs.
udiLogOptionsUDINTLoggingOptions.ServerStartStop
Logging options.