Discussion:
flush buffer?????
(too old to reply)
Deiphos
2007-06-08 09:10:09 UTC
Permalink
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      


loop.jpg:
Loading Image...
Deepu
2007-06-08 09:10:13 UTC
Permalink
Hi,
Although I am unable to give you an exact answer I&nbsp;would suggest you&nbsp;to try&nbsp;<a href="http://www.microsoft.com/technet/sysinternals/utilities/portmon.mspx" target="_blank">this</a> utility to check whats happening at the COM port when you read/write each time.&nbsp;Portmon&nbsp;can probably&nbsp;help you to debug your application. Hope it helps!
Regards,
Deepu.
spaceman spif
2008-06-20 18:40:09 UTC
Permalink
Awakening an old thread here...I'm also currently trying out the "VISA flush" command to try to clear up some serial communication issues.&nbsp; I saw the suggestion to run "portmon" to monitor the serial port.&nbsp; 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.&nbsp; When it resets, for some reason I can no longer communicate with it via the serial port.&nbsp; I tried using the "VISA flush" command before attempting to reestablish communication but it didn't help.&nbsp; 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?
muks
2008-08-07 10:40:17 UTC
Permalink
Awakening an old thread here...I'm also
currently trying out the "VISA flush" command to try to clear up some
serial communication issues.&nbsp; I saw the suggestion to run "portmon" to
monitor the serial port.&nbsp; 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.&nbsp; When it resets, for some reason I can no longer communicate
with it via the serial port.&nbsp; I tried using the "VISA flush" command
before attempting to reestablish communication but it didn't help.&nbsp;
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?
There needs to be an enumeration time for your device&nbsp; between each resets and on.If you try to read&nbsp; the data inbetween them then you will&nbsp; end up with an error or&nbsp; worst a crash(Not likely).Can you&nbsp; tell us what is the device you are trying to use?
mikeporter
2007-06-10 19:10:40 UTC
Permalink
A couple points: - 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.
- 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.
- 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...
spaceman spif
2008-06-20 20:10:07 UTC
Permalink
Man...am I gonna have to offer a month of free gas as incentive on this??? :smileyhappy:
Matt W
2008-06-21 01:10:08 UTC
Permalink
You could try using NI Spy (I think it comes with the VISA driver). I've found it helpful to see what the serial port is doing.
muks
2008-08-07 10:40:17 UTC
Permalink
Man...am I gonna have to offer a month of free gas as incentive on this??? <img src="../../i/smilies/16x16_smiley-happy.gif" border="0" height="16" width="16">
Have you made up your mind on the offer pal?Message Edited by muks on 08-07-2008 05:12 AM
Continue reading on narkive:
Loading...