08-01-2018 11:09 AM
Hi,
Thank you for the response and sorry for being vague. I am using Yokogawa AQ6370D optical spectrum analyzer. I am using the ykaq6370 instrument driver - http://sine.ni.com/apps/utf8/niid_web_display.download_page?p_id_guid=68817DCC4CA04C7EE05400144FF8B5....
I have connected using Ethernet to LabVIEW. I get an error with VISA Read in the VI with an error message 1073807339 - timeout before operation completed. I am positive that the LabVIEW makes an connection with the OSA as the instrument show that its under remote control.
08-01-2018 11:13 AM
Hi,
Thank you for the response and sorry for being vague.
I am using Yokogawa AQ6370D optical spectrum analyzer. I am using the ykaq6370 instrument driver - http://sine.ni.com/apps/utf8/niid_web_display.download_page?p_id_guid=68817DCC4CA04C7EE05400144FF8B....
I have connected using Ethernet to LabVIEW. I get an error with VISA Read in the VI with an error message 1073807339 - timeout before operation completed. I am positive that the LabVIEW makes an connection with the OSA as the instrument show that its under remote control.
08-02-2018 01:33 AM
Hi,
A few years back I used the AQ6370 without any problems.
Can you run the initialize VI and tell me if that is OK ?
Can you post a screenshot of MAX with the AQ part ?
Kees
09-13-2023 07:54 AM
Hello|
I'm facing the same problem with python 3.7. I can't establish a socket connection with the instrument. Anyone guessing which is wrong on the script?
09-13-2023 09:03 AM
From what I can remember it was not that difficult to get the instrument connected.
But I only used LabVIEW and MAX.
Kees
02-22-2024 10:13 AM
Were you able to fix it? I am also working on it.
02-22-2024 10:21 AM
I am also working on it. I have the problem that I can connect through python, but when I do a single sweep I get nothing from the computer.
09-09-2025 07:37 PM
Here is my working solution:
"""
Talking to the Yokogawa OSA AQ6370E: minimal working example
"""
import socket
import time
#####################
### Creating a "Write" function
def Write(sock_file, command_str):
# command_str = "open \"anonymous\"" + "\r\n"
command_str = command_str + "\r\n"
# print(command_str)
## s.send(command_str.encode("utf-8"))
sock_file.write(command_str.encode("utf-8"))
# sock_file.flush() # Important to ensure data is sent over the network
#####################
### Creating a "Readline" function
def Readline(sock_file):
# data = sock_file.read(1024) # Read up to 1024 bytes
data = sock_file.readline() # Read a line until newline character
return data
#####################
### Creating a "Query" function
def Query(sock_file, command_str):
# command_str = "open \"anonymous\"" + "\r\n"
Write(sock_file, command_str)
time.sleep(0.5)
data = Readline(sock_file) # Read a line until newline character
return data
#####################
### Yogogawa ip and port (always use that port number)
TCP_IP = '192.168.1.35'
TCP_PORT = 10001
#####################
### Creating the tcp/ip socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))
s.setblocking(False) # <- very important that we do this!
# s.settimeout(10)
# A socket object can be in one of three modes: blocking, non-blocking, or timeout. Sockets are by default always created in blocking mode
# https://docs.python.org/3/library/socket.html#socket.socket.setblocking
# Wrap the socket with makefile(): Convert the socket object into a file-like object.
# readline() on the file-like object will block until a newline character is received or the connection is closed.
# If you are dealing with binary data or need more control over buffering, consider using sock.makefile('rb') for binary reading and then decoding the received bytes.
sock_file = s.makefile('rwb', buffering=0) # 'r' for reading, 'rb' for binary reading, 'w' for writing, 'wb' for writing binary, 'rwb' for read/write binary. buffering=0 is often used for real-time network communication to ensure data is sent/received immediately without internal buffering.
#####################
### To log in to the Yokogawa, you need to long in with a specific username and password
command_str = "open \"anonymous\"" # do not change!
r = Query(sock_file, command_str)
print(r.decode()) # should be: AUTHENTICATE CRAM-MD5.
command_str = "" # do not change!
r = Query(sock_file, command_str)
print(r.decode()) # should be: ready
#####################
### Now, we should be able to freely talk to the yokogawa. We can test the connection by querying "*IDN?"
command_str = "*IDN?"
r = Query(sock_file, command_str)
print(r.decode()) # should be: YOKOGAWA,AQ6370E,901C12908,01.04
#####################
### Do a single sweep:
command_str = ":INIT"
r = Write(sock_file, command_str)
# sock_file.close()
### from https://forums.ni.com/t5/Instrument-Control-GPIB-Serial/yokogawa-aq6370/td-p/945995