Documentation
FieldTalk Modbus Master Library for .NET
MbusMasterFunctionscustomFunction Method |
User Defined Function Code
Namespace: FieldTalk.Modbus.Master
Assembly: FieldTalk.Modbus.Master (in FieldTalk.Modbus.Master.dll) Version: 2.15.2-eval+3d8362b4bb861c05760d48b11d303e954bb8597c
public int customFunction( int slaveAddr, int functionCode, byte[] requestData, ref byte[] responseData )
Parameters
- slaveAddr
- Type: SystemInt32
Modbus address of slave device or unit identifier (Range: 1 - 255 for serial, 0 - 255 for TCP) - functionCode
- Type: SystemInt32
Custom function code to be used for Modbus transaction (Range: 1-127) - requestData
- Type: SystemByte
Array with data to be sent as request (not including slave address or function code). The length of the array determines how many request bytes are sent (Range: 0-252). - responseData
- Type: SystemByte
Buffer which will be filled with the response data. The buffer must be large enough to hold the reply data. (Range: 0-252) The length will be adjusted should the actual response data be less. A FTALK_INSUFFICIENT_BUFFER error code will be returned in case the allocated buffer size was insufficient.
Return Value
Type: Int32BusProtocolErrors.FTALK_SUCCESS on success or error code. See BusProtocolErrors for possible error codes.
This method can be used to implement User Defined Function Codes.
The caller has only to pass the user data to this function. The assembly of
the Modbus frame (the so called ADU) including checksums, slave address and
function code and subsequentially the transmission, is taken care of by this
method.
The modbus specification reserves function codes 65-72 and 100-110 for user defined functions.