LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to clear the buffer after read the data

Hello all,

 

I am sending command to device through VISA write and read the value using VISA read with respect to command and again i want to send another command to device using VISA write and read the value using with repsect to the command in same port. 

 

I could not able to clear the buffer after i read the data. even i was trying VISA flush buffer and VISA clear. 

 

Please suggest me any solutions

 

Thanks in advance

Message 1 of 7
(6,277 Views)

Hi kumuch,

 

when you read your buffer fast enough you don't need to flush it in between…

 

Did you try the "Serial Read and Write" example VIs coming with LabVIEW? They work without flushing the read buffer!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 7
(6,268 Views)

No, It wont work 

 

I had used the examples already 

 

 

0 Kudos
Message 3 of 7
(6,262 Views)

Hi Kumuch,

 May be you need to check how many bytes are there at the serial port using the "bytes at port" property,based on that read the bytes instead of reading fixed number of bytes always and after  that you may need to add some delay after reading the bytes..

 

Regards,

SrikrishnaNF

Regards,
Srikrishna


0 Kudos
Message 4 of 7
(6,248 Views)

Is your instrument constantly sending data to you or only when you request the data?  If it is on request only, then your buffer should be cleared each time you do a read (assuming you told the VISA Read to grab enough data).  If your instrument is constantly sending data, then you need a second loop that does nothing but read and parse the data coming in.


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
0 Kudos
Message 5 of 7
(6,240 Views)

Hi saikrishna,

 

Yes i tried, its varies with repsct to time which is given in between VISA write and read command. even I can able to get 4092 bytes i think so this is the maximum no of bytes to transfer through data serial communication. 

0 Kudos
Message 6 of 7
(6,220 Views)

hi crossrulz,

 

You are correct my instrument is sending data continously so that data is coming even i use the flush buffer but i have another command to stop the continous measurement. i used it and working fine Thank you..

0 Kudos
Message 7 of 7
(6,217 Views)