How to Print with RidgeRun SDK
The RidgeRun SDK includes integration with the Common Unix Printing System(CUPS). CUPS is a print spooler and associated utilities. It is based on the "Internet Printing Protocol" and provides printing services to most PostScript and raster printers.
Each printer queue has a name and a device associated with it. The device can be a usb port, a network interface, and so forth. To identify the devices, CUPS use Uniform Resource Identifiers(URIs). For example, the first parallel port in Linux usually uses a device URI of parallel:/dev/lp1.
CUPS uses libusb and printer USB devices under /dev/bus/usb/. In order to get USB printers working CUPS needs the ownership of the USB device file of the printer to be root:lp, and permissions to be 660.
/ # ls -l /dev/bus/usb/001/003 crw-rw---- 1 root lp 189, 2 Jan 1 00:23 /dev/bus/usb/001/003
Managing printers from the command line
How to set up a print queue
- Retrieve autodetected printers and their correct matching DeviceURIs from the cupsd
lpinfo -l -v
You should get an output like this:
Device: uri = http class = network info = Internet Printing Protocol (http) make-and-model = Unknown device-id = location = Device: uri = socket class = network info = AppSocket/HP JetDirect make-and-model = Unknown device-id = location = Device: uri = ipp class = network info = Internet Printing Protocol (ipp) make-and-model = Unknown device-id = location = Device: uri = lpd class = network info = LPD/LPR Host or Printer make-and-model = Unknown device-id = location = Device: uri = usb://HP/LaserJet%20P2015%20Series?serial=00CNBJL23349 class = direct info = HP LaserJet P2015 Series make-and-model = HP LaserJet P2015 Series device-id = MFG:Hewlett-Packard;CMD:PJL,PML,POSTSCRIPT,PCLXL,PCL;MDL:HP LaserJet P2015 Series;CLS:PRINTER;DES:Hewlett-Packard LaserJet P2015 Series;MEM:MEM=23MB;COMMENT:RES=1200x1; location =
- Select a printer/DeviceURI and devise an appropriate queue name.
- Set up the queue:
lpadmin -p <queue_name> -v <DeviceURI>
if you have the printer driver you must include the option -m printer_driver
Example to create the queue for the usb HP LaserJet:
lpadmin -p LaserJet -v usb://HP/LaserJet%20P2015%20Series?serial=00CNBJL23349
- You can define a default printer using the lpadmin command with the -d option:
lpadmin -d <queue_name>
How to delete printers
Run the lpadmin command with the -x option
lpadmin -x <queue_name>
How to check printers status
Check the status of a queue on the print server with the System V style command lpstad:
lpstat -p <queue_name>
Also you can see the list printer queues and what device they are attached to:
How to print a file
CUPS understands many different types of files directly, including text, PostScript, PDF, and image files. Type either of the following commands to print a file to the default (or only) printer on the system:
lp <filename> lpr <filename>