home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sd386v50.zip / sd386src.zip / COMDMP.C < prev    next >
Text File  |  1994-06-03  |  34KB  |  796 lines

  1. #define INCL_DOSSESMGR
  2. #define INCL_DOSFILEMGR
  3. #define INCL_DOSDEVICES
  4. #include <os2.h>
  5. #include <bsedev.h>
  6. #include <string.h>
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9.  
  10.  FILE      *comdmp = NULL;
  11.  
  12. int comdump( ULONG );
  13. int comdump( ULONG ComHandle )
  14. {
  15.  APIRET     rc;
  16.  
  17.  if( comdmp == NULL )
  18.   comdmp = fopen("com.dmp","w");
  19.  else
  20.   comdmp = fopen("com.dmp","a");
  21.  fprintf(comdmp,"\n=======================");
  22.  fprintf(comdmp,"\n===next dump ==========");
  23.  fprintf(comdmp,"\n=======================");
  24.  /****************************************************************************/
  25.  /* Query the current bit rate.                                              */
  26.  /****************************************************************************/
  27.  {
  28.   USHORT BitRate;
  29.   ULONG  BitRateLenInOut = sizeof(BitRate);
  30.  
  31.   rc = (USHORT)DosDevIOCtl ( ComHandle,
  32.                              IOCTL_ASYNC,
  33.                              ASYNC_GETBAUDRATE,
  34.                              NULL,
  35.                              0,
  36.                              NULL,
  37.                              &BitRate,
  38.                              BitRateLenInOut,
  39.                              &BitRateLenInOut );
  40.   if(rc){fprintf(comdmp,"ioctl error");fflush(0);exit(0);}
  41.   fprintf(comdmp,"\nBit Rate  = %d",BitRate);
  42.  }
  43. /*****************************************************************************/
  44. /* Query the line characteristics.                                           */
  45. /*****************************************************************************/
  46. {
  47.  {
  48.   struct
  49.   {
  50.    UCHAR DataBits;
  51.    UCHAR Parity;
  52.    UCHAR StopBits;
  53.    UCHAR XmitBreak;
  54.   }LineCtrl;
  55.  
  56.   ULONG  LineCtrlInOut = sizeof(LineCtrl);
  57.   memset(&LineCtrl,0,LineCtrlInOut);
  58.  
  59.   rc = (USHORT)DosDevIOCtl ( ComHandle,
  60.                              IOCTL_ASYNC,
  61.                              ASYNC_GETLINECTRL,
  62.                              NULL,
  63.                              0,
  64.                              NULL,
  65.                              &LineCtrl,
  66.                              LineCtrlInOut,
  67.                              &LineCtrlInOut );
  68.  
  69.   if(rc){fprintf(comdmp,"ioctl error");fflush(0);exit(0);}
  70.   fprintf(comdmp,"\n\n=====Line Characteristics=====\n");
  71.   fprintf(comdmp,"\nData Bits = %d",LineCtrl.DataBits);
  72.   {
  73.    char *Parity[6]={ "None",
  74.                      "Odd",
  75.                      "Even",
  76.                      "Mark",
  77.                      "Space",
  78.                      "Res" };
  79.    if( LineCtrl.Parity > 4 ) LineCtrl.Parity = 5;
  80.    fprintf(comdmp,"\nParity    = %s",Parity[LineCtrl.Parity]);
  81.   }
  82.   {
  83.    char *StopBits[4]={ "1",
  84.                        "1.5",
  85.                        "2" };
  86.    if( LineCtrl.StopBits > 3 ) LineCtrl.StopBits = 3;
  87.  
  88.    fprintf(comdmp,"\nStopBits  = %s",StopBits[LineCtrl.StopBits]);
  89.   }
  90.   {
  91.    char *TxBrk[2] = { "Not Transmitting a break",
  92.                       "Transmitting a break" };
  93.  
  94.    fprintf(comdmp,"\nXmitBreak = %s",TxBrk[LineCtrl.XmitBreak]);
  95.   }
  96.  }
  97. }
  98.  
  99. /*****************************************************************************/
  100. /* Query the extended bit rate.                                              */
  101. /*****************************************************************************/
  102. {
  103.  {
  104.   struct
  105.   {
  106.    ULONG BitRate;
  107.    UCHAR BitRateFraction;
  108.    ULONG MinBitRate;
  109.    UCHAR MinBitRateFraction;
  110.    ULONG MaxBitRate;
  111.    UCHAR MaxBitRateFraction;
  112.   }ExtendedBitRate;
  113.  
  114.   ULONG  ExtendedBitRateLenInOut = sizeof(ExtendedBitRate);
  115.  
  116.   memset(&ExtendedBitRate,0,ExtendedBitRateLenInOut);
  117.  
  118.   rc = (USHORT)DosDevIOCtl ( ComHandle,
  119.                              IOCTL_ASYNC,
  120.                              0x63,
  121.                              NULL,
  122.                              0,
  123.                              NULL,
  124.                              &ExtendedBitRate,
  125.                              ExtendedBitRateLenInOut,
  126.                              &ExtendedBitRateLenInOut);
  127.  
  128.   if(rc){fprintf(comdmp,"ioctl error");fflush(0);exit(0);}
  129.   fprintf(comdmp,"\n\n=====Extended Bit Rate =======\n");
  130.   fprintf(comdmp,"\nExtended BitRate              =%d",ExtendedBitRate.BitRate);
  131.   fprintf(comdmp,"\nExtended BitRate Fraction     =%d",ExtendedBitRate.BitRateFraction);
  132.   fprintf(comdmp,"\nExtended Min BitRate          =%d",ExtendedBitRate.MinBitRate);
  133.   fprintf(comdmp,"\nExtended Min BitRate Fraction =%d",ExtendedBitRate.MinBitRateFraction);
  134.   fprintf(comdmp,"\nExtended Max BitRate          =%d",ExtendedBitRate.MaxBitRate);
  135.   fprintf(comdmp,"\nExtended Max BitRate Fraction =%d",ExtendedBitRate.MaxBitRateFraction);
  136.  }
  137. }
  138.  /****************************************************************************/
  139.  /* Query the COM status.                                                    */
  140.  /****************************************************************************/
  141.  {
  142.   struct
  143.   {
  144.    UINT TxWaitCTS_On   :1;  /* Tx waiting for CTS to be turned on.           */
  145.    UINT TxWaitDSR_On   :1;  /* Tx waiting for DSR to be turned on.           */
  146.    UINT TxWaitDCD_On   :1;  /* Tx waiting for DCD to be turned on.           */
  147.    UINT TxWaitXOFF_Rcv :1;  /* Tx waiting because XOFF received.             */
  148.    UINT TxWaitXOFF_Xmit:1;  /* Tx waiting because XOFF transmitted.          */
  149.    UINT TxWaitBRK_Xmit :1;  /* Tx waiting because break is being transmitted.*/
  150.    UINT TxWaitXmitImmed:1;  /* Character waiting to transmit immediately.    */
  151.    UINT RxWaitDSR_On   :1;  /* Rx waiting for DSR to be turned on.           */
  152.   }ComStatus;
  153.  
  154.   char *ComInfo[8] = { "\nTx waiting for CTS to be turned on"            ,
  155.                        "\nTx waiting for DSR to be turned on"            ,
  156.                        "\nTx waiting for DCD to be turned on"            ,
  157.                        "\nTx waiting because XOFF received"              ,
  158.                        "\nTx waiting because XOFF transmitted"           ,
  159.                        "\nTx waiting because break is being transmitted" ,
  160.                        "\nCharacter waiting to transmit immediately"     ,
  161.                        "\nRx waiting for DSR to be turned on"
  162.                      };
  163.  
  164.   ULONG  ComStatusInOut = sizeof(ComStatus);
  165.  
  166.   memset(&ComStatus,0,sizeof(ComStatus));
  167.  
  168.   rc = (USHORT)DosDevIOCtl ( ComHandle,
  169.                              IOCTL_ASYNC,
  170.                              ASYNC_GETCOMMSTATUS,
  171.                              NULL,
  172.                              0,
  173.                              NULL,
  174.                              &ComStatus,
  175.                              ComStatusInOut,
  176.                              &ComStatusInOut);
  177.  
  178.   if(rc){fprintf(comdmp,"ioctl error");fflush(0);exit(0);}
  179.   fprintf(comdmp,"\n\n=====Com Status ==============\n");
  180.   if(ComStatus.TxWaitCTS_On)    fprintf(comdmp,ComInfo[0]);
  181.   if(ComStatus.TxWaitDSR_On)    fprintf(comdmp,ComInfo[1]);
  182.   if(ComStatus.TxWaitDCD_On)    fprintf(comdmp,ComInfo[2]);
  183.   if(ComStatus.TxWaitXOFF_Rcv)  fprintf(comdmp,ComInfo[3]);
  184.   if(ComStatus.TxWaitXOFF_Xmit) fprintf(comdmp,ComInfo[4]);
  185.   if(ComStatus.TxWaitBRK_Xmit)  fprintf(comdmp,ComInfo[5]);
  186.   if(ComStatus.TxWaitXmitImmed) fprintf(comdmp,ComInfo[6]);
  187.   if(ComStatus.RxWaitDSR_On)    fprintf(comdmp,ComInfo[7]);
  188.  }
  189.  /****************************************************************************/
  190.  /* Query the transmit data status.                                          */
  191.  /****************************************************************************/
  192.  {
  193.   struct
  194.   {
  195.    UINT TxWrite        :1;  /* Write request packets in progress/queued.     */
  196.    UINT TxData         :1;  /* Data in physical device driver xmit queue.    */
  197.    UINT TxTransmitting :1;  /* Currently transmitting data.                  */
  198.    UINT TxWaitXmitImmed:1;  /* Character waiting to transmit immediately.    */
  199.    UINT TxWaitXON      :1;  /* Waiting to transmit an XON.                   */
  200.    UINT TxWaitXOFF     :1;  /* Waiting to transmit an XOFF.                  */
  201.    UINT undef1         :1;  /*                                               */
  202.    UINT undef2         :1;  /*                                               */
  203.   }TxStatus;
  204.  
  205.   char *Tx[6] = { "\nWrite request packets in progress/queued"    ,
  206.                   "\nData in physical device driver xmit queue"   ,
  207.                   "\nCurrently transmitting data"                 ,
  208.                   "\nCharacter waiting to transmit immediately"   ,
  209.                   "\nWaiting to transmit an XON"                  ,
  210.                   "\nWaiting to transmit an XOFF"
  211.                 };
  212.  
  213.   ULONG  TxStatusInOut = sizeof(TxStatus);
  214.  
  215.   memset(&TxStatus,0,sizeof(TxStatus));
  216.  
  217.   rc = (USHORT)DosDevIOCtl ( ComHandle,
  218.                              IOCTL_ASYNC,
  219.                              ASYNC_GETLINESTATUS,
  220.                              NULL,
  221.                              0,
  222.                              NULL,
  223.                              &TxStatus,
  224.                              TxStatusInOut,
  225.                              &TxStatusInOut);
  226.  
  227.   if(rc){fprintf(comdmp,"ioctl error");fflush(0);exit(0);}
  228.   fprintf(comdmp,"\n\n=====Transmit Status==========\n");
  229.   if(TxStatus.TxWrite)         fprintf(comdmp,Tx[0]);
  230.   if(TxStatus.TxData )         fprintf(comdmp,Tx[1]);
  231.   if(TxStatus.TxTransmitting)  fprintf(comdmp,Tx[2]);
  232.   if(TxStatus.TxWaitXmitImmed) fprintf(comdmp,Tx[3]);
  233.   if(TxStatus.TxWaitXON)       fprintf(comdmp,Tx[4]);
  234.   if(TxStatus.TxWaitXOFF)      fprintf(comdmp,Tx[5]);
  235.  }
  236.  /****************************************************************************/
  237.  /* Query the modem control output signals.                                  */
  238.  /****************************************************************************/
  239.  {
  240.   struct
  241.   {
  242.    UINT DTR            :1;  /* Data Terminal Ready.                          */
  243.    UINT RTS            :1;  /* Request To Send.                              */
  244.    UINT Res            :6;  /* Reserved.                                     */
  245.   }ModemCtrl;
  246.  
  247.   ULONG  ModemCtrlLenInOut = sizeof(ModemCtrl);
  248.   memset(&ModemCtrl,0,sizeof(ModemCtrl));
  249.  
  250.   rc = (USHORT)DosDevIOCtl ( ComHandle,
  251.                              IOCTL_ASYNC,
  252.                              ASYNC_GETMODEMOUTPUT,
  253.                              NULL,
  254.                              0,
  255.                              NULL,
  256.                              &ModemCtrl,
  257.                              ModemCtrlLenInOut,
  258.                              &ModemCtrlLenInOut);
  259.  
  260.   if(rc){fprintf(comdmp,"ioctl error");fflush(0);exit(0);}
  261.   fprintf(comdmp,"\n\n=====Modem Control Output ====\n");
  262.   fprintf(comdmp,"\nDTR %s",(ModemCtrl.DTR)?"ON":"OFF");
  263.   fprintf(comdmp,"\nRTS %s",(ModemCtrl.RTS)?"ON":"OFF");
  264.  }
  265.  /****************************************************************************/
  266.  /* Query the modem control output signals.                                  */
  267.  /****************************************************************************/
  268.  {
  269.   struct
  270.   {
  271.    UINT Res            :4;  /* Reserved.                                     */
  272.    UINT CTS            :1;  /* Clear to Send.                                */
  273.    UINT DSR            :1;  /* Data Set Ready.                               */
  274.    UINT RI             :1;  /* Ring Indicator.                               */
  275.    UINT DCD            :1;  /* Data Carrier Detect.                          */
  276.   }ModemCtrlInput;
  277.  
  278.   ULONG  ModemCtrlInputLenInOut = sizeof(ModemCtrlInput);
  279.   memset(&ModemCtrlInput,0,sizeof(ModemCtrlInput));
  280.  
  281.   rc = (USHORT)DosDevIOCtl ( ComHandle,
  282.                              IOCTL_ASYNC,
  283.                              ASYNC_GETMODEMINPUT,
  284.                              NULL,
  285.                              0,
  286.                              NULL,
  287.                              &ModemCtrlInput,
  288.                              ModemCtrlInputLenInOut,
  289.                              &ModemCtrlInputLenInOut);
  290.  
  291.   if(rc){fprintf(comdmp,"ioctl error");fflush(0);exit(0);}
  292.   fprintf(comdmp,"\n\n=====Modem Control Input =====\n");
  293.   fprintf(comdmp,"\nCTS %s",(ModemCtrlInput.CTS)?"ON":"OFF");
  294.   fprintf(comdmp,"\nDSR %s",(ModemCtrlInput.DSR)?"ON":"OFF");
  295.   fprintf(comdmp,"\nRI  %s",(ModemCtrlInput.RI )?"ON":"OFF");
  296.   fprintf(comdmp,"\nDCD %s",(ModemCtrlInput.DCD)?"ON":"OFF");
  297.  }
  298.  /****************************************************************************/
  299.  /* Query size of Rx queue.                                                  */
  300.  /****************************************************************************/
  301.  {
  302.   struct
  303.   {
  304.    USHORT  CharsQueued;
  305.    USHORT  RxBufSize;
  306.   }RxQueue;
  307.  
  308.   ULONG  RxQueueLenInOut = sizeof(RxQueue);
  309.  
  310.   rc = (USHORT)DosDevIOCtl ( ComHandle,
  311.                              IOCTL_ASYNC,
  312.                              ASYNC_GETINQUECOUNT,
  313.                              NULL,
  314.                              0,
  315.                              NULL,
  316.                              &RxQueue,
  317.                              RxQueueLenInOut,
  318.                              &RxQueueLenInOut );
  319.   if(rc){fprintf(comdmp,"ioctl error");fflush(0);exit(0);}
  320.   fprintf(comdmp,"\n\n=====Receive Queue ===========\n");
  321.   fprintf(comdmp,"\nChars in Receive Queue %hd",RxQueue.CharsQueued);
  322.   fprintf(comdmp,"\nReceive Queue Size     %hd",RxQueue.RxBufSize);
  323.  }
  324.  /****************************************************************************/
  325.  /* Query size of Tx queue.                                                  */
  326.  /****************************************************************************/
  327.  {
  328.   struct
  329.   {
  330.    USHORT  CharsQueued;
  331.    USHORT  TxBufSize;
  332.   }TxQueue;
  333.  
  334.   ULONG  TxQueueLenInOut = sizeof(TxQueue);
  335.  
  336.   rc = (USHORT)DosDevIOCtl ( ComHandle,
  337.                              IOCTL_ASYNC,
  338.                              ASYNC_GETOUTQUECOUNT,
  339.                              NULL,
  340.                              0,
  341.                              NULL,
  342.                              &TxQueue,
  343.                              TxQueueLenInOut,
  344.                              &TxQueueLenInOut );
  345.   if(rc){fprintf(comdmp,"ioctl error");fflush(0);exit(0);}
  346.   fprintf(comdmp,"\n\n=====Transmit Queue ===========\n");
  347.   fprintf(comdmp,"\nChars in Transmit Queue %hd",TxQueue.CharsQueued);
  348.   fprintf(comdmp,"\nTransmit Queue Size     %hd",TxQueue.TxBufSize);
  349.  }
  350.  /****************************************************************************/
  351.  /* Query com error.                                                         */
  352.  /****************************************************************************/
  353.  {
  354.   struct
  355.   {
  356.    UINT RxQueueOverrun :1;  /* Receive Queue overrun.                        */
  357.    UINT RxHdweOverrun  :1;  /* Receive hardware overrun.                     */
  358.    UINT HdweParityError:1;  /* The hardware detected a parity error.         */
  359.    UINT HdweFrameError :1;  /* The hardware detected a framing error.        */
  360.    UINT Undef          :12; /* Undefined.                                    */
  361.   }ComError;
  362.  
  363.   char *ComErrorMsg[5] = { "\nReceive Queue Overrun."             ,
  364.                            "\nReceive Hardware Overrun."          ,
  365.                            "\nHardware detected a parity error."  ,
  366.                            "\nHardware detected a framing error." ,
  367.                            "\nUndefined error."
  368.                           };
  369.  
  370.   ULONG  ComErrorInOut = sizeof(ComError);
  371.  
  372.   memset(&ComError,0,sizeof(ComError));
  373.  
  374.   rc = (USHORT)DosDevIOCtl ( ComHandle,
  375.                              IOCTL_ASYNC,
  376.                              ASYNC_GETCOMMERROR,
  377.                              NULL,
  378.                              0,
  379.                              NULL,
  380.                              &ComError,
  381.                              ComErrorInOut,
  382.                              &ComErrorInOut);
  383.  
  384.   if(rc){fprintf(comdmp,"ioctl error");fflush(0);exit(0);}
  385.   fprintf(comdmp,"\n\n=====Com error ===============\n");
  386.   if(ComError.RxQueueOverrun)  fprintf(comdmp,ComErrorMsg[0]);
  387.   if(ComError.RxHdweOverrun)   fprintf(comdmp,ComErrorMsg[1]);
  388.   if(ComError.HdweParityError) fprintf(comdmp,ComErrorMsg[2]);
  389.   if(ComError.HdweFrameError)  fprintf(comdmp,ComErrorMsg[3]);
  390.   if(ComError.Undef)           fprintf(comdmp,ComErrorMsg[4]);
  391.  }
  392.  /****************************************************************************/
  393.  /* Query com event.                                                         */
  394.  /****************************************************************************/
  395.  {
  396.   struct
  397.   {
  398.    UINT RxQueueToHdwe  :1;  /* Character transfered from hdwe to Rx queue.   */
  399.    UINT RxTimeout      :1;  /* Receive timeout.                              */
  400.    UINT TxLastCharSent :1;  /* Last Tx queue char sent to Tx hdwe.           */
  401.    UINT DeltaCTS       :1;  /* Delta CTS.                                    */
  402.    UINT DeltaDSR       :1;  /* Delta DSR.                                    */
  403.    UINT DeltaDCD       :1;  /* Delta DCD.                                    */
  404.    UINT BreakDetect    :1;  /* Break detected.                               */
  405.    UINT PtyFrmRxHdwe   :1;  /* Parity,framing,or Rx hdwe overrun error.      */
  406.    UINT DeltaRI        :1;  /* Delta RI low.                                 */
  407.    UINT Undef          :7;  /* Undefined.                                    */
  408.   }ComEvent;
  409.  
  410.   char *ComEventMsg[10] = {
  411.                            "\nCharacter transfered from hdwe to Rx queue." ,
  412.                            "\nReceive timeout."                            ,
  413.                            "\nLast Tx queue char sent to Tx hdwe."         ,
  414.                            "\nDelta CTS"                                   ,
  415.                            "\nDelta DSR"                                   ,
  416.                            "\nDelta DCD"                                   ,
  417.                            "\nBreak detected."                             ,
  418.                            "\nParity,framing,or Rx hdwe overrun error."    ,
  419.                            "\nDelta RI low."                               ,
  420.                            "\nUndefined."
  421.                           };
  422.  
  423.   ULONG  ComEventInOut = sizeof(ComEvent);
  424.  
  425.   memset(&ComEvent,0,sizeof(ComEvent));
  426.  
  427.   rc = (USHORT)DosDevIOCtl ( ComHandle,
  428.                              IOCTL_ASYNC,
  429.                              ASYNC_GETCOMMEVENT,
  430.                              NULL,
  431.                              0,
  432.                              NULL,
  433.                              &ComEvent,
  434.                              ComEventInOut,
  435.                              &ComEventInOut);
  436.  
  437.   if(rc){fprintf(comdmp,"ioctl error");fflush(0);exit(0);}
  438.   fprintf(comdmp,"\n\n=====Com event ===============\n");
  439.   if(ComEvent.RxQueueToHdwe)   fprintf(comdmp,ComEventMsg[0]);
  440.   if(ComEvent.RxTimeout)       fprintf(comdmp,ComEventMsg[1]);
  441.   if(ComEvent.TxLastCharSent ) fprintf(comdmp,ComEventMsg[2]);
  442.   if(ComEvent.DeltaCTS)        fprintf(comdmp,ComEventMsg[3]);
  443.   if(ComEvent.DeltaDSR)        fprintf(comdmp,ComEventMsg[4]);
  444.   if(ComEvent.DeltaDCD)        fprintf(comdmp,ComEventMsg[5]);
  445.   if(ComEvent.BreakDetect)     fprintf(comdmp,ComEventMsg[6]);
  446.   if(ComEvent.PtyFrmRxHdwe)    fprintf(comdmp,ComEventMsg[7]);
  447.   if(ComEvent.DeltaRI)         fprintf(comdmp,ComEventMsg[8]);
  448.   if(ComEvent.Undef)           fprintf(comdmp,ComEventMsg[9]);
  449.  }
  450. /*****************************************************************************/
  451. /* Query the device control block.                                           */
  452. /*****************************************************************************/
  453. {
  454.  struct
  455.  {
  456.   USHORT WriteTimeOut;        /* Write Timeout(msec)                         */
  457.   USHORT ReadTimeOut;         /* Read  Timeout(msec)                         */
  458.  
  459.   struct _flags1
  460.   {
  461.    UINT  DTR_Ctrl  :2;         /* bit 0   bit 1                               */
  462.                                /*  0        0   Disable.                      */
  463.                                /*  0        1   Enable.                       */
  464.                                /*  1        0   Input handshaking.            */
  465.                                /*  1        1   Invalid.                      */
  466.                                /*                                             */
  467.    UINT  Reserved1 :1;         /* Reserved(returned as 0).                    */
  468.    UINT  CTS_Enable:1;         /* Enable output handshaking using CTS.        */
  469.    UINT  DSR_Enable:1;         /* Enable output handshaking using DSR.        */
  470.    UINT  DCD_Enable:1;         /* Enable output handshaking using DCD.        */
  471.    UINT  DSR_Sensi :1;         /* Enable input sensitivity using DSR.         */
  472.    UINT  Reserved2 :1;         /* Reserved( returned as 0 ).                  */
  473.   }HandShake;                  /*                                             */
  474.                                /*                                             */
  475.   struct _flags2               /*                                             */
  476.   {                            /*                                             */
  477.    UINT  Tx_Auto_Flow_Enable:1;/* Enable Auto xmit Flow Control(XON/XOFF).    */
  478.    UINT  Rx_Auto_Flow_Enable:1;/* Enable Auto rcv  Flow Control(XON/XOFF).    */
  479.    UINT  Error_Enable       :1;/* Enable error replacement character.         */
  480.    UINT  Null_Enable        :1;/* Enable null stripping( remove null bytes).  */
  481.    UINT  Break_Enable       :1;/* Enable break replacement character.         */
  482.    UINT  Rx_Auto_Flow       :1;/* 0 = normal 1 = full duplex.                 */
  483.    UINT  RTS_Ctrl           :2;/* b7 b6                                       */
  484.                                /*  0 0 Disable.                               */
  485.                                /*  0 1 Enable.                                */
  486.                                /*  1 0 Input Handshaking.                     */
  487.                                /*  1 1 Toggling on transmit.                  */
  488.   }FlowReplace;                /*                                             */
  489.                                /*                                             */
  490.   struct _flags3               /*                                             */
  491.   {                            /*                                             */
  492.    UINT  WriteInfiniteEnable:1;/* Enable Write Infinite Timeout processing.   */
  493.    UINT  ReadTimeout        :2;/* b2 b3                                       */
  494.                                /*  0 1 Normal Read Timeout processing.        */
  495.                                /*  1 0 Wait-for-something readout timeout.    */
  496.                                /*  1 1 No-wait read timeout processing.       */
  497.                                /*                                             */
  498.    UINT  ExtHdweBuffering   :2;/* b4 b3                                       */
  499.                                /*  0 0 Not supported.                         */
  500.                                /*  0 1 Extended hardware buffering disabled.  */
  501.                                /*  1 0 Extended hardware buffering enabled.   */
  502.                                /*  1 1 Automatic Protocol override.           */
  503.                                /*                                             */
  504.    UINT  RxTriggerLevel     :2;/* b6 b5                                       */
  505.                                /*  0 0 1 character.                           */
  506.                                /*  0 1 4 characters.                          */
  507.                                /*  1 0 8 characters.                          */
  508.                                /*  1 1 14 characters.                         */
  509.                                /*                                             */
  510.    UINT  TxBufferLoadCount  :1;/* b7                                          */
  511.                                /*  0   1  character.                          */
  512.                                /*  1   16 characters.                         */
  513.   }TimeOut;                    /*                                             */
  514.                                /*                                             */
  515.   UCHAR ErrorReplacement;      /* Returned value.                             */
  516.   UCHAR BreakReplacement;      /* Returned value.                             */
  517.   UCHAR XON_Character;         /* Returned value.                             */
  518.   UCHAR XOFF_Character;        /* Returned value.                             */
  519.  }Dcb;                         /*                                             */
  520.  
  521.   char *DcbHandShakeMsg[5] =
  522.   {
  523.    "\n...Reserved( error if you see this message )",
  524.    "\n...CTS Output handshaking enabled)",
  525.    "\n...DSR Output handshaking enabled)",
  526.    "\n...DCD Output handshaking enabled)",
  527.    "\n...DSR Input Sensitivity  enabled)"
  528.   };
  529.  
  530.   char *DcbFlowReplaceMsg[5] =
  531.   {
  532.    "\n...Automatic Transmit Flow(XON/XOFF) Enabled )",
  533.    "\n...Automatic Receive  Flow(XON/XOFF) Enabled )",
  534.    "\n...Error Replacement character enabled)",
  535.    "\n...Null stripping enabled.)",
  536.    "\n...Break replacement character enabled)"
  537.   };
  538.  
  539.   ULONG  DcbLenInOut = sizeof(Dcb);
  540.  
  541.   memset(&Dcb,0,DcbLenInOut);
  542.  
  543.   rc = (USHORT)DosDevIOCtl ( ComHandle,
  544.                              IOCTL_ASYNC,
  545.                              ASYNC_GETDCBINFO,
  546.                              NULL,
  547.                              0,
  548.                              NULL,
  549.                              &Dcb,
  550.                              DcbLenInOut,
  551.                              &DcbLenInOut);
  552.  
  553.   if(rc){fprintf(comdmp,"ioctl error");fflush(0);exit(0);}
  554.   fprintf(comdmp,"\n\n=====Device Control Blk=======\n");
  555.   fprintf(comdmp,"\nWrite TimeOut(x.01 sec) %d",Dcb.WriteTimeOut);
  556.   fprintf(comdmp,"\nRead  TimeOut(x.01 sec) %d",Dcb.ReadTimeOut);
  557.  
  558.   /***************************************************************************/
  559.   /* Handshake flags.                                                        */
  560.   /***************************************************************************/
  561.   fprintf(comdmp,"\n");
  562.   fprintf(comdmp,"\nHandshake flags     %x",Dcb.HandShake);
  563.   switch(Dcb.HandShake.DTR_Ctrl)
  564.   {
  565.    case 0:
  566.     fprintf(comdmp,"\n...DTR Control Disabled");
  567.     break;
  568.    case 1:
  569.     fprintf(comdmp,"\n...DTR Control Enabled");
  570.     break;
  571.  
  572.    case 2:
  573.     fprintf(comdmp,"\n...DTR Input Handshaking");
  574.     break;
  575.  
  576.    case 3:
  577.     fprintf(comdmp,"\n...DTR Invalid");
  578.     break;
  579.   }
  580.   if(Dcb.HandShake.Reserved1  )   fprintf(comdmp,DcbHandShakeMsg[0] );
  581.   if(Dcb.HandShake.CTS_Enable )   fprintf(comdmp,DcbHandShakeMsg[1] );
  582.   if(Dcb.HandShake.DSR_Enable )   fprintf(comdmp,DcbHandShakeMsg[2] );
  583.   if(Dcb.HandShake.DCD_Enable )   fprintf(comdmp,DcbHandShakeMsg[3] );
  584.   if(Dcb.HandShake.DSR_Sensi  )   fprintf(comdmp,DcbHandShakeMsg[4] );
  585.   if(Dcb.HandShake.Reserved2  )   fprintf(comdmp,DcbHandShakeMsg[0] );
  586.  
  587.   /***************************************************************************/
  588.   /* Flow/Replace flags.                                                     */
  589.   /***************************************************************************/
  590.   fprintf(comdmp,"\n");
  591.   fprintf(comdmp,"\nFlow/Replace flags  %x",Dcb.FlowReplace);
  592.   if(Dcb.FlowReplace.Tx_Auto_Flow_Enable) fprintf(comdmp,DcbFlowReplaceMsg[0]);
  593.   if(Dcb.FlowReplace.Rx_Auto_Flow_Enable) fprintf(comdmp,DcbFlowReplaceMsg[1]);
  594.   if(Dcb.FlowReplace.Error_Enable       ) fprintf(comdmp,DcbFlowReplaceMsg[2]);
  595.   if(Dcb.FlowReplace.Null_Enable        ) fprintf(comdmp,DcbFlowReplaceMsg[3]);
  596.   if(Dcb.FlowReplace.Break_Enable       ) fprintf(comdmp,DcbFlowReplaceMsg[4]);
  597.   switch(Dcb.FlowReplace.Rx_Auto_Flow)
  598.   {
  599.    case 0:
  600.     fprintf(comdmp,"\n...Auto Receive Flow Control Normal");
  601.     break;
  602.  
  603.    case 1:
  604.     fprintf(comdmp,"\n...Auto Receive Flow Control Full Duplex");
  605.     break;
  606.   }
  607.   switch(Dcb.FlowReplace.RTS_Ctrl)
  608.   {
  609.    case 0:
  610.     fprintf(comdmp,"\n...RTS Control Disabled");
  611.     break;
  612.  
  613.    case 1:
  614.     fprintf(comdmp,"\n...RTS Control Enabled");
  615.     break;
  616.  
  617.    case 2:
  618.     fprintf(comdmp,"\n...RTS Input Handshaking");
  619.     break;
  620.  
  621.    case 3:
  622.     fprintf(comdmp,"\n...RTS Toggling on Transmit");
  623.     break;
  624.   }
  625.  
  626.   /***************************************************************************/
  627.   /* Timeout flags.                                                          */
  628.   /***************************************************************************/
  629.   fprintf(comdmp,"\n");
  630.   fprintf(comdmp,"\nTimeout flags  %x",Dcb.TimeOut);
  631.   if(Dcb.TimeOut.WriteInfiniteEnable)
  632.    fprintf(comdmp,"\n...Write Infinite Timeout Processing Enabled");
  633.   switch(Dcb.TimeOut.ReadTimeout )
  634.   {
  635.    case 0:
  636.     fprintf(comdmp,"\n...undefined");
  637.     break;
  638.  
  639.    case 1:
  640.     fprintf(comdmp,"\n...Normal read timeout ");
  641.     break;
  642.  
  643.    case 2:
  644.     fprintf(comdmp,"\n...Wait for something ");
  645.     break;
  646.  
  647.    case 3:
  648.     fprintf(comdmp,"\n...No wait ");
  649.     break;
  650.   }
  651.  
  652.   switch(Dcb.TimeOut.ExtHdweBuffering)
  653.   {
  654.    case 0:
  655.     fprintf(comdmp,"\n...Not supported");
  656.     break;
  657.  
  658.    case 1:
  659.     fprintf(comdmp,"\n...Extended hardware buffering disabled");
  660.     break;
  661.  
  662.    case 2:
  663.     fprintf(comdmp,"\n...Extended hardware buffering enabled");
  664.     break;
  665.  
  666.    case 3:
  667.     fprintf(comdmp,"\n...Automatic protocol override enabled");
  668.     break;
  669.   }
  670.   switch(Dcb.TimeOut.RxTriggerLevel)
  671.   {
  672.    case 0:
  673.     fprintf(comdmp,"\n...Receive Trigger Level is 1 character");
  674.     break;
  675.  
  676.    case 1:
  677.     fprintf(comdmp,"\n...Receive Trigger Level is 4 characters");
  678.     break;
  679.  
  680.    case 2:
  681.     fprintf(comdmp,"\n...Receive Trigger Level is 8 characters");
  682.     break;
  683.  
  684.    case 3:
  685.     fprintf(comdmp,"\n...Receive Trigger Level is 14 characters");
  686.     break;
  687.   }
  688.   switch(Dcb.TimeOut.TxBufferLoadCount)
  689.   {
  690.    case 0:
  691.     fprintf(comdmp,"\n...Transmit buffer load count is 1 character");
  692.     break;
  693.  
  694.    case 1:
  695.     fprintf(comdmp,"\n...Transmit buffer load count is 16 characters");
  696.     break;
  697.   }
  698.   fprintf(comdmp,"\n");
  699.   fprintf(comdmp,"\nError Replacement character %c 0x%x",Dcb.ErrorReplacement,
  700.                                                        Dcb.ErrorReplacement);
  701.   fprintf(comdmp,"\nBreak Replacement character %c 0x%x",Dcb.BreakReplacement,
  702.                                                        Dcb.BreakReplacement);
  703.   fprintf(comdmp,"\nXON  Character              %c 0x%x",Dcb.XON_Character,
  704.                                                        Dcb.XON_Character);
  705.   fprintf(comdmp,"\nXOFF Character              %c 0x%x",Dcb.XOFF_Character,
  706.                                                        Dcb.XOFF_Character);
  707. }
  708.  /****************************************************************************/
  709.  /* Query Enhanced mode parameters.                                          */
  710.  /****************************************************************************/
  711.  {
  712.   struct
  713.   {
  714.    UINT EnhSupport     :1;  /* Enhanced Mode supported by hardware.          */
  715.    UINT EnhEnabled     :1;  /* Enhanced Mode enabled.                        */
  716.    UINT RxDMA          :2;  /* b0 b1                                         */
  717.                             /*  0 0 DMA receive capability disabled.         */
  718.                             /*  0 1 DMA receive capability enabled.          */
  719.                             /*  1 0 DMA channel dedicated to receive.        */
  720.                             /*  1 1 Reserved.                                */
  721.    UINT TxDMA          :2;  /* b0 b1                                         */
  722.                             /*  0 0 DMA transmit capability disabled.        */
  723.                             /*  0 1 DMA transmit capability enabled.         */
  724.                             /*  1 0 DMA channel dedicated to transmit.       */
  725.                             /*  1 1 Reserved.                                */
  726.    UINT RxInDMA_Mode   :1;  /* Receive operation in DMA mode.                */
  727.    UINT TxInDMA_Mode   :1;  /* Transmit operation in DMA mode.               */
  728.    ULONG Reserved;
  729.   }EnhMode;
  730.  
  731.   ULONG  EnhModeLenInOut = sizeof(EnhMode);
  732.   memset(&EnhMode,0,sizeof(EnhMode));
  733.  
  734.   rc = (USHORT)DosDevIOCtl ( ComHandle,
  735.                              IOCTL_ASYNC,
  736.                              0x74,
  737.                              NULL,
  738.                              0,
  739.                              NULL,
  740.                              &EnhMode,
  741.                              EnhModeLenInOut,
  742.                              &EnhModeLenInOut);
  743.  
  744.   if(rc){fprintf(comdmp,"ioctl error");fflush(0);exit(0);}
  745.   fprintf(comdmp,"\n\n=====Enhanced Mode Parameters=\n");
  746.   fprintf(comdmp,"\n");
  747.   fprintf(comdmp,"\nEnhanced mode %s supported by hardware.",
  748.        (EnhMode.EnhSupport)?"is":"is not");
  749.   fprintf(comdmp,"\nEnhanced mode %s.",
  750.        (EnhMode.EnhEnabled)?"enabled":"disabled");
  751.  
  752.   switch(EnhMode.RxDMA)
  753.   {
  754.    case 0:
  755.     fprintf(comdmp,"\nDMA receive capability disabled.");
  756.     break;
  757.  
  758.    case 1:
  759.     fprintf(comdmp,"\nDMA receive capability enabled.");
  760.     break;
  761.  
  762.    case 2:
  763.     fprintf(comdmp,"\nDMA channel dedicated to receive operation");
  764.     break;
  765.  
  766.    case 3:
  767.     fprintf(comdmp,"\nreserved.Check this out...bad news.  ");
  768.     break;
  769.   }
  770.   switch(EnhMode.TxDMA)
  771.   {
  772.    case 0:
  773.     fprintf(comdmp,"\nDMA transmit capability disabled.");
  774.     break;
  775.  
  776.    case 1:
  777.     fprintf(comdmp,"\nDMA transmit capability enabled.");
  778.     break;
  779.  
  780.    case 2:
  781.     fprintf(comdmp,"\nDMA channel dedicated to transmit operation");
  782.     break;
  783.  
  784.    case 3:
  785.     fprintf(comdmp,"\nreserved.Check this out...bad news.  ");
  786.     break;
  787.   }
  788.   if(EnhMode.RxInDMA_Mode)
  789.    fprintf(comdmp,"\nRx operation in DMA mode.");
  790.   if(EnhMode.TxInDMA_Mode)
  791.    fprintf(comdmp,"\nTx operation in DMA mode.");
  792.  }
  793. fclose(comdmp);
  794. return(0);
  795. }
  796.