[Python] VI_ERROR_TMO (-1073807339): Timeout expired before operation completed

Discussão em 'Python' iniciado por Stack, Junho 12, 2025.

  1. Stack

    Stack Membro Participativo

    I try to connect my Power Analyser Rohde&Schwarz, HMC8015 ('ASRL3::INSTR') to my computer, and to read any data that my device can show with python VISA. I have a lot of problems with the code line, which allows to read my device data.

    My code is:

    import visa

    rm = visa.ResourceManager()
    name = rm.list_resources()

    #using with allows to close explicitly the resource at the end of the script
    with rm.open_resource('ASRL3::INSTR') as Power_Analyser:

    Power_Analyser.values_format.is_binary = True
    Power_Analyser.values_format.datatype = 'B'
    Power_Analyser.values_format.is_big_endian = False
    Power_Analyser.values_format.container = bytearray

    Power_Analyser.timeout = 25000 #2,5 seconds

    Power_Analyser.write_termination = '\n'

    Data = Power_Analyser.query_ascii_values('P?',datatype='s')[0]
    print(Data)

    #write the Data to a file on my PC
    PCfilePath = 'C:\\Users\\ApCha\\Documents\\Python Scripts\\a.txt'
    newFile = open(PCfilePath, "wb")
    newFile.write(Data)
    newFile.close()


    It shows me: VisaIOError: VI_ERROR_TMO (-1073807339): Timeout expired before operation completed.

    No matter how big the timeout is set. I'm guessing that the problem comes from the syntax in Power_Analyser.query_ascii_values('P?',datatype='s')[0] but I can't figure out what's the correct syntax.

    I checked on my device manual: https://scdn.rohde-schwarz.com/ur/p.../gb_1/h/hmc80115/HMC8015_SCPImanual_en_01.pdf

    but nothing seems to work and nothing is clearly explained for python VISA and I don't have any experience with that. Does anyone know how to fix the problem ?

    Continue reading...

Compartilhe esta Página