Re: A better way to Read Bytes until Done ?
- From: "Jerome Whelan" <whelanjh@xxxxxxxxxxx>
- Date: Mon, 05 Sep 2005 22:47:45 GMT
"Broken Arrow" <x@xxxxxxxx> wrote in message
news:1125940262364-262977@xxxxxxxxxxxxxxxxxx
> My question involves reading an unknown number of bytes from the serial
> port.
I looked at your schematic in GIF form and I too have concerns:
It appears your idea is to cycle the while loop waiting for the number of
bytes at serial port to be the same on two sequential checks. Big danger
here! You have no time delay in the loop; on a modern computer it will cycle
faster (tens of thousands of loop cycles per second) than the interval
between arrived characters, thus possibly loop-exiting while the real
condition is just awaiting another character to come down the serial line.
Also, your tight while loop may be starving the overall system of the
execution time it needs to move the data between buffers, thus slowing
overall execution. I might include a time delay inside the tight loop of one
millisecond... Let's say your serial rate is 9600 bits/sec and 10 bit
chracters, the number of arrived characters can only change every 1.04
milliseconds....
By the way, don't forget that you can right-click on those VISA serial reads
and switch their characteristics between synchronous and asynchronous
operation. One might be more appropriate for your task than the other. Jerry
.
- References:
- A better way to Read Bytes until Done ?
- From: Broken Arrow
- A better way to Read Bytes until Done ?
- Prev by Date: Re: USB web cam and labview (IMAQ)
- Next by Date: Re: available fonts
- Previous by thread: Re: A better way to Read Bytes until Done ?
- Next by thread: Re: A better way to Read Bytes until Done ?
- Index(es):
Relevant Pages
|