10-14-2021 11:41 AM - edited 10-14-2021 11:47 AM
@bienieck wrote:
Is
VISA Flush I/O Buffer
redundant here and could be removed? Or maybe there should be usedVISA Flush I/O Buffer
at the beginning instead ofVISA Clear
?
What is the purpose of
VISA Set I/O Buffer Size
at the end? Is this a common practice to set it during serial communication configuration? How to interpret0x30
mask?
According the the help, the VISA Clear does the following:
The break is "a condition that holds the transmit line logic-low for longer than one data byte." (Found that from an example description).
So, yes, the Flush I/O Buffer does seem redundant with the VISA Clear. I think I would follow the comment in the code stating to move the VISA Clear into the case for a GPIB instrument.
In my experience, I have never needed to use the VISA Clear or the VISA Flush I/O Buffer. I will typically do a VISA Read to clear out what is in the buffer and attempt to synchronize to the termination character (assuming the instrument is constantly pushing out data).
I also never set the buffer size. Ironically, the buffer is being set to the default value. So I would remove that as well.
10-14-2021 01:14 PM
I use the "VISA Configure Serial Port" vi in my application. That is all I've found to be necessary. I don't think I've ever used the Clear Output Buffer because I'm in control and I know what I send. However, I have used the Clear Input Buffer when there's the possibility of the device / instrument I'm communicating with sending data that I didn't read. That should never happen because I always wait for a response or get a Timeout Exception error (I normally set that to 1 second, as I feel the default 10 seconds is much too long). During debugging I have run into the situation where I didn't know the instrument's response time was greater than a second for certain commands. In that case, when my program moved on, there could/would be characters in my receive buffer. But when do you know to "flush the buffer" in this situation? How long to wait? This is an error handling situation that is application dependent.
Here's a snip of my block diagram where I initialize the port when my program (vi) opens (i == 0 in my overall forever loop this is in):
Hope this helps!
10-14-2021 02:39 PM
@crossrulz wrote:
Ironically, the buffer is being set to the default value. So I would remove that as well.
What is more, I think setting TermChar En
together with ASRL End In
makes no sense. Also, \r\n
as TermChar
is wrong - only single character is supported by VISA. Long story short Hioki needs to learn how to write drivers...
10-14-2021 03:05 PM
Update - When I said, "I don't think I've ever used the Clear Output Buffer" I meant to say, "... the 'VISA Clear'..." after opening and configuring the port. Also, When I said, "Clear Input Buffer" I meant, "Flush Input Buffer". Sorry for the mistake.
In my experience, opening a port, whether with LV or C# or whatever, clears both the input and output buffers.
10-14-2021 09:33 PM
@bienieck wrote:
Long story short Hioki needs to learn how to write drivers...
I have found most instrument manufacturers do. Which is why I almost always write my own drivers.
11-10-2021 05:05 PM
@Edjsch wrote:
I use the "VISA Configure Serial Port" vi in my application. That is all I've found to be necessary.
Don't you need to use VISA Open as well? I debugged my driver today and I found that before VISA Configure Serial Port I need to use VISA Open to make things work. How to explain this?
11-11-2021 01:47 AM
I never needed Visa Open after Visa Configure Serial Port, from my experience it's one or the other.
Maybe you set up Visa CSP wrong and Visa Open then "corrected" your mistake?