05-07-2024 04:50 PM
I have no problem opening a session ...... I manually punch in the IP address and socket, and the session opens successfully. This program I am talking to is written to respond in a specific manner to certain strings sent through the TCPIP, e.g. "Do this thing" and "Do that thing". In C#, I would make the call like so:
Session.RawIO.Write("Do this thing\r\n");
This works, because the program responds precisely as desired - it sets a mode, or turns off. With each command I send to it, it places the string "OK" in the output buffer. This is where the problem comes in - I can't read it. RawIO.Read(), RawIO.ReadString(), etc all fail and time out. I know from the programmer's perspective that the string "OK" is there because this is a well established program that I am talking to, and "OK" is only sent if the call is successful. In the VISA test panel, this fact is reinforced when I attempt a read. The response "OK\r\n" appears, but the session still times out. If I send the *IDN? query, the expected response appears, followed by a timeout. The termination character is \n. Every read function I have tried either through C# or the VISA test panel has failed. Some colleagues in LabView are able to read this response with no problem......what am I doing wrong here?
05-16-2024 11:35 AM
Update:
The only thing I can think of is that the code on the PC side is incompatible with the VISA drivers I am using ... and I don't know much about how the abstraction works, but the C# Read() methods are looking for something (a status bit, perhaps?) that they are not seeing, therefore the drivers are assuming there's nothing in the buffer even when there is (and I can see it!).
05-22-2024 07:00 AM
How do you setup the VISA session? You say the termination character is "\n" but you do need to set several properties to enable automatic termination character processing.
Not sure about the exact name in the C# interface but in LabVIEW they are called:
Message Based Settings:Termination Character Enable: BOOL
Message Based Settings:Termination Character: UINT8
Both of these must be set correctly to allow the VISA session to do termination character processing
05-22-2024 08:27 AM
In C#, I have these options:
byte TerminationCharacter
bool TerminationCharacterEnabled
I have set the TerminationCharacter to 10, and even 13 (\r), to no avail.
I can set up the session as TcpipSession or as a MessageBasedSession. Both appear to have the same result:
(IMessageBasedSession) talktoPC = (IMessageBasedSession)GlobalResourceManager.Open(address)
(ITcpipSession) talktoPC = (ITcpipSession)GlobalResourceManager.Open(address)