Hi,
I am trying to use Pyvisa to automate testing. Issue I am having is that pyvisa.ResourceManager() is displaying multiple devices when infact there is only one device.
Here are the screen shots of my code and ouput:
Output:
Be sure to click 'more' and select 'suggest as answer'!
If you're the thread creator, be sure to click 'more' then 'Verify as Answer'!
Hi,
I am trying to use Pyvisa to automate testing. Issue I am having is that pyvisa.ResourceManager() is displaying multiple devices when infact there is only one device.
Here are the screen shots of my code and ouput:
Output:
This is normal and it is because your VISA Layer itself has either autodetected or has been manually configured to represent serial ports (ASRL) and GPIB addresses 7 and 9 on one controller and 9 on a second as having devices available.
Depending on your VISA Layer, you may be able to configure this behaviour, using whatever "device explorer" or configuration tools it comes with (e.g. NI MAX).
This can also occur where a test device is connected to multiple interfaces at once.
This is, in itself, not a problem as you should only be opening connections to specific devices of interest. It is very common to see all your serial ports listed as some older instruments had serial ports as the only alternative to GPIB and even some new instruments can be configured for USB-CDC as an alternative to USB-TMC
- Gough
Is there a way to kind of reset the Resource Manager either manually or through python ?
Not that I know of. This is down to your VISA layer's behaviour.
You'll need to use the tools corresponding to the VISA layer you're using to configure its behaviour.
Many will autodetect devices on a continuous basis but anything that was manually configured in the VISA's connection manager will permanently stay.
Again, I don't see this as unusual or a problem.
- Gough
Thank you for your help :)
For this reason, I wrote a helper, to inspect all ASRL devices with an IDN? command to see if they real SCPI devices or not.
Yeah I did the same.
Text for copy:
import pyvisa
rm = pyvisa.ResourceManager()
lr = rm.list_resources()
Valid_device =''
for i in lr:
## print(i)
try:
if 'GPIB' in i:
rm.open_resource(i)
print('Opening device#: ' + i)
Valid_device =i
except:
## print('Error not a real device')
break
print('Valid Device: ' + Valid_device)
the reason I had to fix this issue is if you are working with multiple PCs or devices, everytime you had to open NI Max or other app to find out the real device thats connected to your PC.
Now with this simple fix, your code is more portable among the PCs.
Thanks for Element14 community for prompt responses : )