]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
Bug 411: fix CQ support for Class 2.0/2.1
authorLee Howard <faxguy@howardsilvan.com>
Wed, 11 Feb 2004 16:51:13 +0000 (16:51 +0000)
committerLee Howard <faxguy@howardsilvan.com>
Wed, 11 Feb 2004 16:51:13 +0000 (16:51 +0000)
config/lucent-mt-2
config/lucent-mt-20
config/lucent-mt-21
faxd/Class2.c++
faxd/Class2.h
faxd/Class2Recv.c++
man/hylafax-config.4f

index 9ecb9ee34f7b9e6fe1a01b79d0b446b742784221..59704ef52213ef01d1c2e726983a654b6943032c 100644 (file)
@@ -31,6 +31,12 @@ Class2NFLOCmd:               AT+FLO=0
 Class2SFLOCmd:         AT+FLO=1
 Class2HFLOCmd:         AT+FLO=2
 
+# The modem performs copy quality correction (in Class 2... gasp!)
+# always, thus it's not a good idea to use host-based CQ.  The
+# query response is incorrect, also.
+Class2CQQueryCmd:      "!0-2"
+Class2CQCmd:           AT+FCQ=1
+
 # If your line supports Caller-ID, you may want to uncomment this...
 # QualifyCID:          etc/cid         # you must create this file
 # ModemResetCmds:      AT+VCID=1
index d43d8caa42f67bb06a1ff15f2b6c80a7b5121eac..8fb531bcc2d11f2716d0c3621aa7f57aa91b5a77 100644 (file)
@@ -20,10 +20,14 @@ ModemHardFlowCmd:   AT&K3
 
 Class2APCmd:           AT+FAP=1,1,1
 Class2BUGCmd:          AT+FBU=0                # early firmware is buggy
-Class2CQCmd:           AT+FCQ=1,0
 Class2SendRTC:         yes
 Class2UseHex:          yes
 
+# Some firmwares do not report copy quality correction, although it
+# is present and cannot be disabled.  Thus modem-based CQ must be used.
+Class2CQQueryCmd:      "!(00-02),(00-02)"
+Class2CQCmd:           AT+FCQ=1,0
+
 # versions that respond to AT+FFC=? with non-zero data support RTFCC
 # Class2RTFCC:         yes
 
index 0d7f3312f09682bdcf18482ddc9c418efbee7b2c..285057d81b91b7d5122284e2935fc0f9ab77bc8e 100644 (file)
@@ -20,10 +20,14 @@ ModemHardFlowCmd:   AT&K3
 
 Class2APCmd:           AT+FAP=1,1,1
 Class2BUGCmd:          AT+FBU=0        # early firmware is buggy
-Class2CQCmd:           AT+FCQ=1,0
 Class2SendRTC:         yes
 Class2UseHex:          yes
 
+# Some firmwares do not report copy quality correction, although it
+# is present and cannot be disabled.  Thus modem-based CQ must be used.
+Class2CQQueryCmd:      "!(00-02),(00-02)"
+Class2CQCmd:           AT+FCQ=1,0
+
 # versions that respond to AT+FFC=? with non-zero data support RTFCC
 # Class2RTFCC:         yes
 
index d475e060ef83ba251119032993552392e7ce72aa..188eab9805b7253d0b46be9fe9a1e476a56b1347 100644 (file)
@@ -106,16 +106,63 @@ Class2Modem::setupModem()
      * If the modem is capable, then enable it using the configured
      * commands.  If the modem is incapable of doing copy quality
      * checking, then the host will do the work.
+     *
+     * The recommendation for AT+FCQ varies significantly between
+     * the Class 2 and Class 2.0 specification.
+     *
+     * An assumption is made that Class2CQCmd, if configured, enables
+     * all available copy quality services (or disables them if none
+     * are available).
      */
     cqCmds = "";
-    if (doQuery(conf.class2CQQueryCmd, s) && FaxModem::parseRange(s, modemCQ)) {
-       if (modemCQ >>= 1)
-           cqCmds = conf.class2CQCmd;
-    } else
-       modemCQ = 0;
-    static const char* whatCQ[4] = { "no", "1D", "2D", "1D+2D" };
-    modemSupports("%s copy quality checking%s", whatCQ[modemCQ&3],
-       (modemCQ && cqCmds == "" ? " (but not enabled)" : ""));
+    sendCQ = 0;
+    if (serviceType == SERVICE_CLASS2) {
+       /*
+        * The AT+FCQ=? response indicates which compression
+         * formats are copy-quality checked.
+        */
+       if (doQuery(conf.class2CQQueryCmd, s) && FaxModem::parseRange(s, modemCQ)) {
+           if (modemCQ >>= 1)
+               cqCmds = conf.class2CQCmd;
+       } else
+           modemCQ = 0;
+       static const char* whatCQ[4] = { "no", "1D", "2D", "1D+2D" };
+       modemSupports("%s copy quality checking%s", whatCQ[modemCQ&3],
+           (modemCQ && cqCmds == "" ? " (but not enabled)" : ""));
+    } else {           // SERVICE_CLASS20, SERVICE_CLASS21
+       /*
+        * The AT+FCQ=? response indicates whether or not copy-quality
+         * checking and/or correction are supported.  Host CQ cannot
+        * be used if the modem performs copy-quality correction.
+        */
+       cqCmds = conf.class2CQCmd;
+       if (doQuery(conf.class2CQQueryCmd, s) && FaxModem::vparseRange(s, 0, 2, &modemCQ, &sendCQ)) {
+           modemCQ >>= 1;
+           sendCQ >>= 1;
+       } else {
+           modemCQ = 0;
+           sendCQ = 0;
+       }
+       static const char* whatCQ[4] = { "no", "checking", "correction", "checking and correction" };
+       if (modemCQ)
+           modemSupports("receiving copy quality %s", whatCQ[modemCQ&3]);
+       else modemSupports("no receiving copy quality services");
+       if (sendCQ)
+           modemSupports("sending copy quality %s%s", whatCQ[sendCQ&3],
+               (sendCQ && cqCmds == "" ? " (but not enabled)" : ""));
+       else modemSupports("no sending copy quality services");
+    }
+    /*
+     * In Class 2 we follow spec defaults and assume that if cqCmds is null 
+     * that CQ is not enabled.  In Class 2.0/2.1 we follow spec default and
+     * assume the opposite.  In order to know otherwise we'd need to make
+     * sense of AT+FCQ? and incorporate that in the messages above.
+     */
+    if (serviceType == SERVICE_CLASS2)
+       if (cqCmds == "") modemCQ = 0;
+    else {     // SERVICE_CLASS20, SERVICE_CLASS21
+       if (cqCmds == "" && modemCQ) modemCQ = 1;
+    }
     /*
      * Deduce if modem supports T.class2-defined suport for
      * subaddress, selective polling address, and passwords.
index d191d73e2bd589fa766eca712cdc6bef8da928f6..979895cd9df6e81f6b22a74f10aefe6d475d9060 100644 (file)
@@ -61,6 +61,7 @@ protected:
     fxStr      hardFlowCmd;            // hardware flow control command
     u_int      serviceType;            // modem service required
     u_int      modemCQ;                // copy quality capabilities mask
+    u_int      sendCQ;                 // sending copy quality capabilities mask
 
     bool       xmitWaitForXON;         // if true, wait for XON when sending
     bool       hostDidCQ;              // if true, copy quality done on host
index f81eb0f9acf682a775038ad23b1d4f160fdb79ef..d330c02e9e28734d22061774d66b47863acc7be2 100644 (file)
@@ -275,8 +275,16 @@ Class2Modem::recvPageData(TIFF* tif, fxStr& emsg)
      * Have host do copy quality checking if the modem does not
      * support checking for this data format and if the configuration
      * parameters indicate CQ checking is to be done.
+     *
+     * If the modem is performing copy quality correction then
+     * the host cannot perform copy quality checking.
      */
-    hostDidCQ = (modemCQ & BIT(params.df)) == 0 && checkQuality();
+    if (serviceType == SERVICE_CLASS2)
+       hostDidCQ = (modemCQ & BIT(params.df)) == 0 && checkQuality();
+    else
+       hostDidCQ = modemCQ == 0 && checkQuality();
+    protoTrace("Copy quality checking performed by %s", hostDidCQ ? "host" : "modem");
+
     bool pageRecvd = recvPageDLEData(tif, hostDidCQ, params, emsg);
 
     // be careful about flushing here -- otherwise we lose +FPTS codes
index 290110adb8c4dbbfd205005647a798ccf6694ba5..bb0a4bacfdb92ab9aef02ef73757c96002fab5b4 100644 (file)
@@ -2270,6 +2270,20 @@ The value ``none'' may be used if the modem does not support any
 The command used to set a polling identifier.
 This string is inserted into the format ``\s-1%s="<id>"\s+1''.
 .TP
+.B Class2CQCmd
+The command to use to set up parameters for copy quality checking.
+For example, for an Everex 24/96D modem this parameter might be set to
+``\s-1AT+FCQ=1\enAT+FBADMUL=20\enAT+FBADLIN=10\s+1''.
+.B Class2CQCmd
+should be configured to set-up all available copy quality services
+available per
+.B Class2CQQueryCmd.
+To disable features that are available, configure
+.B Class2CQQueryCmd
+with a ``!'', and then set
+.B Class2CQCmd
+accordingly.
+.TP
 .B Class2CQQueryCmd
 The command to send to the modem to get the copy quality capabilities string.
 If the parameter begins with a ``!'', then the remainder of the
@@ -2282,16 +2296,12 @@ See also
 .B PercentGoodLines
 and
 .B MaxConsecutiveBadLines
-for parameters used to do server copy quality checking.
+for parameters used to do server copy quality checking.  If copy quality
+checking is configured to be done by the modem then it is not done by the server.
 .TP
 .B Class2CRCmd
 The command to use to enable the reception of facsimile.
 .TP
-.B Class2CQCmd
-The command to use to set up parameters for copy quality checking.
-For example, for an Everex 24/96D modem this parameter might be set to
-``\s-1AT+FCQ=1\enAT+FBADMUL=20\enAT+FBADLIN=10\s+1''.
-.TP
 .B Class2DCCCmd
 The command used to set modem capabilities.
 This string is inserted into the format