QueryDevice

Writes data to either a specified TCP/IP server device or a UDP server device, then reads the data back from that device. The response from the device must be received before the device's Timeout limit is reached.

Note: The primary use of this function is to retrieve binary data packets from a Modbus server. For more information, see Binary Text Functions or Modbus TCP Communications.

QueryDevice Inputs

Syntax: QueryDevice(Event,Device,Data)

Parameter Description

Event

Specifies the spreadsheet event that triggers the data to be written to the TCP/IP device. This parameter must be a reference to one of the following:

  • The Image data structure in cell A0, containing the AcquireImage function. For more information, see AcquireImage.
  • A cell containing an Event function. For more information, see Event.
  • A cell containing a Button function. For more information, see Button.

Device

A reference to a Device structure, which must be a TCP/IP client, created by a TCPDevice, or a reference to a Device structure returned by a UDPDevice function. For more information, see TCPDevice or UDPDevice.

Data

The data to be written to the TCP/IP or UDP device. For the TCP/IP implementation, the data type must be of the same type specified in the device's Packet Type: either an ASCII string or a binary Modbus command. For the UDP implementation, the data type must be of the same type specified in the Binary Packet parameter: either binary data packets or string information. For more information, see Packet Type or Binary Packet.

QueryDevice Outputs

Returns

A Query data structure, or #ERR if any of the input parameters are invalid.

For more information, see Input/Output Functions, Binary Text Functions, ReadDevice, or WriteDevice.