NI Linux Real-Time Documents

cancel
Showing results for 
Search instead for 
Did you mean: 

Using CUPS to print from your target

Summary

In this guide, I'll step through what I did to setup CUPS to print to a network printer from a cRIO 9030, but will do so in a way that doesn't require a UI running on the target (I've set this up before on a 9068 using the same general process from my recollection).

 

Materials

  • A NI Linux RT-enabled target with a network connection (or a USB storage device to use to sneakernet the packages to the target for installation)
    • This set of instructions were done with a 2017 OS (Operating System 4.6.7-rt14-5.0.0f0), there may be slight differences with other versions of the OS and feed
  • Console access to the NI Linux RT target
  • A printer that is supported by CUPS, the associated .ppd file for that printer
    • Use your friendly neighborhood search engine here
    • If you're pointed to a .rpm or .deb file as "the driver" for your printer, it likely has one or more .ppd files in it you need. Use something like 7zip to extract those files on Windows and transfer to the target
  • Time
  • A burning desire to print from your cRIO target
  • A snazzy hat (optional)

Procedure

(optional) Put on the snazzy hat. This lets people know you mean business and does so with some flair

 

Install software to your target and either enable serial console or ssh access. Login to your target and install the following packages (note: if you're using LabVIEW 2017 or the 17.0 CompactRIO software, see LabVIEW 2017/RIO 17.0 PSA: Feed Adjustment for OPKG)

 

Install the following packages: opkg opkg-doc foomatic-filter

 

Edit the cups config file /etc/cups/cupsd.conf to enable remote access as described here. Basically, change "Listen localhost:631" to "Port 631" and add "Allow from $YOUR_SUBNET" to the "<Location />" and "<Location /admin>" blocks (e.g. if I were on a LAN with the subnet 192.168.1.0 with a subnet mask of 255.255.255.0, my <Location /> and <Location /admin> blocks would look like the following)

 

...
<Location />
  Order allow,deny
  Allow from 192.168.1.0/24
</Location>

# Restrict access to the admin pages...
<Location /admin>
Order allow,deny
Allow from 10.2.106.0/23
</Location>
...

 

Save the file, adjust the hat (if needed), and it's time for a

CHECKPOINT

From the target console, start cupsd, keeping it in the foreground (so you can monitor it/kill it easily)

 

admin@upandatthem:~# cupsd -f

Now, from a browser on your desktop, point it to your target's IP/hostname, specifically to port 631. You should be greeted by the following page

 

cups1.jpg

If you don't see this, review the previous steps to make sure you didn't miss something. If you are sure you didn't, post (making sure to include your target model and software release that you're using)

 

OK, back in the target's console, kill off the cupsd instance with a swift and decisive [ctrl][c]. We'll need to fixup a few things to allow for logging into the web interface first.

 

As the admin user, we need to set a password for the root user (by default, the root user has a password hash that is impossible, so you cannot login to the root user by password-based means).

 

admin@upandatthem:~# passwd root
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully

Now, we need to modify the pam plugin for cups (located at /etc/pam.d/cups)

 

Change the pam_unknown.so fields to pam_unix.so such that cups will use standard UNIX-based authentication and account lookup. Save that file, brace the hat, and get ready for another

CHECKPOINT

Launch cupsd -f again from the target console, and this time we're going to check to make sure that we can login as root to administer the cups configuration on the target.

 

Pop open the browser, point it back to your target (port 631), and go to the "Administration" tab, and click on the [Add Printer] button. It may redirect you to an SSL-enabled page and warn you about a self-signed certificate, accept those and sally forth. It should pop up a login dialog, login with the root credentials you setup previously.

cups2.jpg

 

If you are greeted with a screen that directs you to choose a printer/connection, congrats! The hat worked!

cups3.jpg

 

Now, time to get that .ppd file to your target. A reasonable place to put this would be under /usr/share/cups/model/ or /etc/cups/ppd.

 

Now, there are plenty of guides on how to bring it to completion (especially since there's some difference between setting up different printers), and how to create a startup script to launch a daemon (e.g. Tutorial: Installing Startup Scripts on NI Linux Real-Time), so I'll leave the rest as an exercise for the reader and their stylish headwear.

Contributors