Setting up basic device connectivity

This file documents the procedure to set up basic device connectivity (low-level I/O) with the HP OfficeJet Linux driver (hpoj) package, whether setting up the hpoj software for the first time, upgrading from an older version, or adding a new peripheral later.

The particular procedure you use depends on whether your peripheral is connected locally to your PC via a parallel port or USB (Universal Serial Bus), or connected to a LAN (Local Area Network) via an HP JetDirect print server. In all cases, there will be a "PTAL device name" which you will need to use when setting up printing, scanning, or using any of the other applications provided with the hpoj software.

Setting up local (parallel or USB) connections

When connecting a supported HP all-in-one peripheral locally to your PC, whether to a parallel port or USB, there are two daemons that need to be started in order to provide the necessary low-level I/O support: The ptal-init script is used for starting and stopping the daemons, by invoking the "ptal-init start" and "ptal-init stop" commands, either on the command line or when called as part of system startup/shutdown. It in turn invokes the scripts ptal-start.conf for the actual commands to start the daemons, and ptal-stop.conf for any additional commands needed to stop the daemons. ptal-start.conf and ptal-stop.conf are by default installed in /usr/local/etc (or the etc directory under the installation directory you specified to the configure script). However, if you'd like, you can copy or move them to /etc, where they will take precedence over files of the same name in their original default location.

The PTAL device name for locally connected peripherals is of the form mlc:par:XXXX for parallel-port connections or mlc:usb:XXXX for USB connections. XXXX is a unique number or string you specify to identify the device.

Note that when invoking ptal-mlcd, you omit the mlc: prefix when specifying the device name, which is the first parameter.

Read on for details specific to parallel-port or USB connections...

Setting up local parallel-port connections

It is not currently possible to reliably detect parallel ports (or the peripherals connected to them) in user mode. Therefore, you will need to edit ptal-start.conf and manually add command lines to start ptal-mlcd and ptal-printd. There is already a pair of sample commands commented out in ptal-start.conf, which you may be able to use verbatim or with small changes, by simply un-commenting them (removing the leading "#" character for both the ptal-mlcd and ptal-printd lines).

You need to know the I/O-port base addresses of the parallel port. Most motherboard ports are at 0x378, but 0x278 and 0x3BC are also possibilities. For built-in parallel ports you may be able to consult your BIOS setup to find out this information. If you have an ISA add-in card, the base address may be set via jumpers. If you have a PCI add-in card, you can find this out by running "lspci -v".

If you have an ECP (Extended Capabilities Port), then you also need to know the "high" base address. For built-in or ISA ports, it's normally hard-wired to 0x400 above the "low" base address (i.e. 0x778, 0x678, or 0x7BC). For PCI ECPs, you can again find this out by running "lspci -v".

Under Linux, you may be able to determine base addresses by invoking the command "modprobe lp" and examining syslog messages (/var/log/messages), and/or by looking at parport-related files under /proc, although Linux kernels prior to 2.4 don't provide the ECP high base address in /proc.

Important: Your parallel port should be set to preferably "ECP" mode, or "bidirectional" (also known as "BPP" or "PS/2") at a minimum. "Unidirectional" (also known as "SPP") and "EPP" may work, albeit more slowly. Also, you may experience communication problems with certain models, such as the OfficeJet Pro 1150C, R, and PSC 500 series, unless the parallel port mode is set to either bidirectional or ECP.

The general form for invoking the daemons for parallel-port connections in ptal-start.conf is as follows:

	ptal-mlcd par:0 [-base 0xADDR] [-basehigh 0xADDR] \
		-device /dev/lp0 $PTAL_MLCD_CMDLINE_APPEND
	ptal-printd mlc:par:0 $PTAL_PRINTD_CMDLINE_APPEND
(The ptal-mlcd command line above is split into two lines for clarity.)

Notes:

Important: Be careful not to load kernel modules that conflict with ptal-mlcd's use of the parallel port. Typical examples of conflicting kernel modules include the following: Other than the above caveats, it doesn't matter if kernel parallel-port support is compiled/loaded as modules, compiled into the kernel, or disabled entirely, since ptal-mlcd bypasses the kernel to access the parallel port. As described earlier in this section, the kernel parallel-port support can be useful for determining the physical base address(es) of the port, but it is completely unnecessary for ptal-mlcd's normal operation. Of course, if it's disabled, then don't pass the -device switch to ptal-mlcd.

Preparing Linux for USB support

For proper USB operation, the earliest supported Linux kernel versions are 2.2.19 and 2.4.2. In addition, 2.4.7 fixes some bugs related to USB unplug. If you are using an earlier kernel, such as is the case with RedHat 7.0, then you should upgrade your kernel to a supported version (preferably the latest 2.2 or 2.4 as appropriate). Alternatively, you may be able to just update /usr/src/linux/drivers/usb/printer.c to a newer version and recompile your kernel and/or modules. For your convenience, updated versions of printer.c are available on the hpoj Download page.

The following kernel configuration options must be enabled:

The following kernel modules must be loaded (via modprobe or insmod): As an alternative to loading all needed drivers at startup, you can set up a "hot-plug" script to do this dynamically. This procedure will not be explained here, but you can get more information on the Linux USB home page.
Note: It is not recommended to load the hpoj daemons (ptal-mlcd or ptal-printd) from a USB hotplug script.

Be sure to mount /proc/bus/usb (type usbdevfs), either manually or at startup from /etc/fstab. /proc/bus/usb/devices provides useful (albeit somewhat cryptic) information about the devices attached to the bus. The usbview utility displays the same information in a more readable fashion.

If necessary, create the directory /dev/usb. In that directory, issue the following commands to create nodes for USB printer-class devices:

	mknod lp0 c 180 0
	mknod lp1 c 180 1
etc., as many as you need, but don't go past 15. Set the permission and ownership as desired (for example, 0660 and root:daemon).

Note: For troubleshooting purposes, it may be useful to look at the file /var/log/messages and/or run the graphical usbview utility. For example, if the printer kernel module isn't loaded, then no printer devices will be found. In this case, you may see messages in /var/log/messages to the effect that a USB device "is not claimed by any active driver," and usbview may display the device in red instead of black.

Setting up local USB connections

Setting up for USB is much easier than for parallel, because devices can be auto-detected much more easily. Run "ptal-init setup" to start the detection process, and follow the instructions from that point. For each printer device it finds that isn't listed in ptal-start.conf, it notifies you, suggests a default PTAL device suffix, and gives you an opportunity to enter a different name (or press Control-D to skip the device). Be sure to specify different device suffixes for each USB-connected device. The default PTAL device suffix is based on the device's model name as reported in the device ID string, with spaces replaced with underscores. For example: If you subsequently want to change the PTAL device suffix or remove a device's daemons altogether, then you must manually edit ptal-start.conf and edit or remove BOTH the ptal-mlcd and ptal-printd commands for the device in question.

Important: ptal-mlcd will currently only work with USB peripherals that have an interface that specifies a "class/subclass/protocol" value of "7/1/3", which can be inspected using usbview.

Once ptal-start.conf is set up correctly, ptal-mlcd should automatically handle the problem where devices show up on different /dev/usb/lp* nodes, depending on the order they were powered up or plugged in. However, if you have other USB printers that are not controlled by ptal-mlcd, then you will still have to deal with this problem for those devices. Make sure you always use the right device nodes to refer to the non-ptal-mlcd devices, or you could interfere with ptal-mlcd's access to its device.

Note: See the ptal-init documentation for important information if you happen to have more than one instance of the same USB-connected device.

Setting up JetDirect-connected peripherals

It is generally not necessary to use ptal-init, ptal-mlcd, or ptal-printd if you only have peripherals connected to a LAN via an HP JetDirect print server. However, for scanning or using any of the other applications provided with the hpoj software, you will still need to specify the correct PTAL device name, which takes one of the following two forms:
	hpjd:name
	hpjd:name:port
where name is the hostname or IP address of the JetDirect, and port is the port number (1, 2, or 3) for a multi-port JetDirect, such as the 500X. The default port number is 1.

For full JetDirect support (specifically, using PML or retrieving the device ID string), then you must have an SNMP development package, such as ucd-snmp-devel, installed on your system, and the hpoj software must have been configured to use it when you compiled/installed it.
Note: It is assumed that the JetDirect's SNMP community name is set to public. Currently there is no way to override this assumption other than hacking ptal-hpjd.c.

Note: Parallel-port JetDirects are limited to connecting to print, scan, and PML services when in MLC mode. Connecting to other services, such as echo, is only supported in 1284.4 mode, which was added in firmware version x.08.xx. USB JetDirects, such as the 175X, support connecting to any service on the peripheral in both MLC and 1284.4 modes.

Verifying basic connectivity

Here are some simple tests you can run to be sure you have basic connectivity to the device, before you proceed to more complicated tasks such as setting up printing or scanning. In all of the following examples, replace devname with the appropriate PTAL device name, as explained above.
Note: If you get a "command not found" error, then refer to the Post-installation steps for setting the PATH environment variable.

Note: ptal-mlcd currently doesn't always detect when the peripheral is disconnected or power cycled when it's idle. Therefore, when the peripheral is connected and powered on again, you may experience a failure when you run an application that tries to access the peripheral. In most cases, if you retry the operation it will succeed. However, in certain circumstances you may need to log in as root and issue the command "ptal-init start" to get things going again. This problem will be worked on in a future version of the hpoj software.

Next steps

Now you're ready to set up printing and scanning, or return to the index.