Samsung CLP-315W on NetBSD

Samsung CLP-315W is a low-end color laser printer, featuring USB, Ethernet, and wireless access. It works on NetBSD. The configuration was relatively painless with the standard tools supported by NetBSD. There was no need for something as complex as CUPS.

For initial configuration, I used a NetBSD host and standard dhcpd(8). The printer provides its own HTTP server from which all standard configuration options are available. Also IEEE 802.11 worked with a NetBSD router. But unfortunately, a local host is still required as the printer only speaks a non-standard format language.

The so-called foomatic is a prerequisite. This is available from pkgsrc(7):

# cd /usr/pkgsrc/print/foomatic-filters
# make install package clean

Samsung uses a special QPDL wire protocol, supported by foo2qpdl. For installation, fetch the sources and compile:

$ cd /tmp
$ ftp
$ tar xvfz foo2zjs.tar.gz
$ cd foo2zjs
$ gmake

If you have problems with the compilation, check the Makefile for odd CFLAGS possibly not yet supported by the NetBSD's cc(1). After having the sources successfully compiled, the required files were organized to /usr/local. From the compiled sources only the following are required:

# mkdir -p /usr/local/bin

# cp foo2qpdl /usr/local/bin
# cp foo2qpdl-wrapper /usr/local/bin

# cp foo2zjs /usr/local/bin
# cp foo2zjs-pstops /usr/local/bin

Note the permissions:

# chown root:wheel /usr/local/bin/foo*
# chmod 0555 /usr/local/bin/foo*

I used the following as the PostScript printer description (PPD) file. In order to avoid wasting the color toner cartridges, two separate files for monochrome and color setup were used:

# mkdir -p /usr/local/share

# cd /tmp/foo2zjs/PPD
# cp Samsung-CLP-310.ppd /usr/local/share/samsung-mono.ppd
# cp Samsung-CLP-310.ppd /usr/local/share/samsung-color.ppd

# chown root:wheel /usr/local/share/*
# chmod 0444 /usr/local/share/samsung*

By default, the used PPD file does not use colors. This was solved by editing the samsung-color.ppd file:

# diff -ur Samsung-CLP-310.ppd /usr/local/share/samsung-color.ppd

--- Samsung-CLP-310.ppd 2011-03-08 09:01:45.000000000 +0200
+++ samsung-color.ppd   2011-03-12 11:02:17.000000000 +0200
@@ -98,7 +98,7 @@
 *OpenUI *ColorMode/Color Mode: PickOne
 *FoomaticRIPOption ColorMode: enum CmdLine A
 *OrderDependency: 120 AnySetup *ColorMode
-*DefaultColorMode: Monochrome
+*DefaultColorMode: Color
 *ColorMode Color/Color: "%% FoomaticRIPOptionSetting: ColorMode=Color"
 *FoomaticRIPOptionSetting ColorMode=Color: "-c "
 *ColorMode Monochrome/Monochrome: "%% FoomaticRIPOptionSetting:

The following network setup was used: one host named print.lan was dedicated to forward the printing requests to the printer or printer.lan. This way all hosts inside the LAN can easily use the printer. Two entries were required for the printcap(5) file:

# Color (default; just 'lpr').

# Monochrome ('lpr -P lpm').  

Thus, for color and monochrome output, respectively, one needs only:

lpr /etc/passwd
lpr -P lpm /etc/passwd

Remote clients can access the print.lan host by using:

# We have a CNAME record for the printer host inside LAN.
lp|rp|remote printer:\

Finally, enable lpd(8) in rc.conf(5):

lpd_flags="-r -n 2"

The output quality is relatively good. There are no visible differences compared to the output with Windows and Samsung's own drivers.

Posted at lunch time on Wednesday, June 8th, 2011
Posted Sunday evening, June 12th, 2011

Using Scanners on NetBSD


To connect a USB scanner do:

  1. Check if it is supported by SANE:

SANE:Supported Devices

  1. Make /dev/ugen0 usable through removal of uscanner from the kernel config by commenting it:

     # cd /usr/src/sys/arch/i386/conf

    Comment out the uscanner device:

     # vi GENERIC_UGEN

    by using '#' so it looks like:

     # USB scanners
     # uscanner* at uhub? port ?

    Then, continue to config, make and install the new kernel:

     # config GENERIC_UGEN
     # cd ../compile/GENERIC_UGEN
     # make depend
     # make
     # cp netbsd /netbsd.ugen
     # cp /netbsd /netbsd.old
     # cp netbsd /netbsd
     # shutdown -r now
  2. Add the SANE packages to the system:

     # cd /usr/pkgsrc/graphics/sane-backend
     # make install
     # cd ../sane-frontend
     # make install
     # cd ../xsane
     # make install
  3. Connect the USB scanner and check if it's recognized:

     # sane-find-scanner

    When the scanner is found, check if it is correctly supported and usable:

     # scanimage -L

    Some scanners (e.g. the Epson Perfection 2480) need firmware loaded; put the firmware image in some place and add the scanner backend configuration file to point to it.

    Scan an image by using the name of appropriate backend found on the SANE supported devices page (usually printed out by sane-find-scanner), for an example:

     # scanimage -v -B -d name_of_backend:libusb:/dev/usb0:/dev/ugen0 --format pnm > /tmp/image.pnm


     # scanimage -v -B -d hp:libusb:/dev/usb0:/dev/ugen0 --format pnm > /tmp/image.pnm


     # scanimage -v -B -d gt68xx:libusb:/dev/usb0:/dev/ugen0 --format pnm > /tmp/image.pnm

    or use an alternative X frontend:

     # xsane

    To find what options are available, do:

     # scanimage --help -d gt68xx:libusb:/dev/usb0:/dev/ugen0

User access

To grant another user access to use the scanner, create a 'scanner' group.

# groupadd scanner

Add user to the group scanner:

# usermod -G scanner user_name

Change group for a device:

# chgrp scanner /dev/ugen*

For some drivers, you also need access to the usb bus devices:

# chgrp scanner /dev/usb*

Also check if the permissions are sufficient, otherwise also do:

# chmod g+rw /dev/usb* /dev/ugen*

Additional features

To postprocess the images, the ImageMagick package is very useful. For example, to batch-convert some images to black/white, use:

# mkdir ./bw ; for f in *.jpg ; do convert -colorspace gray "$f" "./bw/$f.jpg" ; done
Posted mid-morning Monday, June 20th, 2011