Cant connect using vxi-11

235 views
Skip to first unread message

Elias Faraclas

unread,
Dec 24, 2014, 10:54:01 PM12/24/14
to pytho...@googlegroups.com
Hey guys,

I'm having trouble connecting to my instrument using this driver.  It fails immediately on the vxi11.Instrument(...) call. 

For background, I have an instrument that I have been using with NI VISA very successfully.  Specifically, with NI-VISA installed I can control it quite well using PyVisa.  I would like to use this library instead so that I can run the python scripts on a linux machine.  NI-VISA is working "fine" on the linux machine, but it can only handle calls from 32-bit processes and I would rather not jump through the hoops of getting both 32-bit and 64-bit python systems running on my Gentoo box.  However, the error exists on both the linux box and the windows box, so I think it is a problem with the python vxi11.

My instrument has the VISA resource name of TCPIP0::192.168.0.204::inst0::INSTR.  Again, using NI-VISA directly or PyVisa I have no issues.  Here is the output from a python console of me trying to connect to it:

C:\Anaconda3\python.exe -u C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.0.2\helpers\pydev\pydevconsole.py 37075 37076
Python 3.4.1 |Anaconda 2.0.1 (64-bit)| (default, Jun 11 2014, 17:27:11) [MSC v.1600 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.

IPython 2.1.0 -- An enhanced Interactive Python.
Anaconda is brought to you by Continuum Analytics.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.
PyDev console: using IPython 2.1.0

import sys; print('Python %s on %s' % (sys.version, sys.platform))
sys.path.extend(['C:\\P4VM\\Mercury\\Development\\Elias\\Tests\\Python\\VXi11'])

Python 3.4.1 |Anaconda 2.0.1 (64-bit)| (default, Jun 11 2014, 17:27:11) [MSC v.1600 64 bit (AMD64)] on win32
In[2]: import vxi11
In[3]: instr = vxi11.Instrument("192.168.0.204")
Traceback (most recent call last):
  File "C:\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2883, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-3-cc6b9f70c55e>", line 1, in <module>
    instr = vxi11.Instrument("192.168.0.204")
  File "C:\Anaconda3\lib\site-packages\vxi11\vxi11.py", line 368, in __init__
    self.client = CoreClient(host)
  File "C:\Anaconda3\lib\site-packages\vxi11\vxi11.py", line 259, in __init__
    rpc.TCPClient.__init__(self, host, DEVICE_CORE_PROG, DEVICE_CORE_VERS)
  File "C:\Anaconda3\lib\site-packages\vxi11\rpc.py", line 508, in __init__
    port = pmap.get_port((prog, vers, IPPROTO_TCP, 0))
  File "C:\Anaconda3\lib\site-packages\vxi11\rpc.py", line 468, in get_port
    self.unpacker.unpack_uint)
  File "C:\Anaconda3\lib\site-packages\vxi11\rpc.py", line 178, in make_call
    self.do_call()
  File "C:\Anaconda3\lib\site-packages\vxi11\rpc.py", line 268, in do_call
    reply = recvrecord(self.sock)
  File "C:\Anaconda3\lib\site-packages\vxi11\rpc.py", line 246, in recvrecord
    last, frag = recvfrag(sock)
  File "C:\Anaconda3\lib\site-packages\vxi11\rpc.py", line 230, in recvfrag
    raise EOFError
EOFError
In[4]: instr = vxi11.Instrument("TCPIP::192.168.0.204::INSTR")
Traceback (most recent call last):
  File "C:\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2883, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-4-0f43f4ae6846>", line 1, in <module>
    instr = vxi11.Instrument("TCPIP::192.168.0.204::INSTR")
  File "C:\Anaconda3\lib\site-packages\vxi11\vxi11.py", line 368, in __init__
    self.client = CoreClient(host)
  File "C:\Anaconda3\lib\site-packages\vxi11\vxi11.py", line 259, in __init__
    rpc.TCPClient.__init__(self, host, DEVICE_CORE_PROG, DEVICE_CORE_VERS)
  File "C:\Anaconda3\lib\site-packages\vxi11\rpc.py", line 508, in __init__
    port = pmap.get_port((prog, vers, IPPROTO_TCP, 0))
  File "C:\Anaconda3\lib\site-packages\vxi11\rpc.py", line 468, in get_port
    self.unpacker.unpack_uint)
  File "C:\Anaconda3\lib\site-packages\vxi11\rpc.py", line 178, in make_call
    self.do_call()
  File "C:\Anaconda3\lib\site-packages\vxi11\rpc.py", line 268, in do_call
    reply = recvrecord(self.sock)
  File "C:\Anaconda3\lib\site-packages\vxi11\rpc.py", line 246, in recvrecord
    last, frag = recvfrag(sock)
  File "C:\Anaconda3\lib\site-packages\vxi11\rpc.py", line 230, in recvfrag
    raise EOFError
EOFError
In[5]: instr = vxi11.Instrument("TCPIP::192.168.0.204::INSTR",inst0)
Traceback (most recent call last):
  File "C:\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2883, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-5-3dd78c4e3791>", line 1, in <module>
    instr = vxi11.Instrument("TCPIP::192.168.0.204::INSTR",inst0)
NameError: name 'inst0' is not defined
In[6]: instr = vxi11.Instrument("TCPIP::192.168.0.204::INSTR","inst0")
Traceback (most recent call last):
  File "C:\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2883, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-6-86e816cc01a4>", line 1, in <module>
    instr = vxi11.Instrument("TCPIP::192.168.0.204::INSTR","inst0")
  File "C:\Anaconda3\lib\site-packages\vxi11\vxi11.py", line 368, in __init__
    self.client = CoreClient(host)
  File "C:\Anaconda3\lib\site-packages\vxi11\vxi11.py", line 259, in __init__
    rpc.TCPClient.__init__(self, host, DEVICE_CORE_PROG, DEVICE_CORE_VERS)
  File "C:\Anaconda3\lib\site-packages\vxi11\rpc.py", line 508, in __init__
    port = pmap.get_port((prog, vers, IPPROTO_TCP, 0))
  File "C:\Anaconda3\lib\site-packages\vxi11\rpc.py", line 468, in get_port
    self.unpacker.unpack_uint)
  File "C:\Anaconda3\lib\site-packages\vxi11\rpc.py", line 178, in make_call
    self.do_call()
  File "C:\Anaconda3\lib\site-packages\vxi11\rpc.py", line 268, in do_call
    reply = recvrecord(self.sock)
  File "C:\Anaconda3\lib\site-packages\vxi11\rpc.py", line 246, in recvrecord
    last, frag = recvfrag(sock)
  File "C:\Anaconda3\lib\site-packages\vxi11\rpc.py", line 230, in recvfrag
    raise EOFError
EOFError

Can you guys see what I am doing wrong, or have any ideas on how to fix this?

Thanks! 

Jeffrey Wurzbach

unread,
Dec 27, 2014, 10:47:51 PM12/27/14
to Elias Faraclas, python-ivi

I think the resource string you pass in line 3 of your iPython session is incomplete. Try using the whole string, TCPIP0::192.168.0.204::inst0::INSTR, to create the instrument object.

sent from my phone....

--
You received this message because you are subscribed to the Google Groups "python-ivi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-ivi+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alex Forencich

unread,
Dec 27, 2014, 11:28:40 PM12/27/14
to pytho...@googlegroups.com
What instrument are you trying to communicate with, exactly?  And are you using the latest version of python vxi11?

Alex Forencich

Elias Faraclas

unread,
Dec 27, 2014, 11:41:14 PM12/27/14
to pytho...@googlegroups.com
I am using version 0.7, which is the latest version.  And using the whole string gives the same error.  Keep in mind the instrument is up and I communicate with it via the NI-VISA Interactive Control panel before and after the python test for sanity purposes.  Here is the output:

Python 3.4.1 (default, Dec 20 2014, 00:21:11) 
[GCC 4.8.3] on linux
>>> import vxi11
>>> vxi11.__version__
'0.7'
>>> instr = vxi11.Instrument("TCPIP0::192.168.0.204::inst0::INSTR")
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/usr/lib64/python3.4/site-packages/vxi11/vxi11.py", line 368, in __init__
    self.client = CoreClient(host)
  File "/usr/lib64/python3.4/site-packages/vxi11/vxi11.py", line 259, in __init__
    rpc.TCPClient.__init__(self, host, DEVICE_CORE_PROG, DEVICE_CORE_VERS)
  File "/usr/lib64/python3.4/site-packages/vxi11/rpc.py", line 508, in __init__
    port = pmap.get_port((prog, vers, IPPROTO_TCP, 0))
  File "/usr/lib64/python3.4/site-packages/vxi11/rpc.py", line 468, in get_port
    self.unpacker.unpack_uint)
  File "/usr/lib64/python3.4/site-packages/vxi11/rpc.py", line 178, in make_call
    self.do_call()
  File "/usr/lib64/python3.4/site-packages/vxi11/rpc.py", line 268, in do_call
    reply = recvrecord(self.sock)
  File "/usr/lib64/python3.4/site-packages/vxi11/rpc.py", line 246, in recvrecord
    last, frag = recvfrag(sock)
  File "/usr/lib64/python3.4/site-packages/vxi11/rpc.py", line 230, in recvfrag
    raise EOFError
EOFError

Alex Forencich

unread,
Dec 28, 2014, 12:55:04 AM12/28/14
to Elias Faraclas, pytho...@googlegroups.com
Send me a wireshark capture. What instrument ate you trying to talk to? I have seen issues with non-standard vxi11 implementations that have caused similar errors.

Alex Forencich

Elias Faraclas

unread,
Dec 28, 2014, 1:10:16 PM12/28/14
to Alex Forencich, pytho...@googlegroups.com
I will send a wireshark capture shortly.  This is a new instrument that is not released yet.  While I expected it to have a standard vxi11 implementation, there is a possibility [apparently] that it may not.  Do you know specifically the set of non-standard conditions that have caused this in other cases?  There is a possibility I can have this fixed on the instrument itself.

Alex Forencich

unread,
Dec 28, 2014, 1:30:08 PM12/28/14
to Elias Faraclas, pytho...@googlegroups.com
I have seen instruments sending trailing zeros that necessitated removing some error checking. I can't recall exactly what the error was, though. A wireshark capture should reveal where the problem is. It may be obvious from the packet decode in wireshark what is going on if there is an issue with a truncated packet or similar.

Alex Forencich

Elias Faraclas

unread,
Dec 28, 2014, 6:58:57 PM12/28/14
to pytho...@googlegroups.com, fara...@gmail.com
Here is the wireshark log capturing packets to and from the instrument.  
vxi11Log.pcapng

Alex Forencich

unread,
Jan 6, 2015, 3:33:39 PM1/6/15
to pytho...@googlegroups.com
Looks like the portmapper implementation on your device is broken.  python-vxi11 connects to the portmapper on port 111.  From there, it asks what port to connect to for VXI-11.  However, it seems the portmapper implementation does not send the correct response.  Seems like the 'last fragment' flag is not set.  Then the portmapper closes the TCP connection, which it should not be doing.  Since the connection is closed by the server while python-vxi11 is waiting for another fragment, it crashes with an EOF error. 

Attached is a trace of a 'good' portmap handshake that I just ran locally with the new server functionality in python-vxi11 (I don't have an instrument in front of me to test with at the moment).  If you open this up in wireshark, you can see that the client closes the TCP connection and not the host.  Also see packet 5 in the trace you sent, the last fragment flag is not set.  Then packet 6 is sent from the server with FIN set, closing the connection. 

Alex Forencich
vxi11portmap.pcapng
Reply all
Reply to author
Forward
0 new messages