Quantcast
Channel: Instrument Control (GPIB, Serial, VISA, IVI) topics
Viewing all articles
Browse latest Browse all 5566

VI_ERROR_TMO when a computer does a query to a function generator

$
0
0

Hello,

I am using a peaktech 4046 : 160MHz Function/arbitrary Waveform Generator. I developping on pyton and I am using the pyvisa librairy.
The connection is well established and the generator applies the query. But it generates the following error and stops the program (it doesn't do anything after the error).

 

Here is the code :

 

```
import pyvisa
rm = pyvisa.ResourceManager()
inst = rm.open_resource('TCPIP0::130.79.192.123::5025::SOCKET')
print(inst.session)
print(inst.io_protocol)

inst.query("source1:function squ")
```

And here is what I have in my terminal :

 

```
2
IOProtocol.normal
Traceback (most recent call last):
File "c:\Users\Labo préclinique\Desktop\ProjetPython\importation de librairies\Forum.py", line 7, in <module>
inst.query("source1:function squ ")
File "C:\Users\Labo préclinique\AppData\Local\Programs\Python\Python39\lib\site-packages\pyvisa\resources\messagebased.py", line 644, in query
return self.read()
File "C:\Users\Labo préclinique\AppData\Local\Programs\Python\Python39\lib\site-packages\pyvisa\resources\messagebased.py", line 486, in read
message = self._read_raw().decode(enco)
File "C:\Users\Labo préclinique\AppData\Local\Programs\Python\Python39\lib\site-packages\pyvisa\resources\messagebased.py", line 442, in _read_raw
chunk, status = self.visalib.read(self.session, size)
File "C:\Users\Labo préclinique\AppData\Local\Programs\Python\Python39\lib\site-packages\pyvisa\ctwrapper\functions.py", line 2337, in read
ret = library.viRead(session, buffer, count, byref(return_count))
File "C:\Users\Labo préclinique\AppData\Local\Programs\Python\Python39\lib\site-packages\pyvisa\ctwrapper\highlevel.py", line 222, in _return_handler
return self.handle_return_value(session, ret_value) # type: ignore
File "C:\Users\Labo préclinique\AppData\Local\Programs\Python\Python39\lib\site-packages\pyvisa\highlevel.py", line 251, in handle_return_value
raise errors.VisaIOError(rv)
pyvisa.errors.VisaIOError: VI_ERROR_TMO (-1073807339): Timeout expired before operation completed.

```

I have tried (to no avail) :
-changing SOCKET to INSTR
-using a timout much longeur ( inst.timeout = 10000)
-adding a end term (tried \n and \r) with : inst.read_termination = '\n'

So I don't know what to do anymore... I need to give more than one command, so the program must not stop so fast. I suspect that my function generator is not sending anything back, but I don't know how to make sure this is the case.

What I wish to know is : Why do I have a time out error if the connection is well established and the request is executed on the device ? How to do the request in a proper way ?


Thank you in advance !!

PS : I know how to catch the error (with try except) but I'd rather have an Ok answer thant a KO one.

 


Viewing all articles
Browse latest Browse all 5566

Trending Articles