[comp.sys.amiga.tech] A couple of AmigaDOS questions...

tw0i+@andrew.cmu.edu (Todd Andrew Williamson) (01/17/90)

To all of you DOS gurus:

1)  Is there a way to do non-blocking reads from an AmigaDOS 
    FileHandle?

2)  Is there a way to get a signal when I/O is available on
    a FileHandle?

The reason that I ask is this:  I'm writing a program that
needs to be able to do I/O on the serial & parallel ports
as well as on AmigaDOS FileHandles.  But it needs to be able
to go about it's business until there is something to be read.

I guess what I'm looking for is something along the lines of 
the UNIX select() call.

As you may have guessed, I don't have the DOS manual.  (I was 
hoping that the 1.3 version would come out soon, but it turns
out I need these answers sooner.)

Thanks,

Todd Williamson
tw0i@andrew.cmu.edu
r746tw0i@cmccvb.BITNET

ccplumb@lion.waterloo.edu (Colin Plumb) (02/08/90)

In article <sZh927G00WB_01qmID@andrew.cmu.edu> tw0i+@andrew.cmu.edu (Todd Andrew Williamson) writes:
>1)  Is there a way to do non-blocking reads from an AmigaDOS 
>    FileHandle?

Yes.  All the DOS functions do is send a packet to the apropriate
handler and wait for it to return.  If you dive into the grungy
bits yourself, use DeviceProc() to find the address of the
handler and fill in packets, in all their BPTR-laden glory
yourself, you can wait for them to come back to any message
port you like.  I believe some code to do this is in Matt
Dillon's suplib.  CMU has FTP, so have a look on ucbvax.berkeley.edu
pub/dillon/...

>2)  Is there a way to get a signal when I/O is available on
>    a FileHandle?

Well, an asynchronous read of one byte will work well.  I can't
think of a way, other than character-by-character, to get
"whatever's currently available;" maybe someone else who's read
the manual in the last moth has an idea?
-- 
	-Colin

new@udel.edu (Darren New) (02/08/90)

In article <20642@watdragon.waterloo.edu> ccplumb@lion.waterloo.edu (Colin Plumb) writes:
>>1)  Is there a way to do non-blocking reads from an AmigaDOS 
>>    FileHandle?
>Yes.  All the DOS functions do is send a packet to the apropriate
>handler and wait for it to return. 

But can you abort the I/O once your other stuff has come back?  I.e., if
I want to time out on a read of CON:, I can get my process to come back when
the timer.device message comes back, but since DOS is not a device I
can't AbortIO on the packet, can I?    -- Darren

ccplumb@lion.waterloo.edu (Colin Plumb) (02/13/90)

In article <10541@nigel.udel.EDU> new@udel.edu (Darren New) writes:
> But can you abort the I/O once your other stuff has come back?  I.e., if
> I want to time out on a read of CON:, I can get my process to come back when
> the timer.device message comes back, but since DOS is not a device I
> can't AbortIO on the packet, can I?    -- Darren

Sorry, no.  An AbortPkt() function *might* exist in 1.4, but it's dubious.
To do something like you describe, you have to use the underlying
console.device.  There's a way, described in AmigaMail and other
places, to get the console.device behind a CON: window and you can
do AbortIO() to it.  Currently, all DOS handlers that can block arbitrarily
long (CON:, SER:, PAR:, AUX:) are layered over Exec .devices, except for
The various flavours of PIPE:.  I don't know if there's a hack in PIPE:
to allow for timeouts.
-- 
	-Colin

walker@sas.UUCP (Doug Walker) (02/13/90)

In article <sZh927G00WB_01qmID@andrew.cmu.edu> tw0i+@andrew.cmu.edu (Todd Andrew Williamson) writes:
>1)  Is there a way to do non-blocking reads from an AmigaDOS 
>    FileHandle?
Use the DOS Packet interface.  Get a copy of PickPacket, by John Toebes and
myself, and some back issues of Transactor for the Amiga - last April-June, I
think - where we discuss the packet interface.


>2)  Is there a way to get a signal when I/O is available on
>    a FileHandle?

Sure, just post a packet read of some large number of bytes.  It will return
when input is available with fewer bytes than you requested, but your MsgPort
will signal you when it returns.  Keep in mind, though, that if it's a console
stream, CON: buffers its input until it sees a \n;  you'll need to put it in
RAW mode to get characters as they're typed.


  *****
=*|_o_o|\\=====Doug Walker, Software Distiller=======================
 *|. o.| ||
  | o  |//     "I try to make everyone's day a little more surreal."
  ======                 - Calvin
usenet: ...mcnc!rti!sas!walker   plink: dwalker  bix: djwalker