]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
Class1: Wait longer to make sure remote is not signaling after bad HDLC
authorAidan Van Dyk <aidan@ifax.com>
Fri, 11 May 2007 15:15:58 +0000 (15:15 +0000)
committerAidan Van Dyk <aidan@ifax.com>
Fri, 11 May 2007 15:15:58 +0000 (15:15 +0000)
From Lee:
| commit 1bf408d11df448a1087a5333ec5b55d912de9b5b
| Author: Lee Howard <faxguy@howardsilvan.com>
| Date:   Sun Mar 4 01:49:11 2007 +0000
|
|   We really need to make sure that the remote is not signalling when we send
|   CRP... or it's in vain.  If we get bad HDLC for DCS then we're apt to send
|   CRP while the remote is signalling TCF.  So we double-up on the wait, to
|   make sure that we're really okay to go.
|
|   Two AT+FRS=7 in a row may be less-elegant than a single AT+FRS=14...
|
|   But to do that properly we'd have to change the Class1SwitchingCmd definition
|   or do some stuff that really won't be nice to do right now.

and:
| commit bb9c6341756c376b6daeba980f01ef5f1566a9a4
| Author: Lee Howard <faxguy@howardsilvan.com>
| Date:   Wed Mar 14 23:31:07 2007 +0000
|
|   We have code deliberately preventing the duplication of switchingPause commands
|   being sent to the modem.  Duh.  So the previous approach wouldn't work.
|
|   So we've got to do this the more elegant way... :-)

and:
| commit 19d29e3dc455798ca8ef90cf39db8fb5e892abef
| Author: Lee Howard <faxguy@howardsilvan.com>
| Date:   Sat Apr 14 22:08:34 2007 +0000
|
|   fxStr .head isn't very forgiving if the string length isn't enough.  :-(

faxd/Class1.c++
faxd/Class1.h

index fb588742f877cab6dec132ac4a2269b62b51c5cc..78746f5181fdb382245667d4737b28ec6fec50c5 100644 (file)
@@ -467,9 +467,26 @@ Class1Modem::decodePWD(fxStr& ascii, const HDLCFrame& binary)
 }
 
 bool
-Class1Modem::switchingPause(fxStr& emsg)
+Class1Modem::switchingPause(fxStr& emsg, u_int times)
 {
-    if (!silenceHeard && !atCmd(conf.class1SwitchingCmd, AT_OK)) {
+    /*
+     * If class1SwitchingCmd is of the AT+FRS=n form we honor
+     * the caller's indicattion for a multiplication of the
+     * configured silence detection.  This is primarily used
+     * to avoid sending CRP as a receiver during a sender's TCF,
+     * but it could also be used in places where we find a
+     * longer wait often necessary.
+     */
+    fxStr scmd = fxStr(conf.class1SwitchingCmd);
+    if (times != 1) {
+       fxStr ncmd = fxStr(scmd);
+       ncmd.raiseatcmd();
+       if (ncmd.length() > 7 && ncmd.head(7) == "AT+FRS=") {
+           int dur = atoi(ncmd.tail(ncmd.length()-7)) * times;
+           scmd = scmd.head(7) | fxStr(dur, "%d");
+       }
+    }
+    if (!silenceHeard && !atCmd(scmd, AT_OK)) {
        emsg = "Failure to receive silence.";
        protoTrace(emsg);
        if (wasTimeout()) abortReceive();
@@ -1420,7 +1437,7 @@ Class1Modem::recvFrame(HDLCFrame& frame, u_char dir, long ms, bool readPending,
            frame.reset();
             gotframe = recvRawFrame(frame);
        } while (!gotframe && docrp && crpcnt++ < 3 && !wasTimeout() &&
-               switchingPause(emsg) && transmitFrame(dir|FCF_CRP));
+               switchingPause(emsg, 3) && transmitFrame(dir|FCF_CRP)); /* triple switchingPause to avoid sending CRP during TCF */
        return (gotframe);
     } else {
        gotCONNECT = false;
index b73d18653760c28af54617e972bc1e78599ed55a..b4810b948255d328d5a502f44bee2f14d13f8d2f 100644 (file)
@@ -160,7 +160,7 @@ protected:
     virtual ATResponse atResponse(char* buf, long ms = 30*1000);
     virtual bool waitFor(ATResponse wanted, long ms = 30*1000);
     virtual bool atCmd(const fxStr& cmd, ATResponse = AT_OK, long ms = 30*1000);
-    bool       switchingPause(fxStr& emsg);
+    bool       switchingPause(fxStr& emsg, u_int times = 1);
     void       encodeTSI(fxStr& binary, const fxStr& ascii);
     void       encodeNSF(fxStr& binary, const fxStr& ascii);
     const fxStr& decodeTSI(fxStr& ascii, const HDLCFrame& binary);