# cups-1.2 does not recognize usb printer (solved)

## Weaselweb

Hi there, after upgrading to cups-1.2.6 (from 1.1) i can't use my usb printer HP LaserJet 2200 which worked without problems.

With the upgraded cups version it give me the error that no printer is connected. Well it is connected, even the dev files exists.

I read something about lpinfo, so i ran "lpinfo -v" and there was no line with usb   :Shocked: 

After downgrade to 1.1.23-r8 i ran that command again and i got this:

```
network socket

network http

network ipp

network lpd

direct parallel:/dev/lp0

direct scsi

serial serial:/dev/ttyS0?baud=115200

serial serial:/dev/ttyS1?baud=115200

serial serial:/dev/ttyS2?baud=115200

serial serial:/dev/ttyS3?baud=115200

direct usb:/dev/usb/lp0

direct usb:/dev/usb/lp1

direct usb:/dev/usb/lp2

direct usb:/dev/usb/lp3

direct usb:/dev/usb/lp4

direct usb:/dev/usb/lp5

direct usb:/dev/usb/lp6

direct usb:/dev/usb/lp7

direct usb:/dev/usb/lp8

direct usb:/dev/usb/lp9

direct usb:/dev/usb/lp10

direct usb:/dev/usb/lp11

direct usb:/dev/usb/lp12

direct usb:/dev/usb/lp13

direct usb:/dev/usb/lp14

direct usb:/dev/usb/lp15
```

with lots of usb entries.

Whats the matter with the 1.2 version of cups? Any help will be appreciated.

Greetings

WeaselwebLast edited by Weaselweb on Fri Dec 01, 2006 1:40 pm; edited 1 time in total

----------

## wynn

With the USB printer switched on and connected, you could also run the CUPS USB backend

```
# /usr/libexec/cups/backend/usb

direct usb://EPSON/Stylus%20D88 "EPSON Stylus D88" "EPSON Stylus D88 USB #1" "MFG:EPSON;CMD:ESCPL2,BDC,D4;MDL:Stylus D88;CLS:PRINTER;DES:EPSON Stylus D88;"
```

 and see what it says.

With the printer switched off, there is no output.

----------

## Weaselweb

/usr/libexec/cups/backend/usb doesn't exist in cups-1.1.23, so itred the 1.2.6 version, which gives me exactly nothing (printer was switched on). No output at all.

I also noticed that "lpinfo -v" need a lot more time (about 5 seconds) to print the infos, where in 1.1.23 it prints the info immediately. Really strange.

----------

## mikegpitt

Does dmesg show that you have plugged in the printer?

Also, have you upgraded the kernel recently and forgot to compile the USB printer module?

----------

## Weaselweb

I have upgraded my kernel recently, but this is independend to the cups version.

Here you can see, that my printer is detected and USB printer driver in enabled (it's even compiled into the kernel)

```
# dmesg | grep usblp

usbcore: registered new driver usblp

drivers/usb/class/usblp.c: v0.13: USB Printer Device Class driver

drivers/usb/class/usblp.c: usblp0: USB Bidirectional printer dev 2 if 0 alt 1 proto 2 vid 0x03F0 pid 0x0217
```

The dev nodes are created (/dev/lp0). Only with cups-1.2.6 the printer is not detected in contrast to cups-1.1.23.

I think the problem is affected by the missing USB driver in cups-1.2.6:

```
# lpinfo -v

network socket

network beh

direct parallel:/dev/lp0

network http

network ipp

network lpd

direct scsi

serial serial:/dev/ttyS0?baud=115200

serial serial:/dev/ttyS1?baud=115200

network smb
```

But I have no idea how to enable it.

----------

## wynn

lpinfo -v taking a long time is probably because it is getting no reply from a port or ports that it is accessing and waiting until it times out before trying again or going on to the next.

It doesn't seem as if there is a USB driver in CUPS.

The usb backend (/usr/libexec/cups/backend/usb) has the following code for listing the devices it sees (this is the function it performs when it is called without arguments)

```
 /*

  * Try to open each USB device...

  */

  for (i = 0; i < 16; i ++)

  {

   /*

    * Linux has a long history of changing the standard filenames used

    * for USB printer devices.  We get the honor of trying them all...

    */

    sprintf(device, "/dev/usblp%d", i);

    if ((fd = open(device, O_RDWR | O_EXCL)) < 0)

    {

      if (errno != ENOENT)

   continue;

      sprintf(device, "/dev/usb/lp%d", i);

      if ((fd = open(device, O_RDWR | O_EXCL)) < 0)

      {

   if (errno != ENOENT)

     continue;

   sprintf(device, "/dev/usb/usblp%d", i);

       if ((fd = open(device, O_RDWR | O_EXCL)) < 0)

     continue;

      }

    }

    if (!backendGetDeviceID(fd, device_id, sizeof(device_id),

                            make_model, sizeof(make_model),

             "usb", device_uri, sizeof(device_uri)))

      printf("direct %s \"%s\" \"%s USB #%d\" \"%s\"\n", device_uri,

        make_model, make_model, i + 1, device_id);

    close(fd);

  }
```

from which you can see that it does it by trying to open /dev/usblpN, /dev/usb/lpN and /dev/usb/usblpN for N from 0 to 15.

backend/usb not seeing your printer could be due to udev not creating /dev/usb/lp0.

udev 103 is running here and

```
# find /etc/udev -type f|xargs grep usb

/etc/udev/rules.d/50-udev.rules:# usb devices

/etc/udev/rules.d/50-udev.rules:KERNEL=="hiddev*",              NAME="usb/%k"

/etc/udev/rules.d/50-udev.rules:KERNEL=="auer*",                NAME="usb/%k"

/etc/udev/rules.d/50-udev.rules:KERNEL=="legousbtower*",        NAME="usb/%k", GROUP="usb"

/etc/udev/rules.d/50-udev.rules:KERNEL=="dabusb*",              NAME="usb/%k"

/etc/udev/rules.d/50-udev.rules:BUS=="usb", KERNEL=="lp[0-9]*", NAME="usb/%k", GROUP="lp"

/etc/udev/rules.d/50-udev.rules:KERNEL=="usblp",        NAME="%k", GROUP="lp"
```

and the second to last rule shown above should create /dev/usb/lp0

----------

## Weaselweb

I had creted my own rule for my printer (10-udev.rules):

```
BUS="usb", SYSFS{serial}="00JPKGC91257", NAME="%k", SYMLINK="hp_printer"
```

As you can see, NAME="%k" has no usb, so no device node is created under /dev/usb/. I changed to NAME="usb/%k" and cups finds my printer:

```
# lpinfo -v

network socket

network beh

direct usb://HP/LaserJet%202200

network http

network ipp

network lpd

direct scsi

serial serial:/dev/ttyS0?baud=115200

serial serial:/dev/ttyS1?baud=115200

network smb
```

But, when i want to print, i still got the message:  *Quote:*   

> "Printer not connected; will retry in 30 seconds..."

  I tried "DeviceURI usb:/dev/lp0" (which doesn't exist anymore), then "DeviceURI usb:/dev/usb/lp0" (still get the error message) and at last "DeviceURI usb://HP/LaserJet%202200" (nothing changed).

Well at the end i desiabled my own udev entry and now it works. It's a bit strange, but well now it works.

wynn, Thanks a lot.

Greetings

Weaselweb

----------

## wynn

I'm glad it's working.

Your rule may have been ignored as it doesn't conform to the udev grammar which is now being enforced. It should be

```
BUS=="usb", SYSFS{serial}=="00JPKGC91257", NAME="%k", SYMLINK="hp_printer"
```

The operators after BUS and SYSFS are match operators or equality operators and must be "==". The operators after NAME and SYMLINK are assignment operators and must be "="

http://www.reactivated.net/writing_udev_rules.html#syntax

----------

## mikegpitt

So is this really a bug with the latest udev then?  It seems like such a rule should be included.

----------

## wynn

 *mikegpitt wrote:*   

> So is this really a bug with the latest udev then?  It seems like such a rule should be included.

 If the syntax is wrong and the rule is ignored (and an error entry appears in /var/log/messages), isn't this proper behaviour?

----------

## Weaselweb

My rule was never ignored, because the symlink "hp_printer" was always created. I also don't find any errors related to udev in /var/log/messages (no results from "grep udev /var/log/messages").

But i couldn't use it, because cups could (can?) only use symlinks with "lp" in it (like lp0, lp1, ...).

----------

## wynn

 *Weaselweb wrote:*   

> My rule was never ignored, because the symlink "hp_printer" was always created. I also don't find any errors related to udev in /var/log/messages (no results from "grep udev /var/log/messages").
> 
> But i couldn't use it, because cups could (can?) only use symlinks with "lp" in it (like lp0, lp1, ...).

 Thank you for your explanation. A little piece more of the jigsaw   :Very Happy: 

I'm sure I saw a post which said that using "=" where equality was intended was now an error. 

[Edit] Found it. madisonicus pointed to https://forums.gentoo.org/viewtopic-p-3742050.html#3742050

larand54's post (https://forums.gentoo.org/viewtopic-p-3754912.html#3754912) at the end of the above topic is illuminating and seems to explain why you should be careful about "==" and "="

But I've looked through the Changelog back to "Summary of changes from v060 to v061" and I can't find anything definite. I've also looked at udev_rules_parse.c but it's a bit difficult...

One thing I can't find in the posts is the version of udev you are running, is it 103?

----------

## Weaselweb

 *wynn wrote:*   

> One thing I can't find in the posts is the version of udev you are running, is it 103?

 

No, at the moment i run udev-087-r1.

I'm trying to find that error with udev-103 and found this in /var/log/syslog:

 *Quote:*   

> Dec  1 21:47:27 server udevd[30818]: add_to_rules: invalid SUBSYSTEMS operation
> 
> Dec  1 21:47:27 server udevd[30818]: add_to_rules: invalid rule '/etc/udev/rules.d/10-udev.rules:1'
> 
> 

 

Looks like you're right, but that syntax check started between 087 and 103.

After changing my rules file to you proposal there's no problem and works like before.

----------

## mikegpitt

 *wynn wrote:*   

>  *mikegpitt wrote:*   So is this really a bug with the latest udev then?  It seems like such a rule should be included. If the syntax is wrong and the rule is ignored (and an error entry appears in /var/log/messages), isn't this proper behaviour?

 I meant, that it seems like a USB printer should be autodetected by udev without the need to write a special rule for it.  I agree that bad syntax isn't the fault of udev.

----------

## Headrush

 *Weaselweb wrote:*   

> But i couldn't use it, because cups could (can?) only use symlinks with "lp" in it (like lp0, lp1, ...).

 

This seems suspicious. I have never used names or symlinks with lpX in them.

 *Weaselweb wrote:*   

> Looks like you're right, but that syntax check started between 087 and 103.
> 
> After changing my rules file to you proposal there's no problem and works like before.

 

You are correct. At one time a single = worked, but this is no longer the case. (And probably better enforced like this.)

----------

## wynn

 *mikegpitt wrote:*   

> I meant, that it seems like a USB printer should be autodetected by udev without the need to write a special rule for it.  I agree that bad syntax isn't the fault of udev.

 Sorry, I misunderstood you. Yes, a USB printer should be autodetected by udev but in this case, peering into the murky depths, it seems that the local rule was somehow preventing this.

----------

## wynn

 *Headrush wrote:*   

>  *Weaselweb wrote:*   But i couldn't use it, because cups could (can?) only use symlinks with "lp" in it (like lp0, lp1, ...). 
> 
> This seems suspicious. I have never used names or symlinks with lpX in them.

 Perhaps Weaselweb was referring to the device discovery code in backend/usb (1.2.X) posted above?

I haven't yet managed to understand how the URI that open_device (for instance) uses is made up. If you have your own name under /dev, then perhaps it is possible to use this when adding the printer and, as you imply, it works without being of the form "lpX".

However, the usual form for a USB device URI chosen by CUPS is usb://<manufacturer>/<printer name> which also doesn't look like "lpX".

More research is clearly needed.

----------

