Python Forum
Connect device using Visa TCP Socket connection
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Connect device using Visa TCP Socket connection
#1
In summary; I am trying to connect to a device using Visa TCP Socket option.

The Connection does not complain but I can not run any SCPI command to the device.
[Edited the question to remove my first question about port number, since the 5025 is the correct port number]

Sample code in use:
import pyvisa as visa

try:
  resourceManager = visa.ResourceManager() 
  dev = 'TCPIP0::192.168.0.44::5025::SOCKET'
  session = resourceManager.open_resource(dev)
  print('\n Open Successful!')
  print('IDN:' +str(session.query('*IDN?')))

except Exception as e:
  print('[!] Exception:' +str(e))
I get the below response:
Output:
C:\d777py>python socket_test.py Open Successful! [!] Exception:VI_ERROR_TMO (-1073807339): Timeout expired before operation completed.
Thanks in advance! P.S. I had no issues with GPIB, USB or other TCPIP connections.
Reply
#2
I have sorted this with the below modification, i.e. it was all about termination characters! Hope this helps someone else too.
import pyvisa as visa

try:  
  resourceManager = visa.ResourceManager() 
  visa.log_to_screen
  dev = 'TCPIP0::192.168.0.44::5025::SOCKET'
  session = resourceManager.open_resource(dev)
  print('\n Open Successful!')
  session.read_termination = '\n'
  session.write_termination = '\n'
  print('IDN:' +str(session.query('*IDN?')))

except Exception as e:
  print('[!] Exception:' +str(e))
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Input network device connection info from data file edroche3rd 6 1,067 Oct-12-2023, 02:18 AM
Last Post: edroche3rd
  Serial connection connection issue Joni_Engr 15 8,102 Aug-30-2021, 04:46 PM
Last Post: deanhystad
  Reading UDP from external device without device software ikdemartijn 2 3,424 Dec-03-2019, 04:29 PM
Last Post: Larz60+
  Socket connection and thread tracking... MuntyScruntfundle 2 2,764 Oct-21-2018, 02:55 AM
Last Post: Skaperen
  Display device details i.e connected with more than one device shintonp 6 5,337 May-10-2017, 06:00 AM
Last Post: shintonp

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020