Zaptel
  1. Zaptel
  2. ZAP-103

[patch] FXOTune doesn't properly clear the dialtone before performing tests

    Details

    • Type: Bug Bug
    • Status: Closed
    • Severity: Major Major
    • Resolution: Fixed
    • Component/s: Utilities
    • Labels:
      None
    • SVN Revision Number:
      1033
    • Mantis ID:
      7136
    • Regression:
      No

      Description

      NOTE: I'm marking this as 'major' because the bugs in fxotune prevent users who are experiencing echo from being able to solve their problem. I'm not sure if this really justifies the 'major' categorization, so I'm fine with it being downgraded - but we were right on the edge of abandoning the TDM altogether, and this patch made all the difference.

      FXOTune does not wait after sending the dial string (used to clear the dial tone) before it begins testing. The result is that a good 30-40% of the tests performed wind up measuring output of the dial tone, and not echo response.

      To check this out for yourself, hook a 2x2x2 (or 4x4x4) splitter to the TDM jack, your outside phoneline to one side of the splitter and a telephone to the other side. Run:

      fxotune -i 5

      Wait a couple of seconds, then pick up the telephone. Note that some of the test tones get sent while there is still a dialtone.

      Another way to get at this:
      1. turn fxotune debug on
      2. Change the line that reads:

      for (i = 0; i < 252; i++) {

      so it only runs one channel's worth of tests (otherwise the debug output gets blown away for each channel):

      for (i = 3; i < 3; i++) { // only test channel Zap/4 (i+1 = 3+1 = 4)

      3. recompile
      4. run fxotune -i 5
      5. Get a baseline power level for each frequency and channel
      6. pick up the telephone (from above) and dial '5' to clear the dialtone
      7. immediately run fxotune -i 5
      8. check the baseline power levels for each frequency and note that some of them are completely different, and some are the same

      This patch fixes the above problem by inserting an extra second delay after sending the dial string, and sets the needtoreset counter to a high value to force the dialtone clearing to take place before the first 8 frequencies are run. It also adds a new calibration mode (-i2) and a mode for dumping waveforms (-d). See the 'Additional Information' section for details.

      Once I configured fxotune.conf with the correct settings resulting from these changes and tuning all of the echo coefficients (instead of just the line impedence) using the -i2 option (see 'Additional Information' for the new -i2 option), my echo problem dropped dramatically (60% response to 5% response). The software echo canceller was then able to handle the 5% response, and we now have crystal clear outside lines.

                • ADDITIONAL INFORMATION ******

      Because fxotune appears to be a work in progress, I took the liberty of making a number of other changes as well - if any of these are not appropriate, please let me know. Here's a summary:

      1. Buffer management fixes - the current code has many places where buffer sizes are specified in bytes, but the algorithms are written for shorts.

      2. Changed the power calculation function - the current implementation [(sum of squares) - (square of sums)] doesn't have any documentation about why it is being used. A more general approach to measuring response would be to use simple RMS computations, so I've changed the power computation to RMS.

      3. Multi-tone support - the current implementation sweeps through a series of frequencies, checking the response at each individual frequency. This is not actually necessary - we can create a single wave form that contains those frequencies and run a single test. I've included multi-tone waveform support in the new '-i2' option (see below).

      4. New -i2 option. This option does an exhaustive search of all 64 echo coefficient settings (these are defined in fxotune.h, and came originally from Silicon Laboratories' AN84). In order for this to work, the user must be able to get a dialstring that will result in silence from the switch at their CO - most switches have a number that will do this, it's just a matter of finding it (see the Additional Information notes below).

      Side note: The -i2 test actually has fewer iterations than the -i test, and because we are dialing into a 'silent' line, we don't have the huge time overhead of repeatedly hanging the line up and starting over. It might be possible to do adjust the code to do the -i2 test with the pickup, test 8 times, hangup, etc... test cycle, but there is almost always a number on the switch that can return silence (at least here in the US). If the user is having an echo problem, then taking the time to find that number (and the milliwatt test number) is worth it...

      5. New -d option. This option sends a test tone (or multi-tone waveform) and dumps the input and output buffers to a file. This info can be plotted to see the actual waveform, or run through a fourier transformation to get spectral information (this is how I figured out that some of the test tones in the old code were reading the dial tone instead of echo). It's also really nice to see the response drop from 60% of the input (that's what mine was at) to 5%.

      Sometimes there is no subsitute for visually seeing what's going on (you can kind of think of the -d option as turning the tdm into a telephony oscilloscope - I wouldn't put much faith in phase shift results, but magnitude results are quite handy).

      Some info on finding a phone number at your switch that returns silence:

      In my case, I had to look up the switch info for my area and exchange code, then try a bunch of numbers for other exchange codes also managed by that switch to find it. The following website was most helpful:

      http://www.sandman.com/colookup.asp

      In my case, the magic number was 9996 and it was on a different exchange code than my phone number. For reference, the number at my CO is 602-454-9995 - that number plays a milliwatt test tone for 5 seconds, then flips to silence for the remainder.

      So, I execute my -i2 tuning with the following command:

      fxotune -i2 -1 6024549995 8

      -1 = tell the system to test with a multi-frequency waveform
      6024549995 = my local CO 'silence' phone number
      8 = wait 8 seconds to get the milliwatt tone at the beginning time to go away (if you have a number that doesn't have a milliwatt tone at the beginning, you can probably set this value to 0)

        Activity

        Hide
        Joshua Colp added a comment -

        OKAY: The original issue is fixed in 1.2 zaptel, and I put your new stuff into trunk zaptel. Thanks a lot and peace out all!

        Show
        Joshua Colp added a comment - OKAY: The original issue is fixed in 1.2 zaptel, and I put your new stuff into trunk zaptel. Thanks a lot and peace out all!
        Hide
        Rob added a comment -

        trumpetinc: I think that it would make sense to have the -m parameter required, but setting it to "0" or something if you are calling a silence number at the CO would be important.

        I had vechers re-open the bug so I could make this comment, but any futher discussion should probably take place in the IRC channel (#asterisk-dev) or on the -dev mailing list.

        Thanks again.

        Show
        Rob added a comment - trumpetinc: I think that it would make sense to have the -m parameter required, but setting it to "0" or something if you are calling a silence number at the CO would be important. I had vechers re-open the bug so I could make this comment, but any futher discussion should probably take place in the IRC channel (#asterisk-dev) or on the -dev mailing list. Thanks again.
        Hide
        Digium Subversion added a comment -

        Repository: dahdi
        Revision: 1073

        U branches/1.2/fxotune.c

        ------------------------------------------------------------------------
        r1073 | file | 2008-06-07 11:35:31 -0500 (Sat, 07 Jun 2008) | 2 lines

        Clear dialtone before running tests (issue ZAP-103 reported and fixed by trumpetinc)

        ------------------------------------------------------------------------

        http://svn.digium.com/view/dahdi?view=rev&revision=1073

        Show
        Digium Subversion added a comment - Repository: dahdi Revision: 1073 U branches/1.2/fxotune.c ------------------------------------------------------------------------ r1073 | file | 2008-06-07 11:35:31 -0500 (Sat, 07 Jun 2008) | 2 lines Clear dialtone before running tests (issue ZAP-103 reported and fixed by trumpetinc) ------------------------------------------------------------------------ http://svn.digium.com/view/dahdi?view=rev&revision=1073
        Hide
        Digium Subversion added a comment -

        Repository: dahdi
        Revision: 1074

        _U trunk/

        ------------------------------------------------------------------------
        r1074 | file | 2008-06-07 11:35:59 -0500 (Sat, 07 Jun 2008) | 9 lines

        Blocked revisions 1073 via svnmerge

        ........
        r1073 | file | 2006-05-18 12:40:14 -0300 (Thu, 18 May 2006) | 2 lines

        Clear dialtone before running tests (issue ZAP-103 reported and fixed by trumpetinc)

        ........

        ------------------------------------------------------------------------

        http://svn.digium.com/view/dahdi?view=rev&revision=1074

        Show
        Digium Subversion added a comment - Repository: dahdi Revision: 1074 _U trunk/ ------------------------------------------------------------------------ r1074 | file | 2008-06-07 11:35:59 -0500 (Sat, 07 Jun 2008) | 9 lines Blocked revisions 1073 via svnmerge ........ r1073 | file | 2006-05-18 12:40:14 -0300 (Thu, 18 May 2006) | 2 lines Clear dialtone before running tests (issue ZAP-103 reported and fixed by trumpetinc) ........ ------------------------------------------------------------------------ http://svn.digium.com/view/dahdi?view=rev&revision=1074
        Hide
        Digium Subversion added a comment -

        Repository: dahdi
        Revision: 1075

        U trunk/fxotune.c

        ------------------------------------------------------------------------
        r1075 | file | 2008-06-07 11:36:16 -0500 (Sat, 07 Jun 2008) | 2 lines

        Majorly improve fxotune with lots of cool new features. (issue ZAP-103 reported and created by trumpetinc)

        ------------------------------------------------------------------------

        http://svn.digium.com/view/dahdi?view=rev&revision=1075

        Show
        Digium Subversion added a comment - Repository: dahdi Revision: 1075 U trunk/fxotune.c ------------------------------------------------------------------------ r1075 | file | 2008-06-07 11:36:16 -0500 (Sat, 07 Jun 2008) | 2 lines Majorly improve fxotune with lots of cool new features. (issue ZAP-103 reported and created by trumpetinc) ------------------------------------------------------------------------ http://svn.digium.com/view/dahdi?view=rev&revision=1075

          People

          • Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development