Skip to content

Instantly share code, notes, and snippets.

@dirkjankrijnders
Created November 14, 2023 10:10
Show Gist options
  • Save dirkjankrijnders/2d824fbb234135c020e9eab0c4bbd13e to your computer and use it in GitHub Desktop.
Save dirkjankrijnders/2d824fbb234135c020e9eab0c4bbd13e to your computer and use it in GitHub Desktop.
import pyvisa
rm = pyvisa.ResourceManager()
rm.list_resources_info()
resource = "GPIB0::7::INSTR"
print(rm.visalib.get_debug_info())
print(rm.visalib.sessions)
my_inst = rm.open_resource(resource)
print(rm.visalib.sessions)
print(rm.resource_info(resource))
my_inst.visalib.gpib_command(my_inst.session,command_byte=0x01)
my_inst.close()
(test_pyvisa) dirkjan@gpibberry:~/src/pyvisa-commands $ /home/dirkjan/src/pyvisa-commands/test_pyvisa/bin/python /home/dirkjan/src/pyvisa-commands/test_script.py
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
libgpib: invalid descriptor
OrderedDict([('Version', '0.5.2.dev9+gf41bfae'), ('ASRL INSTR', ['Please install PySerial (>=3.0) to use this resource type.', "No module named 'serial'"]), ('USB INSTR', ['Please install PyUSB to use this resource type.', "No module named 'usb'"]), ('USB RAW', ['Please install PyUSB to use this resource type.', "No module named 'usb'"]), ('TCPIP INSTR', 'Available '), ('TCPIP SOCKET', 'Available '), ('GPIB INSTR', "Available via Linux GPIB (b'4.3.6 r[2066]')"), ('GPIB INTFC', "Available via Linux GPIB (b'4.3.6 r[2066]')")])
{1973869: <PyVisaLibrary('py')>}
{1973869: <PyVisaLibrary('py')>, 9028922: <pyvisa_py.gpib.GPIBSession object at 0x7f84d35990>}
ResourceInfo(interface_type=<InterfaceType.gpib: 1>, interface_board_number=0, resource_class='INSTR', resource_name='GPIB0::7::0::INSTR', alias=None)
Traceback (most recent call last):
File "/home/dirkjan/src/pyvisa-commands/test_script.py", line 16, in <module>
my_inst.visalib.gpib_command(my_inst.session,command_byte=0x01)
File "/home/dirkjan/src/pyvisa-commands/pyvisa-py/pyvisa_py/highlevel.py", line 248, in gpib_command
return written, self.handle_return_value(session, st)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/dirkjan/src/pyvisa-commands/test_pyvisa/lib/python3.11/site-packages/pyvisa/highlevel.py", line 251, in handle_return_value
raise errors.VisaIOError(rv)
pyvisa.errors.VisaIOError: VI_ERROR_NSUP_OPER (-1073807257): The given session or object reference does not support this operation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment