# Module to find all current VISA-compatible devices. #import visa_fake as v import visa as v ## Use PyVisa to find all visa-compatible devices on usb, com, lpt, gpib connections def FindVisaDevices(write_log=False) : logfile = "log_visa.txt" # a is list of strings, one per instrument. Each string contains the connection, vendor id, model number and serial number. a = v.get_instruments_list() print('\nVISA devices found:') print(a) #print('\t' + '\n\t'.join(a)) # Writing result of actions to a log file can be useful for trouble-shooting. if write_log : f = open(logfile, "w") #Open a text file to record the output. The 'w' means "write". f.write('Result of search for VISA devices:') f.write('\n\t' + '\n\t'.join(a)) # '\t' is a tab and '\n' is a new line or linefeed (lf). f.close() # Always close whatever you have opened. print('\n' + logfile + ' written.') return a #------------------------------------------------------------------------------- if __name__ == '__main__' : FindVisaDevices(write_log=True)