Re: A better way to Read Bytes until Done ?



"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


.



Relevant Pages

  • Re: Threading and Serial port issue
    ... I am using the Opennetcf Port class to handle the serial comms. ... I then sit in a loop waiting for data to arrive. ... private void SetupBoard_Click ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Serial Communication Problem
    ... I have no problems reading from a serial port within a sub-thread. ... the basic loop within the thread, ... > The problem is that function WaitCommEvent never return! ...
    (microsoft.public.windowsxp.embedded)
  • SSA Cabling and Adapter problem
    ... A2 -> Port 16 ... So the A loop is fine, ... The server is an S7A with two I/O drawers, ... There is a seventh adapter in the server, not connected to any disks at all, ...
    (AIX-L)
  • Re: serial port question.
    ... Note that you have left the port in non-blocking mode. ... the termios settings are for raw mode and the VTIME and VMIN ... dependent upon that configuration, and when used as an example ... necessarily must be in a loop. ...
    (comp.os.linux.hardware)
  • SUMMARY: Sun Qlogic HBA + Compaq/HP SAN Switch Issues
    ... I had failed to specify exactly which HBA card I was using. ... talk Fabric Mode (or connect on the F_Port in order for proper switch ... cannot do Fabric Mode...only Loop mode which is why this is not working. ... Bind by World Wide Port Name: ...
    (SunManagers)