ClientRequestReadBits (FB) ¶ FUNCTION_BLOCK ABSTRACT ClientRequestReadBits EXTENDS ClientRequestRead Read client request base class for ReadCoils, ReadDiscreteInputs InOut: Scope Name Type Initial Comment Inherited from Input xExecute BOOL Rising edge: Starts defined operation FALSE : Resets the defined operation after ready condition was reached ETrigTo udiTimeOut UDINT Max. operating time for executing [µs], 0: No operating time limit ETrigTo Output xDone BOOL Ready condition reached ETrigTo xBusy BOOL Operation is running ETrigTo xError BOOL Error condition reached ETrigTo Inout rClient Client Reference to Client . ClientRequest Input uiUnitId UINT 0 Unit-Id to send the request to. ClientRequest udiReplyTimeout UDINT (50 * 1000) Reply timeout in µs - accepted maxmimum time between request message send and reply message receveived - default 50ms. ClientRequest uiMaxRetries UINT 0 Maximum number of request retries in case of “reply timeout”. ClientRequest Output eErrorID Error Error status ClientRequest eException ExceptionCodes Request exception code. ClientRequest uiRetryCnt UINT 0 Number of request retries in case of “reply timeout”. ClientRequest Input uiStartItem UINT 0 First “data item” to read. ClientRequestRead uiQuantity UINT 1 Number of “data items” to read. ReadCoils / ReadDiscreteInputs: 1 to 2000 ReadHoldingRegisters / ReadInputRegisters: 1 to 125 ClientRequestRead pData POINTER TO ARRAY [0..0] OF BOOL 0 Pointer to result data array, memory has to be provided by caller.
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. The maximum number of serial ports usable with ClientSerial / ServerSerial is limited to MAX_NUM_COMPORTS. In case there is a need to use more serial ports, anyone can set the library parameter MAX_NUM_COMPORTS within an application - see Library Manager -> ModbusFB -> Parameter -> MAX_NUM_COMPORTS. Please visit https://forge.codesys.com/prj/codesys-example/modbus/home to find examples. InOut: Scope Name Type Initial Comment Inherited from Input xEnable BOOL FALSE 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). Server fcsSupported SupportedFcs Constants.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 . Server dataModel TableDefinitions “data model”, accepted at xEnable FALSE => TRUE. Server tInactivityInfoTime UDINT 0 “inactivity info time” (in milliseconds). If no valid requests are received in this time xInactive is signaling inactivity - default = 0 -> no “inactivity info”. Server Output xRunning BOOL Server is up and running, waiting for requests. Server xError BOOL Error Server eErrorID Error Error status Server xInactive BOOL No valid requests received for tInactivityTimeOut. Server udiNumMsgRecv UDINT Request statistics: number of request messages received since enabling the Server. Server udiNumMsgReply UDINT Request statistics: number of reply messages send since enabling the Server. Server udiNumMsgExcReply UDINT Request statistics: number of exception reply messages send since enabling the Server. Server udiNumMsgExcReplyIllFct UDINT Request statistics: number of exception reply messages send since enabling the Server, signaling illegal function. Server udiNumMsgExcReplyIllDataAdr UDINT Request statistics: number of exception reply messages send since enabling the Server, signaling illegal data address. Server udiNumMsgExcReplyIllDataValue UDINT Request statistics: number of exception reply messages send since enabling the Server, signaling illegal data value. Server xReadRequest BOOL Read request(s) happened since last call, rejected requests included. Server udiNumReadRequests UDINT Request statistics: read request counter, rejected requests included. Server xWriteRequest BOOL Write request(s) happened since last call, rejected requests included. Server udiNumWriteRequests UDINT Request statistics: write request counter, rejected requests included. Server Input uiUnitId UINT 1 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. iPort SysCom.SYS_COM_PORTS SysCom.SYS_COM_PORTS.SYS_COMPORT_NONE Serial port. Only read when rising edge on xEnable occurs. dwBaudrate SysCom.SYS_COM_BAUDRATE SysCom.SYS_COM_BAUDRATE.SYS_BR_115200 Baud rate. Only read when rising edge on xEnable occurs. byDataBits BYTE 8 Number of data bits/BYTE, 5-8. Only read when rising edge on xEnable occurs. eParity SysCom.SYS_COM_PARITY SysCom.SYS_COM_PARITY.SYS_NOPARITY Parity. Only read when rising edge on xEnable occurs. eStopBits SysCom.SYS_COM_STOPBITS SysCom.SYS_COM_STOPBITS.SYS_ONESTOPBIT Stop bits. Only read when rising edge on xEnable occurs. eDTRcontrol SysCom.SYS_COM_DTR_CONTROL SysCom.SYS_COM_DTR_CONTROL.SYS_DTR_CONTROL_DISABLE DTR control. Only read when rising edge on xEnable occurs. eRTScontrol SysCom.SYS_COM_RTS_CONTROL SysCom.SYS_COM_RTS_CONTROL.SYS_RTS_CONTROL_DISABLE RTS control. Only read when rising edge on xEnable occurs. eRtuAscii RtuAscii RtuAscii.RTU RTU / ASCII. Only read when rising edge on xEnable occurs. udiLogOptions UDINT LoggingOptions.ServerStartStop Logging options. Methods: CheckDataModel , inherited from Server InitDataModel , inherited from Server LogDataModel , inherited from Server LogStatusInfo ResetRequestStatistics , inherited from Server SupportFc , inherited from Server SupportsFc , inherited from Server Structure: Log LogStatusInfo (Method)
ServerTCP (FB) ¶ FUNCTION_BLOCK ServerTCP EXTENDS Server MODBUS TCP server (slave). ServerTCP processes MODBUS TCP requests by up to 64 parallel client connections. 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 xEnable BOOL FALSE 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). Server fcsSupported SupportedFcs Constants.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 . Server dataModel TableDefinitions “data model”, accepted at xEnable FALSE => TRUE. Server tInactivityInfoTime UDINT 0 “inactivity info time” (in milliseconds). If no valid requests are received in this time xInactive is signaling inactivity - default = 0 -> no “inactivity info”. Server Output xRunning BOOL Server is up and running, waiting for requests. Server xError BOOL Error Server eErrorID Error Error status Server xInactive BOOL No valid requests received for tInactivityTimeOut. Server udiNumMsgRecv UDINT Request statistics: number of request messages received since enabling the Server. Server udiNumMsgReply UDINT Request statistics: number of reply messages send since enabling the Server. Server udiNumMsgExcReply UDINT Request statistics: number of exception reply messages send since enabling the Server. Server udiNumMsgExcReplyIllFct UDINT Request statistics: number of exception reply messages send since enabling the Server, signaling illegal function. Server udiNumMsgExcReplyIllDataAdr UDINT Request statistics: number of exception reply messages send since enabling the Server, signaling illegal data address. Server udiNumMsgExcReplyIllDataValue UDINT Request statistics: number of exception reply messages send since enabling the Server, signaling illegal data value. Server xReadRequest BOOL Read request(s) happened since last call, rejected requests included. Server udiNumReadRequests UDINT Request statistics: read request counter, rejected requests included. Server xWriteRequest BOOL Write request(s) happened since last call, rejected requests included. Server udiNumWriteRequests UDINT Request statistics: write request counter, rejected requests included. Server Input wsInterfaceName WSTRING(255) ETH interface name to bind to, “” to bind to any ETH interface. Only read when rising edge on xEnable occurs. uiPort UINT 502 ETH port to use. Only read when rising edge on xEnable occurs. xReset BOOL FALSE Reset the server. Close the server socket, and open again. Reset xRunning, xError, eErrorID and xInactive. Reset the request statistics: udiNumMsgRecv, udiNumMsgReply … udiNumWriteRequests. Reset xReadRequest and xWriteRequest information. udiLogOptions UDINT LoggingOptions.ServerStartStop Logging options. Output uiConnectedClients UINT Number of actually connected clients. Methods: CheckDataModel , inherited from Server InitDataModel , inherited from Server LogDataModel , inherited from Server LogStatusInfo ResetRequestStatistics , inherited from Server SupportFc , inherited from Server SupportsFc , inherited from Server Structure: Log LogStatusInfo (Method)
Util ¶ ByteBuffer (FunctionBlock) BytesToEnd (Method) Capacity (Method) CopyContent (Method) Equals (Method) Freeze (Method) GetByte (Method) GetData (Method) GetDataPointerAt (Method) GetDataPointerAtPosition (Method) GetNBytes (Method) GetNBytesReverse (Method) GetNWords (Method) GetWord (Method) Init (Method) Len (Method) PutByte (Method) PutNBytes (Method) PutNBytesReverse (Method) PutNWords (Method) PutWord (Method) PutWordAt (Method) Rewind (Method) SetLen (Method) SetPos (Method) SetPosToEnd (Method)
ByteBuffer (FB) ¶ FUNCTION_BLOCK ByteBuffer Buffer to work with fixed size byte arrays. ByteBuffer does have a Capacity() fixed during Init(). It could be written to using the Put*() methods, updating Len() and the position (uiPosition). It could be read using the Get*() methods, updating the position (uiPosition). Position could be set from begin (0) to end (Len() -1). Rewind() does set uiPosition to begin. Freeze() make subsequent Put*() calls be ignored - this is reset at Init(). InOut: Scope Name Type Initial Output uiPosition UINT 0 Methods: BytesToEnd Capacity CopyContent Equals Freeze GetByte GetData GetDataPointerAt GetDataPointerAtPosition GetNBytes GetNBytesReverse GetNWords GetWord Init Len PutByte PutNBytes PutNBytesReverse PutNWords PutWord PutWordAt Rewind SetLen SetPos SetPosToEnd Structure: BytesToEnd (Method) Capacity (Method) CopyContent (Method) Equals (Method) Freeze (Method) GetByte (Method) GetData (Method) GetDataPointerAt (Method) GetDataPointerAtPosition (Method) GetNBytes (Method) GetNBytesReverse (Method) GetNWords (Method) GetWord (Method) Init (Method) Len (Method) PutByte (Method) PutNBytes (Method) PutNBytesReverse (Method) PutNWords (Method) PutWord (Method) PutWordAt (Method) Rewind (Method) SetLen (Method) SetPos (Method) SetPosToEnd (Method)
GlobalConstants ¶ Constants (GVL) Parameter (ParamList)
Constants (GVL) ¶ Attributes: qualified_only InOut: Scope Name Type Initial Constant SUPPORTED_FCS_SIMPLE_SERVER SupportedFcs STRUCT(ReadCoils := TRUE, ReadDiscreteInputs := TRUE, ReadHoldingRegisters := TRUE, ReadInputRegisters := TRUE, WriteSingleCoil := TRUE, WriteSingleRegister := TRUE, ReadExceptionStatus := FALSE, Diagnostics := FALSE, GetCommEventCounter := FALSE, GetCommEventLog := FALSE, WriteMultipleCoils := TRUE, WriteMultipleRegisters := TRUE, ReportServerID := FALSE, ReadFileRecord := FALSE, WriteFileRecord := FALSE, MaskWriteRegister := TRUE, ReadWriteMultipleRegisters := TRUE, ReadFifoQueue := FALSE)
Parameter (PARAMS) ¶ InOut: Scope Name Type Initial Comment Constant MAX_NUM_COMPORTS UINT 10 Maximum number of COM ports
ClientRequestReadCoils (FB) ¶ FUNCTION_BLOCK ClientRequestReadCoils EXTENDS ClientRequestReadBits ReadCoils client request (FC01). For details about client request see ClientRequest . InOut: Scope Name Type Initial Comment Inherited from Input xExecute BOOL Rising edge: Starts defined operation FALSE : Resets the defined operation after ready condition was reached ETrigTo udiTimeOut UDINT Max. operating time for executing [µs], 0: No operating time limit ETrigTo Output xDone BOOL Ready condition reached ETrigTo xBusy BOOL Operation is running ETrigTo xError BOOL Error condition reached ETrigTo Inout rClient Client Reference to Client . ClientRequest Input uiUnitId UINT 0 Unit-Id to send the request to. ClientRequest udiReplyTimeout UDINT (50 * 1000) Reply timeout in µs - accepted maxmimum time between request message send and reply message receveived - default 50ms. ClientRequest uiMaxRetries UINT 0 Maximum number of request retries in case of “reply timeout”. ClientRequest Output eErrorID Error Error status ClientRequest eException ExceptionCodes Request exception code. ClientRequest uiRetryCnt UINT 0 Number of request retries in case of “reply timeout”. ClientRequest Input uiStartItem UINT 0 First “data item” to read. ClientRequestRead uiQuantity UINT 1 Number of “data items” to read. ReadCoils / ReadDiscreteInputs: 1 to 2000 ReadHoldingRegisters / ReadInputRegisters: 1 to 125 ClientRequestRead pData POINTER TO ARRAY [0..0] OF BOOL 0 Pointer to result data array, memory has to be provided by caller. ClientRequestReadBits
ClientRequestReadDiscreteInputs (FB) ¶ FUNCTION_BLOCK ClientRequestReadDiscreteInputs EXTENDS ClientRequestReadBits ReadDiscreteInputs client request (FC02). For details about client request see ClientRequest . InOut: Scope Name Type Initial Comment Inherited from Input xExecute BOOL Rising edge: Starts defined operation FALSE : Resets the defined operation after ready condition was reached ETrigTo udiTimeOut UDINT Max. operating time for executing [µs], 0: No operating time limit ETrigTo Output xDone BOOL Ready condition reached ETrigTo xBusy BOOL Operation is running ETrigTo xError BOOL Error condition reached ETrigTo Inout rClient Client Reference to Client . ClientRequest Input uiUnitId UINT 0 Unit-Id to send the request to. ClientRequest udiReplyTimeout UDINT (50 * 1000) Reply timeout in µs - accepted maxmimum time between request message send and reply message receveived - default 50ms. ClientRequest uiMaxRetries UINT 0 Maximum number of request retries in case of “reply timeout”. ClientRequest Output eErrorID Error Error status ClientRequest eException ExceptionCodes Request exception code. ClientRequest uiRetryCnt UINT 0 Number of request retries in case of “reply timeout”. ClientRequest Input uiStartItem UINT 0 First “data item” to read. ClientRequestRead uiQuantity UINT 1 Number of “data items” to read. ReadCoils / ReadDiscreteInputs: 1 to 2000 ReadHoldingRegisters / ReadInputRegisters: 1 to 125 ClientRequestRead pData POINTER TO ARRAY [0..0] OF BOOL 0 Pointer to result data array, memory has to be provided by caller. ClientRequestReadBits