From owner-freebsd-questions@FreeBSD.ORG Sat Jun 4 23:28:37 2011 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C52B0106564A for ; Sat, 4 Jun 2011 23:28:37 +0000 (UTC) (envelope-from scott.gasch@gmail.com) Received: from mail-bw0-f54.google.com (mail-bw0-f54.google.com [209.85.214.54]) by mx1.freebsd.org (Postfix) with ESMTP id 44F358FC14 for ; Sat, 4 Jun 2011 23:28:36 +0000 (UTC) Received: by bwz12 with SMTP id 12so3875478bwz.13 for ; Sat, 04 Jun 2011 16:28:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=8yhg5WlbcyxpXkRIr9nyUAWSAEUvaFurP7Rn0jB6CKg=; b=qj31nmEWvVJoKdWnFmqVPPqzJrEPgYYGEM0fo7LoZuMm7zP0IzSjcKdKR2gfZ1347u Hhoac6L/DS0gmjUaLd6Fqtdrcrj7uP6Tkn/OHoLFVJIbVcajZN4Q0gwbdcmQlzfZWHc0 DNuhdJCPnAvYIQ8vUxoZKt/Smg4QgW5i8XA0w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=j03V8tat1ygPyNory+/qeVygRJxj/VICHc/kMnz3/4/uqiE9gKaDQlaU3W6EgkwrmR 4R2vpVjqHneiqruOuDHJw0lqMZD8EwtZf4po/P0rNlEapAwJGRktQ2hGiTeJQxfAba8c k9OB/OerPoTF+V++/YOaYWmyzt+hAvylWMaIY= MIME-Version: 1.0 Received: by 10.204.11.22 with SMTP id r22mr3253108bkr.172.1307230116076; Sat, 04 Jun 2011 16:28:36 -0700 (PDT) Received: by 10.204.79.225 with HTTP; Sat, 4 Jun 2011 16:28:36 -0700 (PDT) In-Reply-To: References: Date: Sat, 4 Jun 2011 16:28:36 -0700 Message-ID: From: Scott Gasch To: Warren Block Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: questions@freebsd.org Subject: Re: Usb printers take the same port deterministically? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Jun 2011 23:28:37 -0000 Thanks, Warren. Works great, mostly :) I actually need the "unlpt*" device because of publishing the raw printers. Hooking the attach/detach of those device names directly did not work. Adding an action to the "ulpt" device does work... but I then ran into the problem of pulling the number out of the $device variable to figure out what port just attached. After some messing around (I tried to match the device and serial variables) I gave up and just made two entries per printer: one for ulpt0 and one for ulpt1 (see below). Just because I'm a pain, how does this work if you have two printers from the same vendor? Epson's product code 0x0009, for example, means "high speed usb 2.0 printer". So I'm guessing, really, that any epson printer would match? Thx, Scott Here's the final working version for the archives: attach 20 { device-name "ulpt0"; match "vendor" "0x04f9"; # Brother match "product" "0x0033"; # HL-2140 action "ln -s /dev/$device-name /dev/ulpt-brother"; action "ln -s /dev/unlpt0 /dev/unlpt-brother"; }; attach 20 { device-name "ulpt1"; match "vendor" "0x04f9"; # Brother match "product" "0x0033"; # HL-2140 action "ln -s /dev/$device-name /dev/ulpt-brother"; action "ln -s /dev/unlpt1 /dev/unlpt-brother"; }; detach 20 { device-name "ulpt[0-9]"; match "vendor" "0x04f9"; # Brother match "product" "0x0033"; # HL-2140 action "rm -f /dev/ulpt-brother"; action "rm -f /dev/unlpt-brother"; }; # --- attach 20 { device-name "ulpt0"; match "vendor" "0x04b8"; # Epson match "product" "0x0007"; # Photostylus R800 action "ln -s /dev/$device-name /dev/ulpt-epson"; action "ln -s /dev/unlpt0 /dev/unlpt-epson"; }; attach 20 { device-name "ulpt1"; match "vendor" "0x04b8"; # Epson match "product" "0x0007"; # Photostylus R800 action "ln -s /dev/$device-name /dev/ulpt-epson"; action "ln -s /dev/unlpt1 /dev/unlpt-epson"; }; detach 20 { device-name "ulpt[0-9]"; match "vendor" "0x04b8"; # Epson match "product" "0x0007"; # Photostylus R800 action "rm -f /dev/ulpt-epson"; action "rm -f /dev/unlpt-epson"; }; On Sat, Jun 4, 2011 at 3:19 PM, Warren Block wrote: > On Sat, 4 Jun 2011, Scott Gasch wrote: > > Hi, >> >> I have two usb printers on my freebsd machine and I'm using cups. One of >> the things I've done is publish a raw (no driver) printer for each of them >> and use that to share them with other machines in the house that have >> drivers. >> >> My problem is that every once in a while, when I boot up, the order of the >> printers on the usb ports seems to change. For example, right now I've >> got: >> >> Jun 4 11:24:34 foo kernel: ulpt0: > 2.00/1.00, addr 2> on uhub1 >> Jun 4 11:24:34 foo kernel: ulpt0: using bi-directional mode >> Jun 4 11:28:13 foo kernel: ulpt1: > 0/0, rev 2.00/1.00, addr 2> on uhub7 >> >> >> But when I lost power the other night the machine came up with them >> reversed >> -- the brother on ulpt1 and the epson on ulpt0. >> >> As far as I can tell, cups printers.conf ties to a particular port. So, >> you >> can probably see where this is going... when they bind in the wrong order >> and someone prints I get a ton of crap printed out and waste a ton of >> paper. >> How can I make it so that a particular printer binds to a particular usb >> port deterministically? >> > > devd.conf. But I don't think there's any control over ulpt. Instead, > maybe create links so /dev/ulpt-hl2140 and /dev/ulpt-epson12 are linked to > the right devices, and use those where static devices are needed. > Untested... > > attach 20 { > device-name "ulpt[0-9]"; > match "vendor" "0x1234"; # Brother > match "product" "0x4321"; # HL-2140 > action "ln -s /dev/$device-name /dev/ulpt-hl2140"; > }; > > detach 20 { > device-name "ulpt[0-9]"; > match "vendor" "0x1234"; # Brother > match "product" "0x4321"; # HL-2140 > action "rm /dev/ulpt-hl2140"; > }; >