05-19-2025 03:37 PM
Hello all,
I have been using Labview to send/receive data from instruments using GPIB, VISA, SERIAL, etc.
Never used a Ethernet port before, so I stuck on the basic part of opening the connection and sending the commands properly.
I did a NI I/O trace capture.
Line 1 & 2 is using NI MAX (Hostname 172.16.0.25 at Port 10001), with Line Feed \n termination character.
I am sending the simple *IDN?\n. I get the answer as shown on line 2 (and same on NI-MAX).
When I send the command using Labview with VISA, NI trace shows:
I set timeout at 5000ms, same as in NI-MAX (on a next iteration), but this one was not giving any errors.
Only when running NI-MAX again, will error once or answer something other that the answer for *IDN?, to which cleaning the buffer and using NI-MAX again would work just fine.
What I am missing?
I use to use VISA write, read without the property node and would work fine?
I am trying to control an EXFO Variable Optical Attenuator from Dicon, with a Ethernet server inside this damn machine.
No drivers available.
Thank you,
Gaston
05-19-2025 07:34 PM
I personally use VISA if the instrument supports the LXI protocol, but if it doesn't then I instead just use the TCP/IP palette instead of the VISA commands.
You do lose some VISA properties and such, but you gain the ability to operate on a more native level. It may help.
Still though, you have some bits in your code example that look weird so I have to wonder if your code example is in the exact state that got the I/O trace that you show. The "Write" command is set to just send a semicolon, and the "Read" command has its bytes to read input wired to the Return Count of the Write command, which is not going to give you a full reply.
The I/O trace also makes it look like maybe you're sending a literal "\n", i.e. two bytes, a slash and an "n" instead of the line feed character. It should be one byte. "*IDN?\n" should be 6 characters, but shows as 7 in the second entry. How are you handling adding the termination character?
05-20-2025 03:29 AM - edited 05-20-2025 03:30 AM
@Kyle97330 wrote:
The I/O trace also makes it look like maybe you're sending a literal "\n", i.e. two bytes, a slash and an "n" instead of the line feed character. It should be one byte. "*IDN?\n" should be 6 characters, but shows as 7 in the second entry. How are you handling adding the termination character?
By typing in \n at the end but without having switched the display mode to '\' Codes Display mode.
05-20-2025 10:20 AM
There are many different examples of how to do TCP/IP in the LabVIEW examples. Just look here.
05-21-2025 11:45 AM
Yes, I was using \n instead of the proper character return.
Still having some issues related to the read function and the number of characters to read, so it does not error out.
05-21-2025 11:46 AM
I was doing it wrong. Now I having issues with the read number of characters. Thank you!