[comp.sys.amiga] Carrier detect and signals

ncreed@ndsuvax.UUCP (Walter Reed) (11/24/87)

I need to know how to set up the serial device to generate a signal when
the carrier drops.  I am writting the serail routines for my BBS and
don't want to have to do a CheckCarrier() type of thing all over the place.
Yes, I know about the CMD_QUERY, but that's not what I want.  If I did that,
I could set up a timer_request to check the carrier once a second, but I
would rather have it tell me when the carrier drops.  At least, it would be
nice if I could have a flag like SERB_CHECKCD that would enable checking of
the carrier and return an error of SerErr_NOCD if the carrier is lost.
 
Please CBM, PLEASE release the source for the serial device, and / or add
this capability...  It would make writting an AUX: device easier, a BBS
easier...  This is such a small change, and I request that you put it into
version 1.3.  We need it.  Gee, it would be nice to detect a SIG_HUP and 
deal with it.

-- 
Walter Reed              UUCP  : uunet!ndsuvax!ncreed
                      Internet : ncreed%NDSUVAX.BITNET@WISCVM.WISC.EDU
Ph 701-235-0774         Bitnet : ncreed@ndsuvax  OR NU105451@NDSUVM1
-------------------

lyles@tybalt.caltech.edu (Lyle Scheer) (11/24/87)

In article <498@ndsuvax.UUCP> ncreed@ndsuvax.UUCP (Walter Reed) writes:
>
>I need to know how to set up the serial device to generate a signal when
>the carrier drops.  I am writting the serail routines for my BBS and
>don't want to have to do a CheckCarrier() type of thing all over the place.
>Yes, I know about the CMD_QUERY, but that's not what I want.  If I did that,
>I could set up a timer_request to check the carrier once a second, but I
>would rather have it tell me when the carrier drops.  At least, it would be
>nice if I could have a flag like SERB_CHECKCD that would enable checking of
>the carrier and return an error of SerErr_NOCD if the carrier is lost.
> 
>Please CBM, PLEASE release the source for the serial device, and / or add
>this capability...  It would make writting an AUX: device easier, a BBS
>easier...  This is such a small change, and I request that you put it into
>version 1.3.  We need it.  Gee, it would be nice to detect a SIG_HUP and 
>deal with it.
>
That's odd.  I've had a BBS program written for the Amiga since about a year
and a half ago.  The way I do it is, after I output a line of text to the
serial port and CON: device in my window, I check for CD with CmdQuery.  It
doesn't slow it down much.  I also check during my input routine, with no real
loss of input speed.  In fact, I'm quite impressed with how well the Amiga
does with this sort of thing.  I now have my BBS program doing mostly
wait(), so its ready for me to start figuring out how to make it
re-entrant, so that I can multitask more than one serial port(ASDG or someone,
I NEED MORE SERIAL PORTS!)


					Wonko the Sane
				      (you call this SANE??)

Disclaimer: I am totally irresponsible.  So shoot me then.

dillon@CORY.BERKELEY.EDU.UUCP (11/25/87)

>I need to know how to set up the serial device to generate a signal when
>the carrier drops.  I am writting the serail routines for my BBS and
>don't want to have to do a CheckCarrier() type of thing all over the place.
>Yes, I know about the SDCMD_QUERY, but that's not what I want.  If I did that,
>I could set up a timer_request to check the carrier once a second, but I
>would rather have it tell me when the carrier drops.  At least, it would be
>nice if I could have a flag like SERB_CHECKCD that would enable checking of
>the carrier and return an error of SerErr_NOCD if the carrier is lost.

	I just do this before sending a CMD_READ... since you want to do
a SDCMD_QUERY anyway to get the number of bytes in the read buffer (You NEVER
read one character at a time if you can help it).  You need some sort of
timeout on the CMD_READ anyway or your BBS can hang even with an active
carrier (e.g. xmodem transfer dies, user doesn't do anything for 10 minutes..)

	I agree, there should be a way for the serial.device to signal you.
Still, most modems send a 'NO CARRIER' message when the carrier drops and you
would catch it then.  But if you *still* want to do this, you would have to
create a separate task which periodically sends SDCMD_QUERY requests to the
serial.device and sets some global variable.  But I say you can do it within
your read/write routines just as easily.

SPEED CONSIDERATIONS:
	As long as you read as many chars that are available (in one CMD_READ),
and write as many chars as you can (in one CMD_WRITE), you can easily do a 
SDCMD_QUERY in between without slowing the program down.  Remember that 
syncronous IO calls such as SDCMD_QUERY are extremely fast.

	Additionaly, it should be noted that by using asyncronous CMD_WRITE's
a SDCMD_QUERY done after the CMD_WRITE is issued (using a different iorequest
of course) would be completely absorbed by the write-time.
    
				-Matt