LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

flush buffer?????

Hi!
 
I'm using a device that send a data each second, but I only want to check it about each half an hour, so I had the problem that I should flush the buffer to receive acualliced data and not old ones. And this is the problem. I have tried everything (I think) to clear the buffer: VISA Clear and VISA Flush I/O buffer didn't work at all, and finally I have tried something I red on this forum. Sorry, I haven't been able to find it again but more or less it was something like this:(see attached file).Basically, it consists on read all data stored on the buffer since it is empty. Then, I use a bit more than a second to re-fill buffer with a new data, and then I read and store this new data on a file (This last part is not displayed on the picture). The problem is that when I open the file containing data, I find that there is not only one data on it, there are the last 8 or 9 ones. I have also tried to do it without the waiting time but it does the same, what, I think, demonstrates that buffer isn't been flushed.
 
Any idea?
 
Thanks for all      
0 Kudos
Message 1 of 15
(9,479 Views)

Hi,

Although I am unable to give you an exact answer I would suggest you to try this utility to check whats happening at the COM port when you read/write each time. Portmon can probably help you to debug your application. Hope it helps!

Regards,

Deepu.

0 Kudos
Message 2 of 15
(9,470 Views)
I have tried the program. When data is received, it is about 100 or more bytes (That is, several data are received), so it seems to clear them. But what i don't understand is why once the buffer is cleared I still receive several datas when I read the port, instead without the 1200ms delay.
0 Kudos
Message 3 of 15
(9,458 Views)

Did you try reading the buffer one time immediately after clearing it ? May be this will ensure if the buffer actually cleared or not. You may also monitor the Rx line using a scope to ensure the data is sent with the specified interval only.

0 Kudos
Message 4 of 15
(9,433 Views)
A couple points:
  1. Checking the number of bytes in the serial buffer and reading them all will remove from the buffer all the data that was there when the byte count was performed.
  2. You are waiting 1.2 seconds before checking to see whether the buffer is still empty. At 19.2kbps this is an awful lot of time. Assuming a 10-bit character (1 start bit, 8 data bits and 1 stop bit) that is time enough to receive 2,304 characters - each character only takes about a half a millisecond.
  3. If the device is, as I suspect, streaming data, the 1.2 second delay is resulting in the serial buffer being partially overwritten between reads since you aren't setting a buffer size and I believe that the default is only 1024 characters.
Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 5 of 15
(9,413 Views)

But the device isn't sending in continious, It is sending a data each second, so waiting 1.2 seconds only one data should be received.

In ither hand, on the loop, if some data is received when data stored is been readed the loop will execute again till there will be no data to read.

And on third place, yes, if I delete the 1.2 seconds delay it stills happends the same   

0 Kudos
Message 6 of 15
(9,361 Views)

Hi

Why don't you post your VI here so that we can look at it and see if there anything else that could be going wrong. Meanwhile, could you try to see what happens if you remove the RS232 cable from PC after some reads ?

Regards

0 Kudos
Message 7 of 15
(9,347 Views)
On my computer, data received after buffer clear are about 8 or 9, it deppends. I have tried same program on a collegue's computer and it only receives 2 data after clear, so it makes me think that LabView maybe won't be the problem. Both computers are running Windows XP by mine is much fster than hims....
0 Kudos
Message 8 of 15
(9,339 Views)
Awakening an old thread here...I'm also currently trying out the "VISA flush" command to try to clear up some serial communication issues.  I saw the suggestion to run "portmon" to monitor the serial port.  Can you run that program at the same time LV is running?

Now and then the device I'm communicating with will lose power, and then reset.  When it resets, for some reason I can no longer communicate with it via the serial port.  I tried using the "VISA flush" command before attempting to reestablish communication but it didn't help.  However I don't really know how to tell what's really going on in the serial buffer to see if I'm using the flush command correctly or not.

Any suggestions?
********************************************
Amateur programmer for over 10 years!
********************************************
0 Kudos
Message 9 of 15
(8,845 Views)
Man...am I gonna have to offer a month of free gas as incentive on this??? Smiley Happy
********************************************
Amateur programmer for over 10 years!
********************************************
0 Kudos
Message 10 of 15
(8,832 Views)