[comp.os.os2] Is there a way to peek ahead and see how many bytes are in the COM buffer?

yozzo@larouch.uucp (Ralph Yozzo) (12/24/89)

Does anyone know of a way to peek ahead and see how many bytes are in 
the COM1 buffer?
The reason I ask is that I'd like to read as many bytes
as possible from the COM port and I'd rather
not ask for too much because the DosRead() will block.

------------------------------------------------------------------------------
| Ralph E. Yozzo                     |                                       |
| Arpanet: yozzo@ibm.com             |                                       |
| Bitnet: yozzo@yktvmx.bitnet        \---------------------------------------|
| Home: ..!uunet!bywater!acheron!larouch!yozzo  | Phone: (914) 945-3634 work |
|                                               | Phone: (914) 564-4731 home |
------------------------------------------------------------------------------

yozzo@larouch.UUCP (Ralph Yozzo) (12/25/89)

From article <1989Dec24.103004.26003@larouch.uucp>, by yozzo@larouch.uucp (Ralph Yozzo):
> 
> Does anyone know of a way to peek ahead and see how many bytes are in 
> the COM1 buffer?
> The reason I ask is that I'd like to read as many bytes
> as possible from the COM port and I'd rather
> not ask for too much because the DosRead() will block.
> 
To answer my own question, there is a DosDevIOCtl() call that
gives the number of characters in the receive queue.

The call is documented in the I/O Subsystems and Device Drivers Volume 1
page 7-34 Category 1- Function 68H
------------------------------------------------------------------------------
| Ralph E. Yozzo                     |                                       |
| Arpanet: yozzo@ibm.com             |                                       |
| Bitnet: yozzo@yktvmx.bitnet        \---------------------------------------|
| Home: ..!uunet!bywater!acheron!larouch!yozzo  | Phone: (914) 945-3634 work |
|                                               | Phone: (914) 564-4731 home |
------------------------------------------------------------------------------

patrick@engrhub.ucsb.edu (Patrick Lindstrom) (12/29/89)

In article <1989Dec24.103004.26003@larouch.uucp> yozzo@larouch.UUCP (Ralph Yozzo) writes:
>
>Does anyone know of a way to peek ahead and see how many bytes are in 
>the COM1 buffer?
>The reason I ask is that I'd like to read as many bytes
>as possible from the COM port and I'd rather
>not ask for too much because the DosRead() will block.
>

Ralph,
There is a Generic IOCtl call that will return to you the size of the
receive buffer and the number of characters currently queued.  I don't
have my device driver technical reference manual handy so I can't tell
you the exact number.  Look for Category 1 function calls in your
device drivers manual.

patrick@engrhub.ucsb.edu (Patrick Lindstrom) (12/29/89)

In article <1989Dec24.103004.26003@larouch.uucp> yozzo@larouch.UUCP (Ralph Yozzo) writes:
>
>Does anyone know of a way to peek ahead and see how many bytes are in 
>the COM1 buffer?
>The reason I ask is that I'd like to read as many bytes
>as possible from the COM port and I'd rather
>not ask for too much because the DosRead() will block.
>

Ralph, I have one more suggestion...  If you don't want the device driver
to block, you can user IOCtl Category 1, Function 53h to set the read
mode to no-wait.  This will tell the device driver to return with as
many characters as are in the receive queue.  If there aren't any
characters it just returns a byte count of 0.

Patrick Linstruth
patrick@wongo