March 11, 2023

Raspberry/Linux print server Windows/Apple, CUPS

Updated 2023-03-12 !

When we upgraded our WiFi to a Mesh solution, TP-link Deco M9, our old printer, WiFi connected, didn't want to "play" with us anymore. This was due to stronger encryption which wasn't supported. Since the printer just have WiFi or USB connection, no standard Ethernet, I was looking for another solution.

We have no computer running 24/7 except a Raspberry Pi, RPi, which is handling our home automation, Homebridge. So the solution was to use CUPS on that RPi.

On the web there are several posts/manuals how to install CUPS on a RPi so this post will refer to one of these and then some additional hints regarding, Apple AirPrint, Windows Network Printer, scanning....
Install instructions
This post is compact and instructive. Check it out and then some additional hints will follow below. 

Just a note..... Instead of using "apt-get", it's more common to use the newer version "apt". 

After you installed the CUPS software, do a reboot, and then add the printer via the WEB interface. It could be that the RPi is a little slow the first minutes after the reboot, handling the new software.

Running headless
Our RPi is running headless, no monitor and keyboard, so I use "ssh" to reach the command line interface. In Windows open a command window and issue the command or use Putty. On a Mac use "terminal" and then issue the command.

OS upgrade
Always start with an upgrade of the OS in a command line

$ sudo apt update && sudo apt full-upgrade -y && sudo apt clean

Admin interface
Running headless makes that the mentioned URL  "https://localhost:631" can't be used to access CUPS admin interface. So to make it accessible across the network issue the command 

$ sudo cupsctl --remote-any

and then for a standard RPi install, from another klient, use "https://raspberrypi:631" instead.

Airprint
All Apples devices supports AirPrint which by default, after a full installation of CUPS, is in the "air".

So from any device trying to print something, the installed printer will appear.

Windows Network Printer
To make this work you will have to install Samba which is the software supporting Windows clients.

This post will cover the installation and please note the special part handling print drivers and the additional configuration for print server support.

CUPS config
The configuration file is found here "/etc/cups/cupsd.conf"

Scanning
A package, "sane-utils" will be installed within the CUPS install. If you added a printer with scan function you can scan from command line. Check if the scanner is detected with 

$ scanimage -L


(If you got "No scanners were identified. If.... " try this and the commands below with "sudo". This is due to that the usb could be owned by "root". Check with "ls -l /dev/usb") 
In my case the connected Cannon printer responded with 

device `pixma:MX450_192.168.1.64' is a CANON Canon PIXMA MX450 Series multi-function peripheral


Now use the command 

$ scanimage --help


and you will get parameters and the specific options for the Pixma peripheral. Put a document in the scanner and issue the command

$ scanimage > test.ppm


Check the file. With the specific options for the Pixma I issued the command 

$ scanimage --resolution 150 --mode Gray > test2.ppm


and this made a scanned object which had the resolution "150", instead of the default "75", and a "Grey" scanning instead of "Color". This post gave inspiration. The mentioned command "convert" is from a package called ImageMagick, which can be installed with 

$ sudo apt install imagemagick


and is used to convert between different file formats.

Wrap up
Install commands
If the referred post disappears, commands in short

$ sudo apt update && sudo apt full-upgrade -y && sudo apt clean
sudo apt install cups
sudo usermod -a -G lpadmin pi 
$ sudo cupsctl --remote-any
$ https://raspberrypi:631


Check status

Check status after the printer is added to CUPS


$ lpstat -t


If the RPi don't seems to detect the printer you can check with the command below. Use it direct after the first connection, of the USB printer cable, to your RPi.


$ dmesg


Extra info

An older but more extensive post is found here.


Error

After an OS upgrade I got the error 


"File "/usr/lib/cups/filter/rastertogutenprint.5.3" not available: No such file or directory"


After some googling I added a package


sudo apt install printer-driver-gutenprint


restarted the cups service 


$ sudo systemctl restart cups


and it was up and running again.

No comments:

Post a Comment

Feel free to leave a comment ! ... but due to a lot of spam comments I have to moderate them. Will reply ASAP !