GetLibVersionNumber (FUN) ¶ FUNCTION GetLibVersionNumber : DWORD This function has been automatically generated from the project information. InOut: Scope Name Type Return GetLibVersionNumber DWORD
IsLibReleased (FUN) ¶ FUNCTION IsLibReleased : BOOL This function has been automatically generated from the project information. InOut: Scope Name Type Return IsLibReleased BOOL
ModbusFB non standard extensions ¶ Function Blocks Client ClientRequestReadHoldingRegistersWide (FunctionBlock) ClientRequestReadInputRegistersWide (FunctionBlock) ClientRequestReadWideRegisters (FunctionBlock) ClientRequestReadWriteMultipleRegistersWide (FunctionBlock) ClientRequestWriteMultipleRegistersWide (FunctionBlock) Server ServerSerial_extended (FunctionBlock) “wide registers” and endianess ServerTCP_extended (FunctionBlock) “wide registers” and endianess
Function Blocks ¶ Client ClientRequestReadHoldingRegistersWide (FunctionBlock) ClientRequestReadInputRegistersWide (FunctionBlock) ClientRequestReadWideRegisters (FunctionBlock) ClientRequestReadWriteMultipleRegistersWide (FunctionBlock) ClientRequestWriteMultipleRegistersWide (FunctionBlock) Server ServerSerial_extended (FunctionBlock) “wide registers” and endianess ServerTCP_extended (FunctionBlock) “wide registers” and endianess
Client ¶ ClientRequestReadHoldingRegistersWide (FunctionBlock) ClientRequestReadInputRegistersWide (FunctionBlock) ClientRequestReadWideRegisters (FunctionBlock) ClientRequestReadWriteMultipleRegistersWide (FunctionBlock) ClientRequestWriteMultipleRegistersWide (FunctionBlock)
ClientRequestReadHoldingRegistersWide (FB) ¶ FUNCTION_BLOCK ClientRequestReadHoldingRegistersWide EXTENDS ClientRequestReadWideRegisters ReadHoldingRegisters client request (FC03) for registers > 16bit. For details about client request see |ClientRequest| . For details about “wide registers” and endianess see ServerTCP_extended or ServerSerial_extended . Please visit https://forge.codesys.com/prj/codesys-example/modbus/home to find examples. 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) 50 ms 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 BYTE 0 Pointer to result data, memory has to be provided by caller. ClientRequestReadWideRegisters uiDataItemSize UINT “data item” size / register width (in bytes). The ClientRequest has to know about the “data item” size a-priori to provide memory for result data. In case the server unexpectedly does have a different “data item” size than assumed, the ClientRequest can not succeed. ClientRequestReadWideRegisters
ClientRequestReadInputRegistersWide (FB) ¶ FUNCTION_BLOCK ClientRequestReadInputRegistersWide EXTENDS ClientRequestReadWideRegisters ReadInputRegisters client request (FC04) for registers > 16bit. For details about client request see |ClientRequest| . For details about “wide registers” and endianess see ServerTCP_extended or ServerSerial_extended . Please visit https://forge.codesys.com/prj/codesys-example/modbus/home to find examples. 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) 50 ms 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 BYTE 0 Pointer to result data, memory has to be provided by caller. ClientRequestReadWideRegisters uiDataItemSize UINT “data item” size / register width (in bytes). The ClientRequest has to know about the “data item” size a-priori to provide memory for result data. In case the server unexpectedly does have a different “data item” size than assumed, the ClientRequest can not succeed. ClientRequestReadWideRegisters
Error (ENUM) ¶ TYPE Error : Error type used in MODBUS function block library. Attributes: qualified_only InOut: Name Initial Comment OK 0 LicenseMissing 1 Valid MODBUS license is missing. InvalidDataModel 2 The “data model” contains errors or inconsistencies. IllegalFunction 3 Undefined “function code” used to enable/disable supported “function codes”. InvalidUnitId 4 Invalid Unit-Id / Slave address. NoMemory 21 Can not allocate memory. InternalError 22 Other internal error. RequestNotProcessed 50 Request not processed in time RequestException 51 Request caused reply “exception”. RequestParameterError 52 Invalid request parameter, for example “Read Coils” -> “Quantity of coils” = 0 RequestError 53 Internal request error RequestCancelled 54 Request cancelled ReplyError 55 Internal reply error ReplyTimeout 56 No reply received in time InvalidReply 57 Invalid / incomplete reply TcpSocketError 101 Error on open/close/read/write TCP socket. TcpInvalidInterface 102 The application tried to use an unknown ETH interface. TcpConnectTimeout 103 TCP connect timeout. SerialInvalidComPort 201 The application tried to use an unknown SysCom port. SerialComPortUserInconsistentPortSetting 202 Multiple ServerSerial function blocks tried to share one SysCom port with inconsistent settings. SerialComPortUserClientExclusiveError 203 A ClientSerial function block is not allowed to share a SysCom port with any other user. SerialComPortError 204 Error on open/close/read/write SysCom port. SerialInternalError 205 Internal error working with SysCom port.
ExceptionCodes (ENUM) ¶ TYPE ExceptionCodes : MODBUS exception codes. Attributes: qualified_only InOut: Name Initial Comment RESPONSE_SUCCESS 16#0 Everything OK ILLEGAL_FUNCTION 16#1 The function code received in the query is not an allowable action for the server (or slave). This may be because the function code is only applicable to newer devices, and was not implemented in the unit selected. It could also indicate that the server (or slave) is in the wrong state to process a request of this type, for example because it is unconfigured and is being asked to return register values. ILLEGAL_DATA_ADDRESS 16#2 The data address received in the query is not an allowable address for the server (or slave). More specifically, the combination of reference number and transfer length is invalid. For a controller with 100 registers, the PDU addresses the first register as 0, and the last one as 99. If a request is submitted with a starting register address of 96 and a quantity of registers of 4, then this request will successfully operate (address-wise at least) on registers 96, 97, 98, 99. If a request is submitted with a starting register address of 96 and a quantity of registers of 5, then this request will fail with Exception Code 0x02 “Illegal Data Address” since it attempts to operate on registers 96, 97, 98, 99 and 100, and there is no register with address 100. ILLEGAL_DATA_VALUE 16#3 The value to be written is not valid SLAVE_DEVICE_FAILURE 16#4 Unrecoverable error while performing the request ACKNOWLEDGE 16#5 Notification of a Slave that a lengthy operation being started SLAVE_DEVICE_BUSY 16#6 Notification of a Slave that a lengthy operation is in progress MEMORY_PARITY_ERROR 16#8 Special error for function code 20, 21 GATEWAY_PATH_UNAVAILABLE 16#A Special error when using devices behind a gateway (Gateway misconfigured/busy) GATEWAY_TARGET_DEVICE_FAILED_TO_RESPOND 16#B Special error when using devices behind a gateway (Device does not respond)
FunctionCodes (ENUM) ¶ TYPE FunctionCodes : MODBUS function codes. Attributes: qualified_only InOut: Name Initial Comment InvalidFunctionCode 0 ReadCoils 1 ReadDiscreteInputs 2 ReadHoldingRegisters 3 ReadInputRegisters 4 WriteSingleCoil 5 WriteSingleRegister 6 ReadExceptionStatus 7 serial line only Diagnostics 8 serial line only GetCommEventCounter 11 serial line only GetCommEventLog 12 serial line only WriteMultipleCoils 15 WriteMultipleRegisters 16 ReportServerID 17 serial line only ReadFileRecord 20 WriteFileRecord 21 MaskWriteRegister 22 ReadWriteMultipleRegisters 23 ReadFifoQueue 24 EncapsulatedInterfaceTransport 43