NOTE: This is an archive of my old blog. Go to http://gonium.net for my current website.

Sending Faxes from my Router

Posted by md on September 11, 2010

Faxes are an rather old method for communication, but in Germany they have one advantage: as opposed to emails, faxes are legally binding in the same way as letters are. So, from time to time, sending out a fax is useful. In addition, I have a telephone flatrate included in my data plan, so I don’t have to pay the postage for letters any more. The plan: use the USB port on my router to attach a modem and send out faxes using the mgetty package.

For 3 Euro I acquired an old ELSA Microlink 56k USB modem. I did some research, this modem is one of the few ones supported by the Linux usb-cdc kernel drivers. In addition it can be powered from USB only, so I don’t need another power supply. A week after winning an auction on ebay it arrived today.

My router runs OpenWRT. I installed the following packages using the opkg system:

kmod-usb2
kmod-usb-uhci
kmod-usb-net
kmod-usb-core
kmod-usb-acm
mgetty

mgetty contains a program called “sendfax”, which can be used to dial a number and send the data. The latter needs to be in G3 format. Since I write all my letters using LaTeX, I integrated a “fax” target into my Makefile for LaTeX documents. This target reads the PDF output of LaTeX and converts it to G3 using Ghostscript. The essential command is:

gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=dfaxhigh -sOutputFile=fax.g3.%d -q main.pdf

This creates a bunch of fax.g3.* files, one for each page within the PDF file. Then, I simply copy these files to my router and issue the sendfax command, for example:

sendfax #fax number# fax.g3.1 fax.g3.2

The command dials the fax number and sends the specified g3 files:

root@nibbler:~# sendfax 032121xyzxyz fax.g3.1 fax.g3.2
Trying fax device '/dev/ttyACM0'... OK.
Dialing 032121xyzxyz... OK.
sending 'fax.g3.1'...
sending 'fax.g3.2'...

If an error occurs, the command will fail and tell you about it. The mgetty package also contains various scripts for building a fax spooler, but for my personal usage, I will stick to raw sendfax. Please note that it is also possible to receive faxes, but I did not install these components so far.

No more postage for me. Yay!

Picture: CC-BY-SA-NC vtengr4047, thanks!