'GPIBInstrument' object has no attribute 'ask'

750 Views Asked by At

I am now using python to get data from lock in amplifer with GPIB and met a error report to get data. The lock in amplifier is SR865A.

import pyvisa as visa
import time,string
import random


class device:
    def __init__(self,visa_code='GPIB0::8::INSTR'):
       # print("in init")

        #self.device=visa.instrument(add)
        rm = visa.ResourceManager()

        self.device=rm.open_resource(visa_code)
#get data    
    def get_all(self):
        return self.device.ask('SNAP? 0,1,2,3')
        
                          
if (__name__ == '__main__'):
    add="GPIB0::14"
    lockin=device(add)
    #f = open('test.dat','wb');
    data=lockin.get_all()
    x=float(data.split(',')[0])
    y=float(data.split(',')[1])
    r=float(data.split(',')[2])
    theta=float(data.split(',')[3])

Error report; AttributeError: 'GPIBInstrument' object has no attribute 'ask'

0

There are 0 best solutions below