I am writing a program to detect multiple Aardvark I2C/SPI Host Adapters and connect to them.
I want to ensure that when the application fails and is restarted, it can connect to the Aardvark adapters that were open and working. This is where I am having issues:
aa_find_devices_ext(16, 16)
Out[39]: (2, array('H', [32768, 32769]), array('I', [2238942396, 2238944444]))
aa_find_devices_ext(16, 16)
Out[40]: (2, array('H', [0, 1]), array('I', [2238942396, 2238944444]))
Here are some details about my setup:
How can I guard against incorrect ports being returned? Several workstations are involved in this project. It would really save me time to not have to physically connect and reconnect every host adapter on the floor.
Response from Technical Support:Thanks for your question! The Aardvark Software API is provided with functional examples that you can use as-is or modified as needed. The example aadetect should be a good starting point for your project. The API function aa_find_devices_ext searches for Aardvark adapters in use and the ports to which they are connected. Here is what the code looks like in Python (other programing languages are supported):
# Find all the attached devices
(num, ports, unique_ids) = aa_find_devices_ext(16, 16)
if num > 0:
print("%d device(s) found:" % num)
# Print the information on each device
for i in range(num):
port = ports[i]
unique_id = unique_ids[i]
# Determine if the device is in-use
inuse = "(avail)"
if (port & AA_PORT_NOT_FREE):
inuse = "(in-use)"
port = port & ~AA_PORT_NOT_FREE
# Display device port number, in-use status, and serial number
print(" port = %d %s (%04d-%06d)" % (port, inuse, unique_id // 1000000, unique_id % 1000000))
else:
print("No devices found.")
For more information about API code, please refer to the API Documentation section of the Aardvark I2C/SPI Host Adapter User Manual.
We hope this answers your questions. Additional resources that you may find helpful include the following:
If you want more information, feel free to contact us with your questions, or request a demo that applies to your application.