[comp.sys.amiga.tech] Carrier Detect

erekose@apple.com (Erik Scheelke) (10/03/90)

Just a quick question that has me puzzled.  How can I read the state of
a modem's carrier detect?  The serial device appears to lack this
ability.  Thanks in advance.

Erik Scheelke

bj@cbmvax.commodore.com (Brian Jackson) (10/04/90)

In article <45340@apple.Apple.COM> erekose@apple.com (Erik Scheelke) writes:
>Just a quick question that has me puzzled.  How can I read the state of
>a modem's carrier detect?  The serial device appears to lack this
>ability.  Thanks in advance.

/*-------------------------------------------------
 * QUERY.C   This is Manx!
 *
 *  returns status of serial port registers
 *                                               
 *  See page B-75 RKM2.
 *                                               
 *  if (  status & 0x20 )   CARRIER = FALSE
 *  if (!(status & 0x20))   CARRIER = TRUE
 *-------------------------------------------------
 */

 #include <functions.h>
 #include <libraries/dos.h>
 #include <devices/serial.h>
 #include <exec/memory.h>
 #include <stdio.h>

 GLOBAL struct MsgPort  *CreatePort() ;

main()
{
   UWORD    status ;
   struct   IOExtSer   *Q_Req = NULL ;

   Q_Req = (struct IOExtSer *)AllocMem( ((LONG)sizeof(*Q_Req)),
   if( Q_Req ) {
      Q_Req->io_SerFlags = SERF_SHARED | SERF_XDISABLED ;
      Q_Req->IOSer.io_Message.mn_ReplyPort = CreatePort( 0L, 0L ) ;
      if ( Q_Req->IOSer.io_Message.mn_ReplyPort )  {
         if ( OpenDevice( SERIALNAME, NULL , Q_Req , NULL )== 0 ){
            Q_Req->IOSer.io_Command = SDCMD_QUERY ;
            DoIO( Q_Req ) ;
            status = Q_Req->io_Status ;
            printf("\nQuery value is : %d\n", status ) ;
            printf("Carrier = %s\n",status & 0x20 ?"FALSE":"TRUE") ;
            CloseDevice( Q_req ) ;
         }
         DeletePort(Q_Req->IOSer.io_Message.mn_ReplyPor ) ;
      }  
      FreeMem(Q_Req, ((LONG)sizeof(*Q_Req))) ;
   return( status ) ;
}

>Erik Scheelke

bj

 ------------------------------------------------------------------------ 
 | Brian Jackson  Software Engineer @ Commodore-Amiga Inc.   GEnie: B.J. |
 | bj@cbmvax.commodore.com    or  ...{uunet|rutgers}!cbmvax!bj           |
 | "Networking?  You mean, like tennis?"                                 |
 ------------------------------------------------------------------------