Q & A with Vaunix: Controlling Lab Brick Products Using Python

Posted on Tuesday, September 01, 2015
By Scott Blanchard

In our Q & A blog series, we’ve addressed some of the most important and technical questions about our Lab Bricks. We hope these answers give you a better understanding of how our products work.

Note: Many customers control their Lab Brick products using Python. If you’re one of them, please make sure to use the attenuator SDK with ANSI-C style function names from the Vaunix FTP site. It should be straightforward to call the functions from Python using the “types” extension. The following question is one that you may also have:

 

Q. We are able to retrieve the number of devices that are attached using the function fnLDA_GetNumDevices().We are planning to control two devices at a time, but we cannot find a function that fetches the DEV IDs of all the connected devices. What is the procedure to fetch the DEV ID of the devices?

 

Here is the code snippet:

 

from ctypes import c_int, c_double, byref, c_char_p, CDLL
import os
CDLL_file = "VNX_atten.dll"
va = CDLL(CDLL_file)
va.fnLDA_SetTestMode(False)
#Get Number of Devices
num=va.fnLDA_GetNumDevices()
print "No: of devices ", num
##Get Device Info
print va.fnLDA_GetDevInfo(c_char_p(1))

 

A. I believe the call that you are looking for is:

 

fnLDA_GetDevInfo(DEVID*ActiveDevices).

 

Here is some information about this as well as the calls required to get the model name and serial numbers.

 

VNX_ATTEN_API int fnLDA_GetDevInfo(DEVID *ActiveDevices)

 

This function fills in the ActiveDevices array with the device IDs for the connected attenuators. The array must be large enough to hold a device ID for the number of devices returned by fnLDA_GetNumDevices. The function also returns the number of active devices, which in some cases can be less than the number of devices returned in the previous call to fnLDA_GetNumDevices.

 

The device IDs identify each device and are used in the rest of the functions to select the device. While the device IDs may be small integers and may in some cases seem numerically related to the connected devices they should only be used as opaque handles.

 

VNX_ATTEN_API int fnLDA_GetModelName(DEVID deviceID, char *ModelName)

 

This function is used to get the model name of the attenuator. If the function is called with a null pointer it returns only the length of the model-name string. If the function is called with a non-null string pointer it copies the model name into the string and returns the length of the string. The string length will never be greater than the constant MAX_MODELNAME which is defined in VNX_atten.h. This function can be used regardless of whether the attenuator has been initialized with the fnLDA_InitDevice function.

 

VNX_ATTEN_API int fnLDA_GetSerialNumber(DEVID deviceID)

 

This function is used to obtain the serial number of the attenuator. It can be called regardless of whether the attenuator has been initialized with the fnLDA_InitDevice function. If your system has multiple attenuators, your software should use each device’s serial number to keep track of each specific device. Do not rely on the order in which the devices appear in the table of active devices. In a typical system the individual attenuators will be found in the same order but there is no guarantee that this will be the case.

 

As always, information about programming as well as .dll files and other tools is available from our FTP site.

 

If you have any questions about operating or programming Vaunix products or other topics, please send us an email.

Lab Bricks is a registered trademark. © Vaunix Technology Corporation 2017
Vaunix  |  978-662-7839  |  7 New Pasture Road  |  Newburyport, MA 01950