Wednesday, April 27, 2011

cups - brother mfc-8840d

Links:  Openprinting.org (Printing)      Sane project (Scanning)    Brother (manufacturer)

pt1: printing

A friend has an older Brother printer, the MFC-8840D (device code 04f9:0160), an all-in-one copy-print-fax machine. He mentioned that the machine is reachable via its USB port or via a built-in WiFi card, but neither were apparently operating consistently with his XP box. It piqued my interest because I hadn't previously configured a WiFi printer w/Linux. The MFC8840D seemed like a good place to start -- Openprinting.org noted it has "excellent" performance with Linux.
1. Accordingly, began at Openprinting.org and retrieved the ppd file. Renamed the file "brothermfc8840d.ppd" for ease of use and copied it into /usr/share/cups/model. CUPS locates printer information files in that directory.

2. In order to use lpadmin, turned-on CUPS:
# service start cups
Added the printer:
# lpadmin -p Brother -E -v socket://192.168.1.101/printer -m brothermfc8840.ppd
Printer installed and the /etc/cups/printers.conf file was properly generated. Only remaining task was to retrieve the HOSTNAME and TCP/IP info from the printer and update /etc/cups/printers.conf in a text editor with this info.

3. Walked to printer to retreive info but, ah-hah!, it turned out there was no WiFi in the Brother MFC-8840D. The networking capacity my friend apparently hoped was WiFi is only Ethernet. The printer has 3 ports: USB, Ethernet, and parallel. I went ahead and completed the install using USB so my buddy could determine whether his previous printing problems were in XP or the printer itself.

4. Turned the printer on and connected the USB cable to my laptop, running # udevmonitor to get the port name "/usb/lp0". I then opened /etc/cups/printers.conf and changed the URI to a USB connection:
# cat /etc/cups/printers.conf
# Printer configuration file for CUPS v1.3.9
# Written by cupsd on 2011-04-27 23:00
<Printer Brother>
Info Brother
DeviceURI file:///dev/usb/lp0
State Idle
StateTime 1303970446
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy stop-printer
</Printer>

5. Restarted CUPS so that CUPS re-read the printers.conf file with the updated USB information:
# service restart cups
Prints without any apparent problems. Installation time: 10 minutes. Did not initialize or verify the printer's scanner operation.

pt2: scanning

Links: Howto w/scripts   Howto w/scripts   Gentoo Howto

Looked through the SANE database and noted Linux compatibility with the MFC-8840D is listed as "good". That said, a person can go with a simple or a very involved scanner installation. Below, I include both but break it into two parts. For simple scanning using the Xsane GUI, the simple installation will do. For OCR, specialized file handling, and so forth (all of this is possible), a complete install may be necessary. Before I start on these, some checks and the procedures which apply to both a simple of full install are provided.

Checks  The scanner portion of the Brother can be difficult for the system to detect. These checks provide confirmation of detection and useful information during any stage of the installation. Use freely:
$ scanimage --test
$ scanimage - L
$ brscan-skey -l
$ sane-find-scanner
Necessary  
  • Verify "brother" is in the list in the /etc/sane.d/dll file. If it is not, add it.
  • The sane configuration directory must have a "brother.conf". Check with ls /etc/sane.d/. If there is no brother.conf, make one. Get the printer device number using $ sane-find-scanner and then make the file:
# nano /etc/sane.d/brother.conf
usb 0x4f9 0x16e
option connect-device

Preference: I run programs as "user", not "root", so I changed the permissions for this device by simply moving it into my user-level 'lp' (printer) group. First found the device in my rules:
# cat /etc/udev/rules.d/30-scanners.rules |grep "Brother MFC-8840"
# Brother MFC-8840D
Second, went to line 915 and changed permissions and groups. Before the changes:

ATTRS{idVendor}=="04f9", ATTRS{idProduct}=="0160", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"
After changes:
ATTRS{idVendor}=="04f9", ATTRS{idProduct}=="0160", MODE="0666", GROUP="lp", ENV{libsane_matched}="yes"
With these in place, moved on to the software.

A. Simple Installation ~ 10 minutes

A1. Proprietary Brother scanning software. This is supposedly freely available at the Brother site. The Brother site maintains only .rpm/.deb files. I run Slackware, so I used rpm2tgz to convert and then installpkg:

$ cd downloads
$ rpm2tgz brscan*
$ mkdir brscan
$ cp brscan-0.2.4-0.i386.tgz /brscan
$ cd brscan
$ su
# installpkg brscan-0.2.4-0.i386.tgz
# exit
$ brsaneconfig (it works)
A2.Check scanner operation:
$ scanimage --test
A3. Open XSane in the menu and scan sh*t.

B. Full Installation ~ 8 hrs

B1. Install the 32 bit brscan.

$ cd downloads
$ rpm2tgz brscan*
$ mkdir brscan
$ cp brscan-0.2.4-0.i386.tgz /brscan
$ cd brscan
$ su
# installpkg brscan-0.2.4-0.i386.tgz
# exit
$ brsaneconfig (it works)
B2. Install the 32 bit brscan-skey.

$ cd downloads
$ rpm2tgz brscan-skey*
$ mkdir brscan
$ cp brscan-skey-0.2.1-3.i386.tgz /brscan
$ cd brscan
$ su
# installpkg brscan-skey-0.2.1-3.i386.tgz
# exit
$ brscan-skey (it works)

B3. Check it:
$ brscan-skey -l
MFC-8840D : brother:bus6;dev1 : USB Not registered
$ sane-find-scanner
found USB scanner (vendor=0x04f9, product=0x0160) at libusb:002:003
$ scanimage -L
device `brother:bus5;dev1' is a Brother MFC-8840D USB scanner
B4. At this point, the scanner scanned just fine, but the jpg was not saved and I was getting the error message:
ERROR: No such file or directory [/usr/local/Brother/sane/brscan-skey-0.2.1-3.cfg]
B5. Must therefor create the file /usr/local/Brother/sane/brscan-skey-0.2.1-3.cfg
# nano /usr/local/Brother/sane/brscan-skey-0.2.1-3.cfg
password=
IMAGE="sh /usr/local/Brother/sane/script/scantoimage-0.2.1-3.sh"
OCR="sh /usr/local/Brother/sane/script/scantoocr-0.2.1-3.sh"
EMAIL="sh /usr/local/Brother/sane/script/scantoemail-0.2.1-3.sh"
FILE="sh /usr/local/Brother/sane/script/scantofile-0.2.1-3.sh"
SEMID=b

B6. Must then create a script for each desired function. This site has samples of all of them. There are limitless tweaks for file size, OCR use, etc etc etc. Can go crazy with this -- the scripts are entirely configurable for nearly any function.

pt3: faxing

No phone available here, but this appears relatively straightforward and the software is likewise available at the Brother site.