Showing posts with label cups. Show all posts
Showing posts with label cups. Show all posts

Saturday, June 30, 2012

iPrint: Printing from iPhone to Ubuntu 10.04 Brother MFC 210c printer


So, there was a need to print something at home. Needless to say, this could've been done from either the Windows Vista laptop or Ubuntu desktop, or the Mac Book Pro. But since there were iPhones and iPads also in the mix, the challenge was to print the email directly from the palm of my hand (the Palm WebOS device is being obsoleted, much to my chagrin).


The curious fact is, I never felt motivated enough to do this for the WebOS device, though it must've been entirely possible. Oh well, I guess that's an argument in favor of market share and ecosystems.

But I digress. So, with a little bit of web searching, I came across the following excellent posts that allowed me to get started, and then with a little bit of tinkering, I managed to print from the iPhone. Yay!


Setup:

a) Brother MFC 210C connected to
b) 2.4 GHz P4 dual core with HT tower running Ubuntu 10.04, connected to the rest of the home network via
c) Linksys WRT54G running DD-WRT in bridge mode
d) iOS devices supporting print option (iPhone 4S) connected to the network via WiFi


I already had cups installed and setup and the printer working. The printer is also shared via Samba so that the win machines can get to it. This made life simpler in some measure.



bash# dpkg -s cups | grep Status

Status: install ok installed
I had to install a pdf filter:
bash# sudo apt-get install cups-PDF
I also had the avahi-daemon up and running
bash# dpkg -s Avahi-daemon | grep Status
Status: install ok installed


Modify cups settings as below:



bash# sudo vi /etc/cups/cupsd.conf


Add the line

ServerAlias *

Change the following lines:

Port Localhost:631 to Port 631
BrowseAllow to BrowseAllow All



Downloaded the excellent python script for generating the Avahi configuration scripts



bash# cd ~/temp
bash# wget https://raw.github.com/tjfontaine/airprint-generate/9d329cfc319e9d7c2eca53192411bf746a7b73d1/airprint-generate.py



run the script


bash# python airprint-generate.py

copy the generated file to avahi daemon settings


bash# sudo cp AirPrint-MFC210C.service /etc/avahi/services/


restart services
bash# sudo /etc/init.d/cups restart

bash# sudo restart avahi-daemon



At this point, I was able to see the Printer, but when I tried to print to it, nothing happened.

Time to play with Ubuntu CUPS settings.


6. Point browser to http://localhost:631, ensure that the following settings are set:

“Save debugging information for troubleshooting”.
Click “Change settings”
Click “View Error Log”
I saw the following errors:
E [24/Feb/2012:00:27:44 -0800] Unable to remove temporary file "/var/spool/cups/tmp/.fontconfig" - Is a directory
E [24/Feb/2012:00:27:44 -0800] Unable to remove temporary file "/var/spool/cups/tmp/.hplip" - Is a directory
These files are owned by “lp”, so to delete them
bash# sudo su lp
bash# pushd /var/spool/cups/tmp
bash# rm –fr .hplip .fontconfig
Ensure that cups settings match below (“Show printers…”)

Click change settings
Print from iPhone!

Note that this will overwrite the earlier generate cupsd conf file. The settings will remain the same, only that the format would probably change.
KNOWN ISSUES
Need to keep restarting avahi daemon
sudo restart avahi-daemon
I haven’t looked in to why this is happening, but I can print for the time being!

References:
Confounded Technology's excellent post
Awesome airprint config file generating script that tjfontaine authored
CUPS printing basics and background
Ryan Finne's original work that kick-started all of this

Tuesday, July 21, 2009

Printing in Ubuntu

I had my linux laptop printing to my Brother MFC-210c printer, but since i've changed laptops and now finally got a dedicated linux machine, I wanted to setup a print server. First things first, get the printer to work with CUPS.

Followed instructions from this website:
http://ubuntuforums.org/showthread.php?t=590793

Also very useful was Brother's linux support site (very happy that they're doing this! my next printer is probably going to be Brother too when this one fails!)

*http://solutions.brother.com/linux/en_us/index.html


*http://solutions.brother.com/linux/en_us/instruction_prn1a.html#dpkg1



machine arch: intel p4 HT running ubuntu 8.10

(repeated below for local record)

* install tcsh:


sudo apt-get install tcsh


* download lpd and cups drivers (.dep packages)
from here and here



cd ~/temp/brother-driver
sudo mkdir /var/spool/lpd
sudo dpkg -i --force-all --force-architecture mfc210clpr-1.0.2-1.i386.deb
sudo mkdir /usr/share/cups/model
sudo dpkg -i --force-all cupswrapperMFC210C-1.0.2-3.i386.deb


NB: replace above .deb package with appropriate ones if things change later.

check if the drivers were correctly installed:

dpkg -l | grep --ignore-case brother


The above should generate an output that looks like below:

ii brscan2 0.2.4 Brother Scanner Driver
ii cupswrappermfc210c 1.0.2-3 Brother MFC210C CUPS wrapper driver
ii mfc210clpr 1.0.2-1 Brother lpr Inkjet Printer Definitions


At this point, i was ready to print a test page. However going to System | Administration | Printing showed me two Brother MFC-210C printers. One was listed as a "text only printer", which I simply deleted (because it wasn't working to begin with). Check on the remaining icon that it is listed as "Brother MFC-210C CUPS v1.1" (right click, select Properties).

Print a test page!

Next step, getting the printer shared so that windows machines can print to it.

This needs samba installed and working, which i'm assuming is already done. if not, there's another page on this blog that should help you get up and running.

The following howto page is helpful

http://tldp.org/HOWTO/Debian-and-Windows-Shared-Printing/sharing_with_windows.html

However, these throw open the system to all, so i decided to make some modifications


cd /etc/samba
sudo vi /etc/samba/smb.conf.master


add / modify the following section

[printers]
comment = All Printers
browseable = yes
path = /var/spool/samba
printable = yes
guest ok = no
read only = yes
create mask = 0700
use client driver = yes



restart samba

sudo testparm -s smb.conf.master > smb.conf
sudo /etc/init.d/samba restart


Modify cups files

Windows printer drivers format their output for the printer before sending it across the network. You must configure CUPS to accept the pre-formatted output by uncommenting the following line from


sudo vi /etc/cups/mime.convs



application/octet-stream application/vnd.cups-raw 0 -

Also uncomment the following line from

sudo /etc/cups/mime.types


application/octet-stream

Now CUPS must be told to allow connections from other machines on the network. Add these lines to /etc/cups/cupsd.conf:



AuthType None
Order Deny,Allow
Deny From All
Allow From 192.168.1.*/255.255.255.0




This allows only machines on the local network to access the cups driver.

restart the cups daemon

sudo /etc/init.d/cups restart