Click or drag to resize

ModbusTCPProtocolSendCommand Method (String)

Send a ModbusTCP command (ADU) to a Brainboxes Device and return response The MBAP header is handled internally by this class, only the function and data need to be sent as a command Any spacing is ignore, commands are hex encoded ASCII (e.g. "01 0000 0001") Modbus TCP commands are defined as follows: ADU - Application Data Unit, split into: MBAP Header - the header contains 4 fields: * transactionId (2 bytes) = id starting at 01 increments by 1 for each new ADU sent * protocol Id (2 bytes) = always 0x00 = modbus for brainboxes devices * Length (2 bytes) = the total length in bytes of rest of the ADU from that point * Unit Id (1 byte) = set by the client in the request the response must contain the same data, always 0xff * Function Code (2 bytes)- the type of function requested can be: * 0x01 = Read Coils * 0x02 = Read Discrete Inputs * 0x03 = Read Holding Registers * 0x04 = Read Input Registers * 0x05 = Write Single Coil * 0x06 = Write Single Register * Data (variable length) - The end of the modbusTCP command, which contains data relevant to the function code The format of the command is hex encoded values in ASCII, The response is of the format: * transactionId (2 bytes) = is the same transaction ID the PC used in its request * protocol Id (2 bytes) = is the protocol which is always 00 for Modbus TCP * Length (2 bytes): is the number of bytes in the rest of the transaction * Unit Id (1 byte): is the Unit Identifier =0xFF * Function Code (2 bytes): is the Modbus Function code 01= Read Multiple Coils * Byte Code (2 bytes): Is the byte count of data to follow in this case 2 bytes * Data: is the value of data that corresponds to the function code

Namespace:  Brainboxes.IO
Assembly:  Brainboxes.IO (in Brainboxes.IO.dll) Version: 1.5.0.8
Syntax
public string SendCommand(
	string pdu
)

Parameters

pdu
Type: SystemString
Protocol Data Unit: Function Code and Data of the Modbus TCP command, spaces and dashes are ignored

Return Value

Type: String
response from the ED device without modbus header MBAP

Implements

IIOProtocolSendCommand(String)
See Also