How do I get a screen capture from Agilent E4440A spectrum using Python?

I want to get a screen capture from Agilent E4440A PSA series spectrum using Python with PyVISA, but I had the VI_ERROR_TMO timeout error. The following are my code.

 

import visa

rm = visa.ResourceManager()

rm.list_resources()

inst = rm.open_resource('TCPIP0::192.168.100.3::inst0::INSTR')

inst.timeout = 60000

inst.read_termination = None

inst.write(":DISPlAY:DATA?")

data = inst.read_raw()

 

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

  File "C:\Python27\lib\site-packages\pyvisa-1.8-py2.7.egg\pyvisa\resources\messagebased.py", line 306, in read_raw

    chunk, status = self.visalib.read(self.session, size)

  File "C:\Python27\lib\site-packages\pyvisa-1.8-py2.7.egg\pyvisa\ctwrapper\functions.py", line 1582, in read

    ret = library.viRead(session, buffer, count, byref(return_count))

  File "C:\Python27\lib\site-packages\pyvisa-1.8-py2.7.egg\pyvisa\ctwrapper\highlevel.py", line 188, in _return_handler

    raise errors.VisaIOError(ret_value)

pyvisa.errors.VisaIOError: VI_ERROR_TMO (-1073807339): Timeout expired before operation completed.

 

 

I tried to use other command as the following, but it had the same problem.

 

inst.timeout = 60000

inst.read_termination = None

inst.write("HARDCOPY:FORMat GIF")

inst.write("HARDCOPY:INKSAVER OFF")

inst.write("HARDCOPY:LAYout LANdscape")

inst.write("HARDCOPY:PORT ETHERNET")

inst.write("HARDCOPY START")

data = inst.read_raw()

 

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

  File "C:\Python27\lib\site-packages\pyvisa-1.8-py2.7.egg\pyvisa\resources\messagebased.py", line 306, in read_raw

    chunk, status = self.visalib.read(self.session, size)

  File "C:\Python27\lib\site-packages\pyvisa-1.8-py2.7.egg\pyvisa\ctwrapper\functions.py", line 1582, in read

    ret = library.viRead(session, buffer, count, byref(return_count))

  File "C:\Python27\lib\site-packages\pyvisa-1.8-py2.7.egg\pyvisa\ctwrapper\highlevel.py", line 188, in _return_handler

    raise errors.VisaIOError(ret_value)

pyvisa.errors.VisaIOError: VI_ERROR_TMO (-1073807339): Timeout expired before operation completed.

 

Can anyone help me? The following is Agilent E4440A information.

 

Firmware Revision: A.11.21 RELEASE

Revision Date: Jun 19 2012 10:29:48

Was this helpful?