]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
Add more intelligence to the Class 1 receiver in sending RTN
authorAidan Van Dyk <aidan@ifax.com>
Wed, 14 Mar 2007 18:29:25 +0000 (18:29 +0000)
committerAidan Van Dyk <aidan@ifax.com>
Wed, 14 Mar 2007 18:29:25 +0000 (18:29 +0000)
From Lee's work:
|  commit 2fdb9f1d671d5f378bd66e9222707f66fa4be118
|  Author: Lee Howard <faxguy@howardsilvan.com>
|  Date:   Sat Nov 4 00:38:58 2006 +0000
|
|    If, without receiving any Phase C data, we get PPM very quickly after we
|    last sent MCF... well, we can rest assured that the sender didn't get our
|    MCF signal ... and it wasn't that we missed an extremely short page.
|
|    So instead of sending RTN let's send MCF again... helping prevent retrains
|    and slow progress, etc.

and

|  commit 45f8d9cb46b5db27dc2c845a5975e6eab5a52f23
|  Author: Lee Howard <faxguy@howardsilvan.com>
|  Date:   Sat Nov 4 02:19:37 2006 +0000
|
|    Sys::now() is seconds not ms... plus it needed to be longer than 3100 ms anyway.

CHANGES
faxd/Class1.h
faxd/Class1Recv.c++

diff --git a/CHANGES b/CHANGES
index d74166bb0753f41c93276d24f84f294682442e5b..b8bb4be98f2bd7e79ff9dd6b37a73bcf31d2729e 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,7 @@
 
 Changelog since HylaFAX 4.3.3
 
+* Add more intelligence to the Class 1 receiver in sending RTN (12 Mar 2007)
 * Restart Class 1 TCF reception timer after zeros start
 * Handle +FCERROR after most +FRH=3 commands (12 Mar 2007)
 * We can't rely on the timeout value to know if CONNECT has been seen (12 Mar 2007)
index e8953d5d4bd2b75ff8e645a9b1ace74bc4beaba6..bccd364f8007519e9c203c3dd65f210d3001c4ef 100644 (file)
@@ -78,6 +78,7 @@ protected:
     bool       messageReceived;        // expect/don't expect message carrier
     bool       repeatPhaseB;           // return to beginning of Phase B before next page
     bool       silenceHeard;           // indicates whether the last command was +FRS
+    time_t     lastMCF;                // indicates the time of the last MCF signal
     u_int      lastPPM;                // last PPM during receive
     bool       sendCFR;                // received TCF was not confirmed
     u_short    ecmBitPos;              // bit position to populate on ecmByte
index e9e585366bd7e397553d635260c262014c0eeeca..5a52174240fd5dc012096075b267c4bbe056e26a 100644 (file)
@@ -93,6 +93,7 @@ Class1Modem::recvBegin(fxStr& emsg)
     recvdDCN = false;                          // haven't seen DCN
     lastPPM = FCF_DCN;                         // anything will do
     sendCFR = false;                           // TCF was not received
+    lastMCF = 0;                               // no MCF heard yet
 
     fxStr nsf;
     encodeNSF(nsf, HYLAFAX_VERSION);
@@ -495,6 +496,7 @@ Class1Modem::recvPage(TIFF* tif, u_int& ppm, fxStr& emsg, const fxStr& id)
            startTimeout(7550);
            (void) sendFrame((sendERR ? FCF_ERR : FCF_MCF)|FCF_RCVR);
            stopTimeout("sending HDLC frame");
+           lastMCF = Sys::now();
        } else if (conf.badPageHandling == FaxModem::BADPAGE_RTNSAVE) {
            startTimeout(7550);
            (void) sendFrame(FCF_RTN|FCF_RCVR);
@@ -829,10 +831,12 @@ Class1Modem::recvPage(TIFF* tif, u_int& ppm, fxStr& emsg, const fxStr& id)
                                }
                            } else {
                                (void) transmitFrame((sendERR ? FCF_ERR : FCF_MCF)|FCF_RCVR);
+                               lastMCF = Sys::now();
                            }
-                           if (pageGood)
+                           if (pageGood) {
                                traceFCF("RECV send", sendERR ? FCF_ERR : FCF_MCF);
-                           else
+                               lastMCF = Sys::now();
+                           } else
                                traceFCF("RECV send", FCF_RTN);
                        }
                        /*
@@ -866,15 +870,28 @@ Class1Modem::recvPage(TIFF* tif, u_int& ppm, fxStr& emsg, const fxStr& id)
                    if (!switchingPause(emsg)) {
                        return (false);
                    }
-                   u_int rtnfcf = conf.badPageHandling == FaxModem::BADPAGE_DCN ? FCF_DCN : FCF_RTN;
-                   (void) transmitFrame(rtnfcf|FCF_RCVR);
-                   traceFCF("RECV send", rtnfcf);
-                   /*
-                    * Reset the TIFF-related state so that subsequent
-                    * writes will overwrite the previous data.
-                    */
-                   messageReceived = true;     // expect DCS next
                    signalRcvd = 0;
+                   if (params.ec == EC_DISABLE && !getRecvEOLCount() && (Sys::now() - lastMCF < 4)) {
+                       /*
+                        * We last transmitted MCF a very, very short time ago, received no image data
+                        * since then, and now we're seeing a PPM again.  In non-ECM mode the chances of 
+                        * this meaning that we simply missed a very short page is extremely remote.  It
+                        * probably means that the sender did not properly hear our MCF and that we just
+                        * need to retransmit it. 
+                        */
+                       (void) transmitFrame(FCF_MCF|FCF_RCVR);
+                       traceFCF("RECV send", FCF_MCF);
+                       messageReceived = false;        // expect Phase C
+                   } else {
+                       u_int rtnfcf = conf.badPageHandling == FaxModem::BADPAGE_DCN ? FCF_DCN : FCF_RTN;
+                       (void) transmitFrame(rtnfcf|FCF_RCVR);
+                       traceFCF("RECV send", rtnfcf);
+                       /*
+                        * Reset the TIFF-related state so that subsequent
+                        * writes will overwrite the previous data.
+                        */
+                       messageReceived = true; // expect DCS next
+                   }
                }
                break;
            case FCF_DCN:                       // DCN