]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
faxgetty: retry answer command if modem doesn't respond
authorAidan Van Dyk <aidan@ifax.com>
Wed, 26 Sep 2007 12:55:52 +0000 (12:55 +0000)
committerAidan Van Dyk <aidan@ifax.com>
Wed, 26 Sep 2007 12:55:52 +0000 (12:55 +0000)
Based on work from Lee:
| commit 1beb05f502f08cc4fb327436140355a0a9d5a29d
| Author: Lee Howard <faxguy@howardsilvan.com>
| Date:   Thu Aug 2 20:03:19 2007 +0000
|
|   Second, if we do see multiple RINGs after the answer command (i.e. ATA) then
|   it means that the modem somehow didn't get the message, and we need to try
|   sending the command over again.
|
|   Note that there is a risk that between rings the call switched (e.g. the first
|   hung up and the second began) and so we could get the wrong CallID information
|   on the latter call.  Unfortunately, this is an inherant risk in analog
|   and analog-simulating environments.  Detecting call begins and ends is nearly
|   impossible to be completely sure all of the time.

faxd/ClassModem.c++
faxd/ClassModem.h

index 015283d1620a192bb22bb92f88a73d5f8b2055dd..b5ae525f7a23434e8b1bf694f005fe168d17a157 100644 (file)
@@ -223,17 +223,28 @@ ClassModem::findAnswer(const char* s)
  * Deduce connection kind: fax, data, or voice.
  */
 CallType
-ClassModem::answerResponse(Status& eresult)
+ClassModem::answerResponse(const fxStr& answerCmd, Status& eresult)
 {
     CallStatus cs = FAILURE;
     ATResponse r;
     time_t start = Sys::now();
+    u_short morerings = 0;
 
     do {
        r = atResponse(rbuf, conf.answerResponseTimeout);
 again:
        if (r == AT_TIMEOUT || r == AT_DLEEOT || r == AT_NOCARRIER)
            break;
+       if (r == AT_RING && ++morerings > 1) {
+           /*
+            * We answered already.  If we see RING once it could
+            * be glare.  If we see it yet again, then the modem
+            * apparently did not see or respond to our first
+            * answerCmd and we've got to try it again.
+            */
+           atCmd(answerCmd, AT_NOTHING);
+           morerings = 0;
+       }
        const AnswerMsg* am = findAnswer(rbuf);
        if (am != NULL) {
            if (am->expect != AT_NOTHING && conf.waitForConnect) {
@@ -290,7 +301,7 @@ ClassModem::answerCall(AnswerType atype, Status& eresult, const char* number)
     if (answerCmd == "")
        answerCmd = conf.answerAnyCmd;
     if (atCmd(answerCmd, AT_NOTHING)) {
-       ctype = answerResponse(eresult);
+       ctype = answerResponse(answerCmd, eresult);
        if (atype == ANSTYPE_DIAL) ctype = CALLTYPE_FAX;        // force as fax
        if (ctype == CALLTYPE_UNKNOWN) {
            /*
index 361953869b823bf4499b04314dc6ec9adc94246a..de7f1ee33f3b55397cc6f2897646a286bf4049a1 100644 (file)
@@ -219,7 +219,7 @@ protected:
     bool doQuery(const fxStr& queryCmd, fxStr& result, long ms = 30*1000);
 // dial/answer interactions with derived classes
     virtual const AnswerMsg* findAnswer(const char* s);
-    virtual CallType answerResponse(Status& eresult);
+    virtual CallType answerResponse(const fxStr&, Status& eresult);
     virtual CallStatus dialResponse(Status& eresult) = 0;
     virtual bool isNoise(const char*);
 // miscellaneous