[COM] Communication issue with Keysight B2987A using TCPIP::SOCKET
LarsEggimann opened this issue · comments
Hello There!
I am having issues connecting to my instrument. I use the following script for testing:
#!/usr/bin/python
import pyvisa
from pyvisa.resources import TCPIPSocket
import time
import os
rm = pyvisa.ResourceManager("@py")
my_instrument: TCPIPSocket = rm.open_resource("TCPIP::192.168.113.72::5025::SOCKET") # type: ignore
# For Serial and TCP/IP socket connections enable the read Termination Character, or read's will timeout
if my_instrument.resource_name.startswith("ASRL") or my_instrument.resource_name.endswith("SOCKET"):
my_instrument.read_termination = "\n"
print('Connected!')
print('Pinging...')
os.system('ping -c 5 192.168.113.72')
print('Querying...')
print(my_instrument.query("*IDN?"))
The pings are succesfull but when trying to query the identification string with *IDN?
i get a connection refused
error. This is the output of my test-script:
(.venv) [lars@lars-arch MasterThesis]$ "/home/lars/Nextcloud/Uni/Uni 8. Semester (Masters)/MasterThesis/.venv/bin/python" "/home/lars/Nextcloud/Uni/Uni 8. Semester (Masters)/MasterThesis/code/testing/test_keysight.py"
Connected!
Pinging...
PING 192.168.113.72 (192.168.113.72) 56(84) bytes of data.
64 bytes from 192.168.113.72: icmp_seq=1 ttl=64 time=0.019 ms
64 bytes from 192.168.113.72: icmp_seq=2 ttl=64 time=0.147 ms
64 bytes from 192.168.113.72: icmp_seq=3 ttl=64 time=0.030 ms
64 bytes from 192.168.113.72: icmp_seq=4 ttl=64 time=0.040 ms
64 bytes from 192.168.113.72: icmp_seq=5 ttl=64 time=0.052 ms
--- 192.168.113.72 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4045ms
rtt min/avg/max/mdev = 0.019/0.057/0.147/0.046 ms
Querying...
Traceback (most recent call last):
File "/home/lars/Nextcloud/Uni/Uni 8. Semester (Masters)/MasterThesis/code/testing/test_keysight.py", line 33, in <module>
print(my_instrument.query("*IDN?"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/lars/Nextcloud/Uni/Uni 8. Semester (Masters)/MasterThesis/.venv/lib/python3.11/site-packages/pyvisa/resources/messagebased.py", line 641, in query
self.write(message)
File "/home/lars/Nextcloud/Uni/Uni 8. Semester (Masters)/MasterThesis/.venv/lib/python3.11/site-packages/pyvisa/resources/messagebased.py", line 196, in write
count = self.write_raw(message.encode(enco))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/lars/Nextcloud/Uni/Uni 8. Semester (Masters)/MasterThesis/.venv/lib/python3.11/site-packages/pyvisa/resources/messagebased.py", line 156, in write_raw
return self.visalib.write(self.session, message)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/lars/Nextcloud/Uni/Uni 8. Semester (Masters)/MasterThesis/.venv/lib/python3.11/site-packages/pyvisa_py/highlevel.py", line 544, in write
written, status_code = self.sessions[session].write(data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/lars/Nextcloud/Uni/Uni 8. Semester (Masters)/MasterThesis/.venv/lib/python3.11/site-packages/pyvisa_py/tcpip.py", line 1247, in write
size = self.interface.send(block)
^^^^^^^^^^^^^^^^^^^^^^^^^^
ConnectionRefusedError: [Errno 111] Connection refused
On the instrument i see that the LAN connection is established and no error messages are displayed. I hope someone can tell me what I am doing wrong. Thanks in advance!
Instrument details
- Model: Keysight B2987A
- Communication: TCPIP
- Link to the documentation (if available): keysight
Output of pyvisa-info
(.venv) [lars@lars-arch MasterThesis]$ pyvisa-info
/bin/sh: -c: line 1: syntax error near unexpected token `('
/bin/sh: -c: line 1: `ldd /home/lars/Nextcloud/Uni/Uni 8. Semester (Masters)/MasterThesis/.venv/bin/python 2>/dev/null'
/bin/sh: -c: line 1: syntax error near unexpected token `('
/bin/sh: -c: line 1: `ldd /home/lars/Nextcloud/Uni/Uni 8. Semester (Masters)/MasterThesis/.venv/bin/python 2>/dev/null'
/bin/sh: -c: line 1: syntax error near unexpected token `('
/bin/sh: -c: line 1: `ldd /home/lars/Nextcloud/Uni/Uni 8. Semester (Masters)/MasterThesis/.venv/bin/python 2>/dev/null'
/bin/sh: -c: line 1: syntax error near unexpected token `('
/bin/sh: -c: line 1: `ldd /home/lars/Nextcloud/Uni/Uni 8. Semester (Masters)/MasterThesis/.venv/bin/python 2>/dev/null'
/bin/sh: -c: line 1: syntax error near unexpected token `('
/bin/sh: -c: line 1: `ldd /home/lars/Nextcloud/Uni/Uni 8. Semester (Masters)/MasterThesis/.venv/bin/python 2>/dev/null'
Machine Details:
Platform ID: Linux-6.8.2-arch2-1-x86_64-with-glibc2.39
Processor:
Python:
Implementation: CPython
Executable: /home/lars/Nextcloud/Uni/Uni 8. Semester (Masters)/MasterThesis/.venv/bin/python
Version: 3.11.8
Compiler: GCC 13.2.1 20230801
Architecture: ('x86', 64)
Build: Feb 12 2024 14:50:05 (#main)
Unicode: UCS4
PyVISA Version: 1.14.1
Backends:
ivi:
Version: 1.14.1 (bundled with PyVISA)
Binary library: Not found
py:
Version: 0.7.2
ASRL INSTR: Available via PySerial (3.5)
USB INSTR: Available via PyUSB (1.2.1). Backend: libusb1
USB RAW: Available via PyUSB (1.2.1). Backend: libusb1
TCPIP INSTR: Available
Resource discovery:
- VXI-11: ok
- hislip: ok
VICP INSTR: Available
TCPIP SOCKET: Available
GPIB INSTR:
Please install linux-gpib (Linux) or gpib-ctypes (Windows, Linux) to use this resource type. Note that installing gpib-ctypes will give you access to a broader range of functionalities.
No module named 'gpib'
GPIB INTFC:
Please install linux-gpib (Linux) or gpib-ctypes (Windows, Linux) to use this resource type. Note that installing gpib-ctypes will give you access to a broader range of functionalities.
No module named 'gpib'
It is solved now, it was a configuration issue on my part. I connected to the device directly via an ethernet cable and by mistake set the IP of my computer to the same as the instruments. This lead to a connection issue.