LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA Clear Vs Flush Buffer for RS-232

 Hello all,

 

I would really appreciate if someone could help me to find the difference between VISA Clear and Flush buffer when I use these functions while

 

communicating over RS-232 between PC and microcontroller. I found that Flush can selectively clear my input and output buffer either by writing to device or by just clearing where as VISA clear will just clear the PC I\O buffers. One more thing I found is VISA Clear takes approxuimately 250 Msecs to perform operation where as Flush buffer takes no time. Am I compromising something when I use Flush buffer ? I would really appreciate if any of you experts could help me to answer this question.

 

Thanks in Advance,

Manu Mohan

 





0 Kudos
Message 1 of 17
(29,728 Views)

Dear Sir!

 

 Where you able to communicate even after you used the 'VISA clear' to clear the buffer, without re-opening the device in Visa configure again ?(just curious).. And u are absolutely right and As its found in the help,  VISA Clear for the Serial Instrument  flushes (simply discards) the I/O output buffer,  sends a break, and then flushes the I/O input buffer... Where as in Flush I/O Buffer we can flush more than one buffer Simultaneously by ORing the masks... And i suppose u wont be compromising anything by Flush I/O... 

with regards,

Gokul

Message 2 of 17
(29,708 Views)

@goku wrote:

Dear Sir!

 

 Where you able to communicate even after you used the 'VISA clear' to clear the buffer, without re-opening the device in Visa configure again ?(just curious).. And u are absolutely right and As its found in the help,  VISA Clear for the Serial Instrument  flushes (simply discards) the I/O output buffer,  sends a break, and then flushes the I/O input buffer... Where as in Flush I/O Buffer we can flush more than one buffer Simultaneously by ORing the masks... And i suppose u wont be compromising anything by Flush I/O... 

with regards,

Gokul


You mean it will break the initialised VISA communication by removing the Assert status with your initialised the COM ? Anyway I'm just using Tx,Rx

 

and Ground of the COM port, so it is not affecting my initialised communiocation..i.e I don't do any COM Initialise after VISA clear. But I guess it will

 

affect my communication if I do a PC-PC communication and I have to re-initialize the COM, Please correct me if I am wrong.

 





0 Kudos
Message 3 of 17
(29,699 Views)

Yes sir! you are absolutely right... I would recommend using Flush I/O buffer function if you would like to maintain the communication with the device even after flushing the buffer... 🙂 To my knowledge and observation Visa Clear was used only when the buffer needs to be cleared and the Port needs to be released from Labview,  for some other application to use the port for communication...

 

With regards,

Gokul

 

Message 4 of 17
(29,693 Views)

@goku wrote:

Yes sir! you are absolutely right... I would recommend using Flush I/O buffer function if you would like to maintain the communication with the device even after flushing the buffer... 🙂 To my knowledge and observation Visa Clear was used only when the buffer needs to be cleared and the Port needs to be released from Labview,  for some other application to use the port for communication...

 

With regards,

Gokul

 


Then how would VISA Clear and VISA Close differs ?





0 Kudos
Message 5 of 17
(29,688 Views)

VISA Clear just clears the input and output buffers of the device, but VISA Close closes the device session. VISA Clear woould not close the device session, and VISA Close would not clear the buffers.

 

Regards,

Sahil Singla

Applications Engineer

National Instruments

Regards,

Sahil Singla
Applications Engineer | National Instruments

(Give Kudos to good Answers and Mark it as a Solution if your problem is Solved)
0 Kudos
Message 6 of 17
(29,662 Views)

Hi All,

 

I just searched ni.com and found this post. I was trying to find out if a VISA Close Function followed by a VISA Configure Serial Port vi function on the same serial port flushes the VISA I/O buffer or not. Sahil says, "VISA Close would not clear the buffers" but I would think that the VISA Configure Serial Port, which opens the port, would flush the buffers.

 

Does anyone know if this is true? Also, where can I find this in NI.com documentation? I cannot find any mention of this specifically.

 

Thank you very much.

Ed

0 Kudos
Message 7 of 17
(29,599 Views)

From what I am doing right now, Visa configure port does not clear the buffer say if the device is still communicating with the computer after your program has closed without closing the communications.  I'm not sure if the communication is closed (not just stoping the program or force quiting the program) if the buffer is cleared.

 

to get rid of data once the port has been configured and the communication has started read the number of bytes at port with a property node and if not 0 then flush the buffer.  Otherwise there may be sync issues, i just found this out.

 

0 Kudos
Message 8 of 17
(28,523 Views)

Manu,

 

I have only ever needed to use the VISA Flush I/O Buffer vi, and I've only ever needed to use the default mask of 16 to clear the input buffer on the PC. That can happen on occasion if unrequested data arrives at the serial port from my external instrument. Therefore, when I start a new acquisition sequence, I simply flush the input buffer to clear it.

 

As previous posts said, the VISA Clear generates a BREAK, which is about 250 mSec long, as you observe. Generally you don't need or want that. (To repeat from the Help: VISA Clear "flushes (discards) the I/O output buffer, sends a break, and then flushes the I/O input buffer.")

 

Since your PC LabVIEW program is in control, you know when you are sending, so you shouldn't need to clear the output buffer. (However, in a complex event-driven program this may not be so clear.) What you may not have control over is when and how much data your external serial device sends. My device will only sends upon request from the PC or from a user-initiated transmission.

 

Hope this helps.

Ed

Message 9 of 17
(28,500 Views)

I would like to ask about this third party driver I plan to use. As you can see after VISA Open we have VISA Clear and then, after configuration, we have VISA Flush I/O Buffer with mask 0x40 OR 0x80 and VISA Set I/O Buffer Size with mask 0x30 (which is not mentioned in help file).

 

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

Michał Bieńkowski
CLA, CTA

Someone devote his time to help solve your problem? Appreciate it and give kudos. Problem solved? Accept as a solution so that others can find it faster in the future.
Make a contribution to the development of TestStand - vote on TestStand Idea Exchange.
0 Kudos
Message 10 of 17
(6,770 Views)