Copies data from a Windows memory buffer into an array.
win_buf_to_array(memhandle, data_array, first_point, count)
memhandle (int)
This must be a memory handle that was returned by win_buf_alloc() when the buffer was allocated. The buffer should contain the data that you want to copy.
data_array (POINTER(c_ushort))
The C array that the data is copied to.
first_point (int)
Index of the first point in the memory buffer that data is copied from.
count (int)
Number of data points to copy.
From pyul import ul
count = 1000
# Allocate the buffer and cast it to an unsigned short
memhandle = ul.win_buf_alloc(count)
data_array = ctypes.cast(memhandle, ctypes.POINTER(ctypes.c_ushort))
# Run the input scan
ul.a_in_scan(0, 0, 0, count, 100, ULRange.BIP5VOLTS, memhandle, 0)
# Print the results
for i in range(0, count):
print("Data[" + str(i) + "] = " + str(data_array[i]) + "\n")
# Free the buffer and set the data_array to None
ul.win_buf_free(memhandle)
data_array = None