pyVISA Timeout error connecting to a Tektronix MSO-4034B over ethernet - python

I'm having some issues trying to connect pyVISA to a Tektronix MSO-4034B over ethernet. I can connect to it fine for example I can run:
>>>print(tek.query('*IDN?'))
TEKTRONIX,MSO4034B,C010722,CF:91.1CT FV:v1.38 DPO4USB:V1.00
Fine. But running the following:
>>> values = np.array(tek.query_ascii_values('CURV?'))
Returns the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/jkuechle/anaconda/lib/python3.4/site-packages/pyvisa/resources/messagebased.py", line 455, in query_ascii_values
block = self.read()
File "/Users/jkuechle/anaconda/lib/python3.4/site-packages/pyvisa/resources/messagebased.py", line 332, in read
message = self.read_raw().decode(enco)
File "/Users/jkuechle/anaconda/lib/python3.4/site-packages/pyvisa/resources/messagebased.py", line 306, in read_raw
chunk, status = self.visalib.read(self.session, size)
File "/Users/jkuechle/anaconda/lib/python3.4/site-packages/pyvisa/ctwrapper/functions.py", line 1582, in read
ret = library.viRead(session, buffer, count, byref(return_count))
File "/Users/jkuechle/anaconda/lib/python3.4/site-packages/pyvisa/ctwrapper/highlevel.py", line 188, in _return_handler
raise errors.VisaIOError(ret_value)
pyvisa.errors.VisaIOError: VI_ERROR_TMO (-1073807339): Timeout expired before
operation completed.
Seems like I can pull any setting (WFMOutpre? also works) off the 4034B, but I can't get any data off of it.
My Code:
import visa
import numpy as np
rm = visa.ResourceManager()
tek = rm.open_resource('TCPIP::10.0.0.45::INSTR')
values = np.array(tek.query_ascii_values('CURVe'))

you can post a timeout in 25000ms using
tek.timeout = 25000

you can also add a delay for each write verb, example shows 1.2s delay or wait by using the following:
my_instrument = rm.open_resource("GPIB::10::INSTR", send_end=False, delay=1.2)

Related

Reading emails using poplib throws an error - poplib.error_proto: -ERR EOF

I am trying to read emails using the poplib library but getting an error - poplib.error_proto: -ERR EOF. The initial connection seems to be successful and I am able to get the response for the getwelcome() function but after that, the server seems to be closing the connection. Adding the code below, nothing special just the dummy code -
import poplib
client = poplib.POP3_SSL(server_name, port)
client.user(username)
client.pass_(password)
welcome = client.getwelcome()
print(welcome)
messages = len(client.list()[1]) # throws error - poplib.error_proto: -ERR EOF
Traceback (most recent call last):
File "email-pop.py", line 68, in <module>
fetch_all_mails()
File "email-pop.py", line 36, in fetch_all_mails
numMessages = len(pop_conn.list()[1])
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/poplib.py", line 243, in list
return self._longcmd('LIST')
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/poplib.py", line 186, in _longcmd
return self._getlongresp()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/poplib.py", line 162, in _getlongresp
resp = self._getresp()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/poplib.py", line 152, in _getresp
resp, o = self._getline()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/poplib.py", line 136, in _getline
if not line: raise error_proto('-ERR EOF')
poplib.error_proto: -ERR EOF
Can't seem to find what could be the issue, any help would be appreciated.
Thanks

python elasticsearch client error: timed out while get_alias

I am new to python and elasticsearch and i am trying to run a sample application. But my elasticsearch connection shows some error. I have installed elasticsearch and started the server. In the application there is a code like this
ES_URL = ['thrift://127.0.0.1:9200']
connection = pyes.ES(ES_URL)
index = connection.indices.get_alias('staging-asset')
when .get_alias is called, it shows
Client error: timed out
Traceback (most recent call last):
File "/Users/shahanahamza/.virtualenvs/cms/lib/python2.7/site-
packages/pyes/connection.py", line 151, in _client_call
return getattr(conn.client, attr)(*args, **kwargs)
File "/Users/shahanahamza/.virtualenvs/cms/lib/python2.7/site-
packages/pyes/pyesthrift/Rest.py", line 41, in execute
return self.recv_execute()
File "/Users/shahanahamza/.virtualenvs/cms/lib/python2.7/site-
packages/pyes/pyesthrift/Rest.py", line 52, in recv_execute
(fname, mtype, rseqid) = self._iprot.readMessageBegin()
File "/Users/shahanahamza/.virtualenvs/cms/lib/python2.7/site-
packages/thrift/protocol/TBinaryProtocol.py", line 126, in
readMessageBegin
sz = self.readI32()
File "/Users/shahanahamza/.virtualenvs/cms/lib/python2.7/site-
packages/thrift/protocol/TBinaryProtocol.py", line 206, in readI32
buff = self.trans.readAll(4)
File "/Users/shahanahamza/.virtualenvs/cms/lib/python2.7/site-
packages/thrift/transport/TTransport.py", line 58, in readAll
chunk = self.read(sz - have)
File "/Users/shahanahamza/.virtualenvs/cms/lib/python2.7/site-
packages/thrift/transport/TTransport.py", line 159, in read
self.__rbuf = StringIO(self.__trans.read(max(sz, self.__rbuf_size)))
File "/Users/shahanahamza/.virtualenvs/cms/lib/python2.7/site-
packages/thrift/transport/TSocket.py", line 103, in read
buff = self.handle.recv(sz)
timeout: timed out
Please help me to figure out the issue. Thanks in advance.
As mentioned in the comment by #omri , you might need to increase default threshold timeout-
pyes.es.ES(server, timeout=30, bulk_size=500,max_retries=10)
you can read more about here
There can also be other reasons for this timeouts. Check this and see if its still happening.
Check your mappings also

Keithley 2410 and PyVISA - VI_ERROR_TMO: Timeout expired before operation completed

I'm trying to control a Keithley 2410 via python on an x86_64 linux machine (CentOS 7). I'm using python 2.7.5, NI-VISA 16 and PyVISA 1.8. The Keithley is connected to the computer via a a RS232-to-USB cable and it's configured for RS232 communication (with the parameters: baud 57600, bits 8, parity none, terminator , flow-ctrl none). When I try to query the Keithley I get a timeout error, as shown below:
>>> import visa
>>> rm = visa.ResourceManager()
>>> print(rm.list_resources())
(u'ASRL1::INSTR', u'ASRL2::INSTR')
>>> keithley = rm.open_resource("ASRL2::INSTR")
>>> print(keithley.query('*IDN?'))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/pyvisa/resources/messagebased.py", line 407, in query
return self.read()
File "/usr/lib/python2.7/site-packages/pyvisa/resources/messagebased.py", line 332, in read
message = self.read_raw().decode(enco)
File "/usr/lib/python2.7/site-packages/pyvisa/resources/messagebased.py", line 306, in read_raw
chunk, status = self.visalib.read(self.session, size)
File "/usr/lib/python2.7/site-packages/pyvisa/ctwrapper/functions.py", line 1582, in read
ret = library.viRead(session, buffer, count, byref(return_count))
File "/usr/lib/python2.7/site-packages/pyvisa/ctwrapper/highlevel.py", line 188, in _return_handler
raise errors.VisaIOError(ret_value)
pyvisa.errors.VisaIOError: VI_ERROR_TMO (-1073807339): Timeout expired before operation completed.
PyVISA 1.8 should default to '\r' line termination for serial, so your 2410 may not be receiving the '\n' it needs to start it parsing the command. Try doing
keithley.write_termination = '\n'
keithley.read_termination = '\n'
right after your open_resource() call.
Thanks for the suggestion but it seems as though I needed to explicitly set the baud rate.
rm = visa.ResourceManager()
smu = rm.open_resource("ASRL2::INSTR")
smu.baud_rate = 57600

Simple *IDN? query resulted in "Timeout expired before operation completed"

I tried to do a simple query to my LAB instrument by:
>>> import visa
>>> rm = visa.ResourceManager()
>>> viavi = rm.open_resource("TCPIP0::10.0.2.76::5001::SOCKET")
>>> print(viavi.query("*IDN?"))
The result was:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Program Files\Python35\lib\site-packages\pyvisa\resources\messagebase
d.py", line 407, in query
return self.read()
File "C:\Program Files\Python35\lib\site-packages\pyvisa\resources\messagebase
d.py", line 332, in read
message = self.read_raw().decode(enco)
File "C:\Program Files\Python35\lib\site-packages\pyvisa\resources\messagebase
d.py", line 306, in read_raw
chunk, status = self.visalib.read(self.session, size)
File "C:\Program Files\Python35\lib\site-packages\pyvisa\ctwrapper\functions.p
y", line 1582, in read
ret = library.viRead(session, buffer, count, byref(return_count))
File "C:\Program Files\Python35\lib\site-packages\pyvisa\ctwrapper\highlevel.p
y", line 188, in _return_handler
raise errors.VisaIOError(ret_value)
pyvisa.errors.VisaIOError: VI_ERROR_TMO (-1073807339): Timeout expired before op
eration completed.
According to what I learned till now (from the experience of others). This timeout error is somehow related to line termination ("\n"). How can I solve this problem ?
I found out that it was all related to the read_termination. My LAB instrument simply terminated its response by a '\n'.
While my script was looking for a '\r' all that time.

Spring-python JMS receiver. MQSCO wrong size. Given: 540, expected 560

I am trying to connect to JMS queue by spring-python. I take example of receiver from official spring python site
enter code herefrom springpython.jms.core import JmsTemplate
from springpython.jms.factory import WebSphereMQConnectionFactory
qm_name = "my_qmname"
channel = "my_channel"
host = 'my_host'
listener_port = 'my_port'
queue1 = "MY_QUEUE"
# The connection factory we're going to use.
factory = WebSphereMQConnectionFactory(qm_name, channel, host, listener_port)
# Every JmsTemplate uses a connection factory for actually communicating with a JMS provider.
jms_template = JmsTemplate(factory)
# Get a message off the queue. The call to receive will by default time out
# after 1000ms and raise springpython.jms.NoMessageAvailableException then.
jms_template.receive(queue1)
# We're not using an IoC so we need to shut down the connection factory ourselves.
factory.destroy()
And i get next error:
Traceback (most recent call last):
File "E:/Repos/provisioning/test.py", line 30, in <module>
jms_template.receive('MY_QUEUE')
File "c:\Python27\Lib\site-packages\springpython\jms\core.py", line 108, in receive
return self.factory.receive(dest, timeout)
File "c:\Python27\Lib\site-packages\springpython\jms\factory.py", line 327, in receive
self._connect()
File "c:\Python27\Lib\site-packages\springpython\util.py", line 45, in lockedfunc
return f(*args, **kwargs)
File "c:\Python27\Lib\site-packages\springpython\jms\factory.py", line 211, in _connect
raise exc
springpython.jms.WebSphereMQJMSException: MQSCO wrong size. Given: 540, expected 560
As i found MQSCO is something related to SSL, how can i fix the problem?
Thank you

Categories