-1

I need to communicate with a scope, Agilent Infiniium DCA-J 86100C, with python 2.7. The company Keysight offers various python code, although I'm trying to run one of them to help me learn but it crashed. I'm using GPIB and pyvisa for the connection.

I've already tried to change to termination characters but it didn't change anything. I'm not sure what band rate I could try.

SCOPE_VISA_ADDRESS = "GPIB0::7::INSTR"
rm = visa.ResourceManager('C:\\Windows\\System32\\visa32.dll')
KsInfiniiVisionX = rm.open_resource(SCOPE_VISA_ADDRESS)
KsInfiniiVisionX.clear()

KsInfiniiVisionX.query(':SYSTEM:DSP "";*OPC?')
KsInfiniiVisionX.write(":HARDcopy:INKSaver OFF")
KsInfiniiVisionX.write(":DISPlay:DATA? PNG,SCReen,COLor")

my_image = KsInfiniiVisionX.read_raw()
Traceback (most recent call last):
  File "X:\...\Get_screen_image_VISA_Python_modified\InfiniiVision_Save_ScreenShot_to_PC_Python-2.7_modified.py", line 201, in <module>
    my_image = KsInfiniiVisionX.read_raw()
  File "C:\Python27\lib\site-packages\pyvisa\resources\messagebased.py", line 306, in read_raw
    chunk, status = self.visalib.read(self.session, size)
  File "C:\Python27\lib\site-packages\pyvisa\ctwrapper\functions.py", line 1582, in read
    ret = library.viRead(session, buffer, count, byref(return_count))
  File "C:\Python27\lib\site-packages\pyvisa\ctwrapper\highlevel.py", line 188, in _return_handler
    raise errors.VisaIOError(ret_value)
VisaIOError: VI_ERROR_TMO (-1073807339): Timeout expired before operation completed.
Alex
  • 21
  • 2

1 Answers1

1

I was able to get help. The goal was to take a screenshot of the display on the scope and save this screenshot to a connected PC. The picture had to be modify before being saved. Also, the reason why the function ".read_raw()" wouldn't work is that I had to do an *OPC before but only in a .write() command not in a .query().

    KsInfiniiVisionX.write('DISK:SIMAGE "D:\User Files\screen images\TEST.jpg",SCR,INV')
    KsInfiniiVisionX.write('*OPC?')
    complete = KsInfiniiVisionX.read()

    KsInfiniiVisionX.write('DISK:BFILE? "D:\User Files\screen images\TEST.jpg"')
    my_image = KsInfiniiVisionX.read_raw()

    dum  = (my_image[0:1].decode())
    length = int(my_image[1:2].decode())
    size = int(my_image[2:2+length].decode())

    search = dum+str(length)+str(size)
    my_file=my_image.partition(search.encode())

    base_directory = "X:\\..."
    target = open(base_directory + '{}.jpg'.format(file_name), 'wb')
    target.write(my_file[2])
    target.close()

Unfortunately, I am not an expert so I can't explain WHY it works.

Alex
  • 21
  • 2