Generally speaking, it is not reccomended to read single bytes in a loop
structure, as the subroutine suggests.  I'm pretty sure I got this
notion from either the "Linux Serial How-To" or the "Linux Serial
Programming How-To", both of which were great aids to me in starting
out, and continue to be valuable reference points.  Both are available
at http://howto.tucows.com/.  

I think the OS does something pretty much like what is described in your
subroutine, but it does it automatically and keeps the bytes available
until you read them.  It seems silly to duplicate or bypass this with
code of your own.

If the data from your device is available in fixed length "packets", you
may want to consider opening the port cannonically (see references
above).  I use this approach to read data from a voltmeter that is set
up to broadcast values (always 6 bytes) on a periodic basis.

Tom

Sangohn Christian wrote:
> 
> Hi!
> 
> I´m making my first steps in writing software for serial devices.
> There are some steps described in the documentation of the device I´m
> programming for and I dont know how to implement them.
> Her is the excerpt from the documentation:
> 
> -----------------------------------------------------------------
> C.  Steps in Subroutine Beta:  Feed in Data Details
> -----------------------------------------------------------------
> Step  1  Begin.
> Step  2  Confirm Relative mode.
>          If yes, counter is loaded with 3.
>          If no, counter is loaded with 5.
> Step  3  Confirm Remote Request mode.
>          If yes, the Trigger command is sent and proceed Step 4.
>          If no, on with Step 4.
> Step  4  Status register is checked.
> Step  5  Confirm if byte is available.
>          If yes, go on to Step 6.
>          If no, return to Step 4.
> Step  6  Byte is read from communication port.
> Step  7  Byte is stored.
> Step  8  Counter is decremented.
> Step  9  Confirm that counter equals 0.
>          If yes, go on to Step 10.
>          If no, return to Step 4 and proceed again.
> Step 10  Return.
> 
> My question is how do I achieve steps 4 and 5?
> 
> Additionally, I´d be thankful if someone could point me to useful
> documentation for such questions, so I don´t have to border you
> again with that ;-)
> 
> TIA
> 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-serial" in
> the body of a message to [EMAIL PROTECTED]

-
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to [EMAIL PROTECTED]

Reply via email to