Saltar para: Post [1], Comentários [2], Pesquisa e Arquivos [3]
First of all, sorry for posting this in english. Hopefully, I'll post this in portuguese too. I chose english as this might be interesting to a wide community of raspberry pi users out there.
So what's this all about? Really, it's about making good use of an extremely cheap, low powered computer that I got at Codebits last year. I actually replaced a $600 mac mini I had doing all these things before.
My goal was to have a reliable Media Center that could connect to a NAS device (I use Synology DS1511) and play all my videos, photos and MP3.
Also, at home we all have a computer and we all need to print or scan something every once in a while. I could have bought a network printer and scanner but instead I already owned an old Canon Inkjet printer, the PIXMA MP630 which has been doing it's job quite well for years. As it happens, this is a multifunction device and works as a scanner too. What follows is a recipe to have everything working.
You'll need a 4GB SD card and a Mac to start the procedure. Everything else is done on the Raspberry Pi.
You should have some knowledge of working "with black windows full of letters" as my daughter says.
Raspbmc is a debian wheezy distribution optimized for XBMC Media Center. There are some others but for some reason I like this one. Any other debian based should work though.
Open a terminal window on your mac, insert the SD card on a card reader and run these:
$ curl -O http://svn.stmlabs.com/svn/raspbmc/testing/installers/python/install.py
$ chmod +x install.py
$ sudo python install.py
Now follow the on screen instructions.
Insert the card on the Raspberry pi. It will boot and complete the installation. Grab a coffee :)
Go ahead and play a bit with XBMC. It's great. And if you have one of those TVs that support CEC then you can even use your TV remote to navigate on XBMC. I know for a fact that Samsung and Sony TVs work quite well.
Open your terminal and run this:
$ ssh pi@192.168.1.169
it will prompt you for a password. Raspbmc uses the default password "raspberry". I advise you to change it just in case.
Take some time choosing your locale and time zone settings. It will only prompt you once for these.
The network installation of Raspbmc you just did will probably download all the latest packages. However, just to be sure, run these commands:
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install cups
(Grab a coffee. This will take a while)
$ sudo usermod -a -G lpadmin pi
We're adding user "pi" to the lpadmin group. You'll need admin access to add printers.
Now edit cupsd configuration:
$ sudo vi /etc/cups/cupsd.conf
And change Listem localhost:631 to Listen *:631.
Also change or add the following lines. Replace 192.168.1.* with the IP addresses of your network. My network is 192.168.1.0/24
Listen *:631
<Location />
Order allow,deny
Allow 192.168.1.*
</Location>
<Location /printers>
Order allow,deny
Allow 192.168.1.*
</Location>
# Restrict access to the admin pages...
<Location /admin>
Order allow,deny
Allow 192.168.1.*
</Location>
We're telling cups which IPs in the network have access to. If you trust your network and if you're sure there's no access from outside, you can skip editing the file and just enter:
$ sudo cupsctl --remote-admin
$ sudo cupsctl --remote-any
Now you have to restart CUPS
$ sudo /etc/init.d/cups restart
Please note the IP address of your Raspberry Pi. You'll need it later
$ ifconfig eth0 | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}'
On your mac, grab a browser and point it to your Raspberry Pi's IP on port 631. Mine is on 192.168.1.169, so...
https://192.168.1.169:631
Don't worry about the certificate warning. It's self signed so your browser will rightfully warn you about it.
Now click on Administration and then on Add Printer
You should be prompted with a user and password. Of course, use "pi" as the user and "raspberry" as the password (or whatever new password you chose)
You should see a list of local printers. Mine was listed as "Canon MP630 series (Canon MP630 series)"
Press continue, review the information and make sure you check "Share this printer"
Choose a make and model and finally add the printer.
This is where I've seen most people make a mistake so beware. When you add this printer under OSX, the default driver is postscript based. This means the Mac will send a postscript file back to the CUPS server. Now the server has to convert postscript to whatever the printer understands. This is bad. This conversion is both memory and cpu consuming. Printing a page would take up to 10 minutes if you use these settings.
What I did was: I installed the correct driver on OSX as if I had the printer connected locally and used that driver. This means that all processing is done by my computer and the Raspberry Pi only has to forward it to the printer.
In my case, I installed CanonPrinterDrivers from Apple and chose MP 630 Series driver on the printer add dialog.
Printing done! Go ahead and print a few documents. It's fast and has almost no impact on the Raspberry. I actually had a video playing without problems.
While installing CUPS you also installed SANE. So everything should be in place.
To be sure, run this command:
$ scanimage -L
device `pixma:04A9172E_145C70' is a CANON Canon PIXMA MP630 multi-function peripheral
So, SANE identified my device correctly. Actually, if I try:
$ scanimage --format=tiff > ~/myimage.tiff
It works.
But now we need to tell SANE who is allowed to scan from the network.
Grab your editor:
$ sudo vi /etc/sane.d/saned.conf
And simply add this line
192.168.1.0/24
Again, change it to match your network. This means that every IP from 192.168.1.1 to 192.168.1.255 will be able to use the scanner.
Now make sure SANE starts by default. You need to edit another file:
$ sudo vi /etc/default/saned
And change this line to yes
RUN=yes
Now, unfortunatelly, Apple has been shooting itself in the foot as far as network scanning is concerned. With the latest versions (I tried 10.7 and 10.8) you can't make your scanner appear under "Image Capture". However, with a few tweaks you can make things work.
First, you need to install SANE Backends for OSX. There's a nice port here: http://www.ellert.se/twain-sane/
Install libusb and SANE Backends, SANE Preferences Pane in this order
Now you must tell your mac where to search for the scanner.
Edit this file:
$ vi /usr/local/etc/sane.d/net.conf
And add your Raspberry Pi's IP right at the end.
In my case, 192.168.1.169
Now go ahead and see if your mac recognizes the network scanner:
$ scanimage -L
device `net:192.168.1.169:pixma:04A9172E_145C70' is a CANON Canon PIXMA MP630 multi-function peripheral
There! If you're a command-line fan, you can simply use "scanimage"
If you prefer a gui to scanimage, download "snac" from here http://www.wallner.nu/fredrik/software/snac/
It's just a GUI frontend to scanimage but it allows you to scan and save the picture.
I hope this is useful to somebody.
Cheers.