ClientRequestReadInputRegisters (FB) ¶ FUNCTION_BLOCK ClientRequestReadInputRegisters EXTENDS ClientRequestReadRegisters ReadInputRegisters client request (FC04). 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 UINT 0 Pointer to result data array, memory has to be provided by caller. ClientRequestReadRegisters
ClientRequestReadRegisters (FB) ¶ FUNCTION_BLOCK ABSTRACT ClientRequestReadRegisters EXTENDS ClientRequestRead Read client request base class for ReadHoldingRegisters and ReadInputRegisters 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 UINT 0 Pointer to result data array, memory has to be provided by caller.
ClientRequestReadWriteMultipleRegisters (FB) ¶ FUNCTION_BLOCK ClientRequestReadWriteMultipleRegisters EXTENDS ClientRequest ReadWriteMultipleRegister client request (FC23). For details about client request see ClientRequest . Please note: The write operation is performed before the read. 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 uiWriteStartItem UINT 0 First “data item” to write. uiWriteQuantity UINT 1 Number of “data items” to write. pWriteData POINTER TO ARRAY [0..0] OF UINT 0 Pointer to write data array. uiReadStartItem UINT 0 First “data item” to read. uiReadQuantity UINT 1 Number of “data items” to read. pReadData POINTER TO ARRAY [0..0] OF UINT 0 Pointer to read data array, memory has to be provided by caller.
ClientRequestWriteMultiple (FB) ¶ FUNCTION_BLOCK ABSTRACT ClientRequestWriteMultiple EXTENDS ClientRequest Write client request base class for WriteMultipleCoils, WriteMultipleRegisters 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 write. uiQuantity UINT 1 Number of “data items” to write.
ClientRequestWriteMultipleCoils (FB) ¶ FUNCTION_BLOCK ClientRequestWriteMultipleCoils EXTENDS ClientRequestWriteMultiple WriteMultipleCoils client request (FC15). 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 write. ClientRequestWriteMultiple uiQuantity UINT 1 Number of “data items” to write. ClientRequestWriteMultiple pData POINTER TO ARRAY [0..0] OF BOOL 0 Pointer to write data array.
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)