# ReadLatchedUserDataBuffer

You can use the ReadLatchedUserDataBuffer function with applications that require buffered acquisitions.

The ReadLatchedUserDataBuffer function reads data contained in the User Data field of the currently enabled factory communication protocol. If you are using an acquisition trigger input, the data is latched on the rising edge of the acquisition trigger. If you are using an Industrial Ethernet trigger, the data is latched on the rising edge of the trigger bit. You can change the factory communication protocol in the Industrial Ethernet utility in In-Sight Vision Suite.

The latched data is carried with the acquired image data, and is read into the Spreadsheet through the ReadLatchedUserDataBuffer function. The referenced Buffer data structure, which is created by a FormatInputBuffer function, defines how the received data is interpreted.

The following graphs show the user data latching sequence for different types of triggers:

Industrial Communications Triggers | Internal or Discrete IO Triggers
User data is latched after Trigger rise, and before TriggerAck. | User data is latched immediately after Exposure and before TriggerAck.

For more information, see Setting Up the Industrial Communications and FormatInputBuffer.

Note: If a periodic connection is not actively writing to the data buffer on an enabled industrial protocol, the function returns the data from the last protocol that wrote to the data buffer.
Note: ReadLatchedUserDataBuffer does not support latching on the rising edge of the acquisition trigger input on the In-Sight L38.
Inputs

Syntax: ReadLatchedUserDataBuffer(Event,Buffer,Protocol,Validate Connection,Byte/Word Order)

Parameter | Description
--- | ---
Event | Specifies the update event on which to read data. This parameter must be a reference to one of the following: The Image data structure in cell A1. A cell containing an Event function. A cell containing a Button function.
Buffer | Specifies a reference to a Buffer data structure created by a FormatInputBuffer function, which defines how the received data is interpreted. Note: The maximum length for input data is 4,000 bytes.
Protocol | Specifies which protocol the user data is to be read from.
0 = EtherNet/IP | Specifies that EtherNet/IP is the enabled factory communication protocol. For more information, see EtherNet/IP PLC Configuration. Note: This protocol is only available on In-Sight vision systems running In-Sight firmware 5.1.0 and later.
1 = PROFINET | Specifies that PROFINET is the enabled factory communication protocol. For more information, see PROFINET PLC Configuration. Note: This protocol is only available on In-Sight vision systems running In-Sight firmware 5.1.0 and later.
2 = SLMP Scanner | Specifies that SLMP Scanner is the enabled factory communication protocol. For more information, see SLMP PLC Setup.
3 = Modbus TCP Server | Specifies that Modbus TCP Server is the enabled factory communication protocol. For more information, see Modbus TCP Communications. Note: This protocol is only available on In-Sight vision systems running In-Sight firmware version 5.3.0 and later.
100 = Any (Default) | Specifies that the currently enabled factory communication protocol is used (which is enabled through the Industrial Ethernet utility). If more than one protocol is enabled, the first enabled protocol is used.
Validate Connection | Specifies whether or not the function attempts to validate the connection. If enabled, the function returns #ERR if the selected protocol does not have an active cyclic connection. Note: For EtherNet/IP, the function does not return #ERR unless an implicit connection was established after the last restart. When implicit messaging is not used, this allows the vision system to receive data explicitly without returning #ERR.
Byte/Word Order | Specifies the bit order for words and bytes read by the function.
0 = Big endian (= default for Modbus) | Specifies that the most significant byte is stored first and subsequent bytes are stored in descending order.
1 = Little endian | Specifies that the least significant byte is stored first and subsequent bytes are stored in ascending order.
2 = Big endian (word swapping) | Big endian byte style will be applied and double word types will have their word pair order switched. (16-bit words)
3 = Little endian (word swapping) | Little endian byte style will be applied and double word types will have their word pair order switched. (16-bit words)
100 = Default (when unselected) | The default setting (below) is used.
EtherNet/IP | Little endian
PROFINET | Big endian
SLMP Protocol Scanner | Little endian
Modbus TCP Server | Big endian
CC-Link IE Field Basic | Little endian
Examples: AB (one-word-sized value): A = the most significant byte, B = the least significant byte:
| Order of Arrival
--- | ---
Big endian (=default) | AB
Little endian | BA
Big endian (word swapping) | AB
Little endian (word swapping) | BA
12AB (two-word-sized value): 1 = the most significant byte, B = the least significant byte:
| Order of Arrival
--- | ---
Big endian (=default) | 12 | AB
Little endian | BA | 21
Big endian (word swapping) | AB | 12
Little endian (word swapping) | 21 | BA

Outputs

Returns | A UserData data structure containing the data sent by a client; or #ERR if any input parameters are invalid, a connection from a client has not been established or the data buffer has not been written to since establishing the connection.
Results | Data in the UserData data structure is accessed using the GetBufferData function.