Subject: Re: Determine if Floppy is in drive?
To: James K. Lowden <jklowden@schemamania.org>
From: None <collver1@attbi.com>
List: netbsd-help
Date: 01/30/2003 03:27:43
On Thu, Jan 30, 2003 at 02:08:22AM -0500, James K. Lowden wrote:
> It's part of my unix puzzlement, you might say.  How do I know:
> 
> 1. the printer's online?
> 2. the modem has DSR raised?
> 3. the CD is ready?  
> 
> I guess this is part of NetBSD's legacy, the assumption that the machine
> is at the other end of some tangle of RS-232, and that if [device] is not
> ready, sooner or later an operator will ready it.  I guess.  

NetBSD has POSIX tty support.
To test for DSR, just use the TIOCMGET ioctl.
From tty(4):

TIOCMSET int *state
            The integer pointed to by state contains bits that correspond
            to modem state.  Following is a list of defined variables and
            the modem state they represent:

            TIOCM_LE   Line Enable.
            TIOCM_DTR  Data Terminal Ready.
            TIOCM_RTS  Request To Send.
            TIOCM_ST   Secondary Transmit.
            TIOCM_SR   Secondary Receive.
            TIOCM_CTS  Clear To Send.
            TIOCM_CAR  Carrier Detect.
            TIOCM_CD   Carrier Detect (synonym).
            TIOCM_RNG  Ring Indication.
            TIOCM_RI   Ring Indication (synonym).
            TIOCM_DSR  Data Set Ready.

            This call sets the terminal modem state to that represented
            by state.  Not all terminals may support this.

TIOCMGET int *state
            Return the current state of the terminal modem lines as rep-
            resented above in the integer pointed to by state.

Cheers,

Ben