login | register
Sat 04 of Jul, 2009 [05:20 UTC]

voip-info.org

History

app_rxfax and app_txfax

Created by: pupeno,Last modification on Mon 09 of Feb, 2009 [13:24 UTC] by olivier2831

app_rxfax and app_txfax


app_rxfax and app_txfax are two Asterisk applications to send and receive faxes. They are simple interfaces to Steve Underwood's spandsp library, which does the real work. Up to date versions may be obtained from http://sf.net/projects/agx-ast-addons.
Using svn to download is recommended as tarballs from Sourceforge repository are not in sync.

They consist of three files app_rxfax, app_txfax and apps_makefile.patch which you should put on your Asterisk's source code directory and apply the patch (which may or may not work according to the current state of Asterisk). For more directions consult http://soft-switch.org/installing-spandsp.html which explains how to install spandsp and then app_rxfax and app_txfax.

There's an application called astfax that can use app_txfax to create a mail-to-fax gateway.

app_rxfax and app_txfax is distributed next to spandsp (but not in the same tarball). The latest version is on http://www.soft-switch.org/downloads/snapshots/spandsp/ inside the directory 'test-apps-asterisk-1.2' and 'test-apps-asterisk-1.4'.

AGX Extra Addons for Asterisk contains enhanced version of app_rxfax and app_txfax for 1.4.
Download it with : svn co https://agx-ast-addons.svn.sourceforge.net/svnroot/agx-ast-addons agx-ast-addons

Sending (txfax)

If the variable LOCALHEADERINFO has been set when txfax is run, the value of that variable will be used as the user defined part of the header text. The page number, date and time, and calling FAX ID will be filled in by the software to make a complete header line, of the kind produced by most FAX machines.

If the variable LOCALSTATIONID has been set when txfax is run, the value of that variable will be used to identify itself to the remote fax machine.


exten => _X.,1,SetVar(FAXFILE=/var/spool/asterisk/fax/mydocument.tif)
exten => _X.,2,SetVar(LOCALHEADERINFO=Company name and department)
exten => _X.,3,SetVar(LOCALSTATIONID=Company name)
exten => _X.,4,txfax(${FAXFILE}|caller)



Document format

When sending a fax you need to use a tiffg3 document, to convert a document to tiffg3 you can use ghostscript with this command:

/usr/bin/gs -q -sDEVICE=tiffg3 -sPAPERSIZE=a4 -r204x196 -dNOPAUSE -sOutputFile=/var/spool/asterisk/outgoing/mydocument.tif -- /var/spool/asterisk/outgoing/mydocument.pdf


If you can't get Asterisk to recognize an incoming call as a fax, check the wiring of your jacks. Reversed wires in an RJ-11 jack prevented Asterisk from recognizing the fax polling tones and caused the server to dump the call into a regular extension instead of recognizing it as a fax




See also


Comments

Comments Filter
222

333Problem with rxfax && post receipt printing

by ksmithaz1, Wednesday 09 of April, 2008 [16:54:48 UTC]
asterisk-1.4.17
spandsp-0.0.4-pre18
agx-ast-addons-1.4.5
zaptel-1.4.9.2
libpri-1.4.3
asterisk-addons-1.4.6

Compiled && installed w/o issue

This USED to work w/1.2 && older versions of rxfax:

[co2]
exten => s,1,NoOp(Inbound Call)
exten => s,2,NoOp(CALLERID=${CALLERID})
exten => s,3,Set(_menu=menu-000)
exten => s,4,Goto(fax,90)

; Queue and print
exten => fax,90,Set(FAXFILE=/var/spool/asterisk-fax/${UNIQUEID}.tif)
exten => fax,91,rxfax(${FAXFILE})
exten => fax,92,NoOp(REMOTESTATIONID ${REMOTESTATIONID})
exten => fax,93,NoOp(FAXPAGES ${FAXPAGES})
exten => fax,94,NoOp(FAXBITRATE ${FAXBITRATE})
exten => fax,95,NoOp(FAXRESOLUTION ${FAXRESOLUTION})
exten => fax,96,System(/usr/local/bin/printfax -p ${FAXPAGES} -r ${FAXRESOLUTION} ${FAXFILE})
exten => fax,97,NoOP(Fax Complete)
exten => fax,98,NoOP
exten => fax,99,Hangup


Now When the fax is done I don't get the printfax to run . . . (from the log):

[Apr  9 11:51:44] VERBOSE[12856] logger.c: [Apr  9 11:51:44]     -- Starting simple switch on 'Zap/4-1'
[Apr  9 11:51:45] VERBOSE[12856] logger.c: [Apr  9 11:51:45]     -- Executing [s@co2:1] NoOp("Zap/4-1", "Inbound
 Call") in new stack
[Apr  9 11:51:45] VERBOSE[12856] logger.c: [Apr  9 11:51:45]     -- Executing [s@co2:2] NoOp("Zap/4-1", "CALLERI
D=") in new stack
[Apr  9 11:51:45] VERBOSE[12856] logger.c: [Apr  9 11:51:45]     -- Executing [s@co2:3] Set("Zap/4-1", "_menu=me
nu-000") in new stack
[Apr  9 11:51:45] VERBOSE[12856] logger.c: [Apr  9 11:51:45]     -- Executing [s@co2:4] Goto("Zap/4-1", "fax|90"
) in new stack
[Apr  9 11:51:45] VERBOSE[12856] logger.c: [Apr  9 11:51:45]     -- Goto (co2,fax,90)
[Apr  9 11:51:45] VERBOSE[12856] logger.c: [Apr  9 11:51:45]     -- Executing [fax@co2:90] Set("Zap/4-1", "FAXFI
LE=/var/spool/asterisk-fax/1207756304.353.tif") in new stack
[Apr  9 11:51:45] VERBOSE[12856] logger.c: [Apr  9 11:51:45]     -- Executing [fax@co2:91] RxFAX("Zap/4-1", "/va
r/spool/asterisk-fax/1207756304.353.tif") in new stack
[Apr  9 11:51:45] DEBUG[12856] chan_zap.c: Took Zap/4-1 off hook
[Apr  9 11:51:45] DEBUG[12856] chan_zap.c: Engaged echo training on channel 4
. . . <blah,blah>
[Apr  9 11:52:56] DEBUG[12856] /usr/src/asterisk/agx-ast-addons/app_rxfax.c: Fax successfully received.
[Apr  9 11:52:56] DEBUG[12856] /usr/src/asterisk/agx-ast-addons/app_rxfax.c: Remote station id: 
[Apr  9 11:52:56] DEBUG[12856] /usr/src/asterisk/agx-ast-addons/app_rxfax.c: Local station id:  
[Apr  9 11:52:56] DEBUG[12856] /usr/src/asterisk/agx-ast-addons/app_rxfax.c: Pages transferred: 4
[Apr  9 11:52:56] DEBUG[12856] /usr/src/asterisk/agx-ast-addons/app_rxfax.c: Image resolution:  8031 x 3850
[Apr  9 11:52:56] DEBUG[12856] /usr/src/asterisk/agx-ast-addons/app_rxfax.c: Transfer Rate:     14400
[Apr  9 11:52:56] DEBUG[12856] /usr/src/asterisk/agx-ast-addons/app_rxfax.c: ===================================
===========================================
[Apr  9 11:52:58] DEBUG[12856] /usr/src/asterisk/agx-ast-addons/app_rxfax.c: Got hangup
[Apr  9 11:52:58] VERBOSE[12856] logger.c: [Apr  9 11:52:58]     -- Hungup 'Zap/4-1'
[Apr  9 12:04:40] VERBOSE[12857] logger.c: [Apr  9 12:04:40]     -- Starting simple switch on 'Zap/4-1'

PHHHT. Huk!


From an older log:
[Oct 11 10:09:14] DEBUG[4959]: Fax successfully received.
[Oct 11 10:09:14] DEBUG[4959]: Remote station id: Mortgage Services   
[Oct 11 10:09:14] DEBUG[4959]: Local station id:  
[Oct 11 10:09:14] DEBUG[4959]: Pages transferred: 1
[Oct 11 10:09:14] DEBUG[4959]: Image resolution:  7700 x 3850
[Oct 11 10:09:14] DEBUG[4959]: Transfer Rate:     9600
[Oct 11 10:09:14] DEBUG[4959]: ==============================================================================
[Oct 11 10:09:14] VERBOSE[4959]: [Oct 11 10:09:14]     -- Executing NoOp("Zap/4-1", "REMOTESTATIONID Mortgage Se
rvices   ") in new stack
[Oct 11 10:09:14] VERBOSE[4959]: [Oct 11 10:09:14]     -- Executing NoOp("Zap/4-1", "FAXPAGES 1") in new stack
[Oct 11 10:09:14] VERBOSE[4959]: [Oct 11 10:09:14]     -- Executing NoOp("Zap/4-1", "FAXBITRATE 9600") in new st
ack
[Oct 11 10:09:14] VERBOSE[4959]: [Oct 11 10:09:14]     -- Executing NoOp("Zap/4-1", "FAXRESOLUTION 3850") in new
 stack
[Oct 11 10:09:14] VERBOSE[4959]: [Oct 11 10:09:14]     -- Executing System("Zap/4-1", "/usr/local/bin/printfax -
p 1 -r 3850 /var/spool/asterisk-fax/1192111704.363.tif") in new stack
[Oct 11 10:09:14] VERBOSE[4959]: [Oct 11 10:09:14]     -- Executing NoOp("Zap/4-1", "Fax Complete") in new stack
[Oct 11 10:09:14] VERBOSE[4959]: [Oct 11 10:09:14]     -- Executing NoOp("Zap/4-1", "") in new stack
[Oct 11 10:09:14] VERBOSE[4959]: [Oct 11 10:09:14]     -- Executing Hangup("Zap/4-1", "") in new stack
[Oct 11 10:09:14] VERBOSE[4959]: [Oct 11 10:09:14]   == Spawn extension (co2, fax, 99) exited non-zero on 'Zap/4
-1'


I'm at a loss, I can think of a few work-arounds, but this must have something to do with a change in asterisk on a hangup. Processing stops now? Perhaps an explicit off-hook is needed. Any insight useful.
222

333Newer information

by pcrane, Wednesday 05 of March, 2008 [11:40:10 UTC]
There is a newer package with installation instructions. I've never had any success with the instructions on this page with the latest versions of asterisk (>=1.4). If you don't have any luck with this stuff try AGX's Asterisk Extra AddOns instead and ignore the instructions above.
222

333Rxfax keeps the channel up

by cyrenity, Wednesday 12 of September, 2007 [20:16:11 UTC]
i have followed Ray step-by-step, installation is okay. i can see rxfax/txfax in show applications.

but the problem is really strange, i can receive fax successfully but rxfax keeps the channel up forever untill i softhangup the channel. here is the output
softswitch-vas*CLI> show channels verbose
Channel Context Extension Prio State Application Data CallerID Duration Accountcode BridgedTo
Zap/3-1 fax s 3 Up RxFAX /var/spool/asterisk/fax/1 0212792161 00:16:44 (None)
1 active channel
1 active call

output from /var/log/asterisk/full:

Sep 12 15:00:47 DEBUG2499 app_rxfax.c: ===========================================================================
Sep 12 15:00:49 DEBUG2499 app_rxfax.c:
========================================================================
Sep 12 15:00:49 DEBUG2499 app_rxfax.c: Fax successfully received.
Sep 12 15:00:49 DEBUG2499 app_rxfax.c: Remote station id: 2792161
Sep 12 15:00:49 DEBUG2499 app_rxfax.c: Local station id:
Sep 12 15:00:49 DEBUG2499 app_rxfax.c: Pages transferred: 1
Sep 12 15:00:49 DEBUG2499 app_rxfax.c: Image resolution: 8037 x 3850
Sep 12 15:00:49 DEBUG2499 app_rxfax.c: Transfer Rate: 9600
Sep 12 15:00:49 DEBUG2499 app_rxfax.c:
===========================================================================


any idea why rxfax keeps running.
regards

222

333destination number

by rlins10, Thursday 30 of August, 2007 [14:33:09 UTC]
Where do I put the FAX DESTINATION NUMBER ?

ext-test-custom
exten => 667,1,Goto(ext-fax,out_fax,1)

ext-fax
exten => s,1,Answer
exten => s,2,Goto(in_fax,1)
exten => in_fax,1,StopPlayTones
exten => in_fax,2,GotoIf($"${FAX_RX}" = "system"?3:analog_fax,1)
exten => in_fax,3,Macro(faxreceive)
exten => in_fax,4,system(/var/lib/asterisk/bin/fax-process.pl --to ${EMAILADDR} --from ${FAX_RX_FROM} --subject "Recebendo Fax de ${CALLERID(number)} ${CALLERID(name)}" --attachment ${CALLERID(number)}.pdf --type application/pdf --file ${FAXFILE});
exten => in_fax,5,Hangup
exten => analog_fax,1,GotoIf($"${FAX_RX}" = "disabled"?4:2) ;if fax is disabled, just hang up
exten => analog_fax,2,Set(DIAL=${DB(DEVICE/${FAX_RX}/dial)});
exten => analog_fax,3,Dial(${DIAL},20,d)
exten => analog_fax,4,Hangup
;appexten => out_fax,1,wait(7)
exten => out_fax,1,Answer()
exten => out_fax,2,AbsoluteTimeout(35)
exten => out_fax,3,SetVar(FAXFILE=/home/fax/mydocument.tif)
exten => out_fax,4,SetVar(LOCALHEADERINFO=company)
exten => out_fax,5,SetVar(LOCALSTATIONID=company)
exten => out_fax,6,txfax(${TXFAX_NAME}|caller)
exten => out_fax,7,Hangup
exten => h,1,Hangup()

222

333Asterisk 1.4.4, spandsp 0.0.3

by cibi, Wednesday 04 of July, 2007 [18:32:23 UTC]
And another experience:
Asterisk 1.4.4, spandsp 0.0.3, Debian 4.0 etch, libtiff, autconf (2.61-4) and automake from the standard Debian 4.0 archive.

Don't remember how exactly i compiled spandsp, but for Asterisk 1.4.2 and Asterisk 1.4.4, i didn't do autconf in
autoconf
./bootstrap.sh
./configure
make menuselect
just boststrap.sh in a FRESH unzipped asterisk-1.4.x dir was enough.
I use the app-r/tx.c files from January 2007, the latest are from June 2007, haven't tested them.
If you have problems, also check, if app_t/rxfax.so are linked against libspandsp and libtiff (with ldd apps/app_rxfax.so)

Edit /BTW: Haven't had the problem that Leonardo reported.

222

333rxfax and txfax with Asterisk 1.4.4

by leo_lns, Friday 18 of May, 2007 [02:41:25 UTC]
First of all, thanks Ray Collett for the tips.

I've compiled it exactly as Ray's comment below, but with a bit difference when re-creating the Makefile with bootstrap.sh

I'm using:
Asterisk 1.4.4
SpanDSP 0.0.3: http://www.soft-switch.org/downloads/spandsp/spandsp-0.0.3.tgz

Hint: The autoconf 2.6 or above and automake are essentially.

Do the same things that Ray said below, then after run ./bootstrap.sh, it re-creates the configure file, but it merge the SPEEX and SPANDSP session incorrectly. So, open the configure, find the SPANDSP session (below the RADIUS), then remove everything from SPANDSP and SPEEX (there are lot of things repeated). The clean code is this:

SPANDSP_DESCRIP="spandsp Library"
SPANDSP_OPTION="spandsp"

if test "${with_spandsp+set}" = set; then
 withval=$with_spandsp;
case ${withval} in
    n|no)
    USE_SPANDSP=no
    ;;
    y|ye|yes)
    SPANDSP_MANDATORY="yes"
    ;;
    *)
    SPANDSP_DIR="${withval}"
    SPANDSP_MANDATORY="yes"
    ;;
esac

fi

PBX_SPANDSP=0





SPEEX_DESCRIP="Speex"
SPEEX_OPTION="speex"

if test "${with_speex+set}" = set; then
 withval=$with_speex;
case ${withval} in
    n|no)
    USE_SPEEX=no
    ;;
    y|ye|yes)
    SPEEX_MANDATORY="yes"
    ;;
    *)
    SPEEX_DIR="${withval}"
    SPEEX_MANDATORY="yes"
    ;;
esac

fi

PBX_SPEEX=0


Now just continue with ./configure and the next steps.
222

333Re: rxfax and txfax with Asterisk 1.4.2

by ojaksch, Tuesday 24 of April, 2007 [11:26:20 UTC]
Ray, did you tested sending/receiving a fax?
I followed your instructions; compiling was ok, but when invoking rxfax asterisk instantly dies...
222

333rxfax and txfax with Asterisk 1.4.2

by rcollett, Tuesday 24 of April, 2007 [00:19:54 UTC]
I spent about 5 hours today trying to get this all to work. Here is the process that I used to get it to install:<BR>
(using an older Fedora 3 i686 system)<BR><BR>

wget http://ftp.digium.com/pub/asterisk/releases/asterisk-1.4.2.tar.gz<BR>
wget http://www.soft-switch.org/downloads/snapshots/spandsp/spandsp-20070413.tar.gz<BR>
wget http://www.soft-switch.org/downloads/snapshots/spandsp/test-apps-asterisk-1.4/app_rxfax.c<BR>
wget http://www.soft-switch.org/downloads/snapshots/spandsp/test-apps-asterisk-1.4/app_txfax.c<BR>
wget http://www.soft-switch.org/downloads/snapshots/spandsp/test-apps-asterisk-1.4/asterisk.patch<BR><BR>

tar -zxvf spandsp-20070413.tar.gz<BR>
cd spandsp-0.0.4<BR>
make uninstall<BR>
make clean<BR>
autoconf<BR>
./configure<BR>
make<BR>
make install<BR><BR>

tar -zxvf asterisk-1.4.2.tar.gz<BR>
cd asterisk-1.4.2<BR>
cp ../asterisk.patch .<BR>
cp ../app_rxfax.c apps/<BR>
cp ../app_txfax.c apps/<BR><BR>

(at this point, you SHOULD be able to do "patch -bp0 < asterisk.patch", but the patch is partially broken. Look at the asterisk.patch and you'll see several different sections where the patch looks for one block of text in a certain file, then inserts the lines that starts with the "+". You need to manually add the lines with the "+" character into the spots that the patch file point to. Remember to remove the "+" from the beginning of the line.)<BR><BR>

cp /usr/local/include/spandsp/plc.h include/asterisk/plc.h<BR><BR>

(I had to copy the plc.h that was installed from the spandsp into the asterisk folder to get around some error messages)<BR><BR>

make clean<BR>
autoconf<BR>
./bootstrap.sh<BR>
./configure<BR>
make menuselect<BR><BR>

(at this point, check to see if the app_txfax and app_rxfax are selected. It should not be marked as unavailable, ie., no XXX's)<BR><BR>

make<BR>
make install<BR><BR>

If it compiles without error, If it does not coredump when you run asterisk, you should be able to see usage information from the console by running these commands:<BR>
core show application RxFax<BR>
core show application TxFax<BR><BR>

I had to manually upgrade my autoconf, because there are no RPM's for autoconf 2.6 or newer.<BR><BR>

Ray

222

333State consult

by highwayman, Wednesday 07 of March, 2007 [08:56:29 UTC]
Here there is another patch, but for different purposes. This patch allows to consult the successfully state of the transmitted fax, the status is show in the variable "RESULTADO". To apply the patch:

  1. patch app_txfax.c < app_txfax.patch

The complete post is here.</p>
222

333rxfax and txfax vs. Asterisk 1.4

by ChicagoBud, Wednesday 21 of February, 2007 [17:45:27 UTC]
OK. To answer my own question, I found an updated app_rxfax.c, app_txfax.c and a patch file for asterisk 1.4 in http://www.soft-switch.org/downloads/snapshots/spandsp/test-apps-asterisk-1.4. The patch must be for a beta of 1.4 as it didn't quite work (patch -p0) but it was easy enough to figure out how to fix the issues. Then I did a ./configure; make; make install and the modules were copied to /usr/lib/asterisk/modules. Note that the patch does not attempt to patch menuselect so there is no fax entry when you do a make menuselect.