LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA Clear Vs Flush Buffer for RS-232


@bienieck wrote:

Is VISA Flush I/O Buffer redundant here and could be removed? Or maybe there should be used VISA Flush I/O Buffer at the beginning instead of VISA 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 interpret 0x30 mask?

 

VISA.png


 

According the the help, the VISA Clear does the following:

  • Serial Instr—VISA flushes (discards) the I/O output buffer, sends a break, and then flushes the I/O input buffer.

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 11 of 17
(2,132 Views)

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):

Edjsch_0-1634234942388.png

 

Hope this helps!

Message 12 of 17
(2,119 Views)

@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...

Michał Bieńkowski
CLA, CTA, CPI

  1. Did someone devote their time to help solve your problem? Appreciate it and give kudos.
  2. Problem solved? Accept as a solution so that others can find it faster in the future.
  3. Contribute to the development of TestStand by voting on the TestStand Idea Exchange.
0 Kudos
Message 13 of 17
(2,110 Views)

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.

0 Kudos
Message 14 of 17
(2,100 Views)

@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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 15 of 17
(2,080 Views)

@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?

Michał Bieńkowski
CLA, CTA, CPI

  1. Did someone devote their time to help solve your problem? Appreciate it and give kudos.
  2. Problem solved? Accept as a solution so that others can find it faster in the future.
  3. Contribute to the development of TestStand by voting on the TestStand Idea Exchange.
0 Kudos
Message 16 of 17
(1,971 Views)

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?

Message 17 of 17
(1,960 Views)