Python Forum

Full Version: Connect device using Visa TCP Socket connection
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
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))