Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 4 Jun 2011 20:33:14 -0600 (MDT)
From:      Warren Block <wblock@wonkity.com>
To:        Scott Gasch <scott.gasch@gmail.com>
Cc:        questions@freebsd.org
Subject:   Re: Usb printers take the same port deterministically?
Message-ID:  <alpine.BSF.2.00.1106041955030.34792@wonkity.com>
In-Reply-To: <BANLkTinKGOJnvmm81Dk_WrygKbwK9c6SLg@mail.gmail.com>
References:  <BANLkTinNzPUtfMa5xbxn-z=sjm6QRBvWNw@mail.gmail.com> <alpine.BSF.2.00.1106041610280.34154@wonkity.com> <BANLkTinKGOJnvmm81Dk_WrygKbwK9c6SLg@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

---902635197-1433074227-1307241194=:34792
Content-Type: TEXT/PLAIN; format=flowed; charset=ISO-8859-15
Content-Transfer-Encoding: 8BIT

On Sat, 4 Jun 2011, Scott Gasch wrote:

> 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).

"action" can be a whole script.  Of course the quoting can get ugly. 
Here's what I use for a scanner.  The backtick portion was from someone 
on the mailing lists.  Can't recall who came up with it, but they 
deserve credit anyway:

attach 20 {
         device-name "ugen[0-9].[0-9]";
         match "vendor" "0x04b8";
         match "product" "0x010a";
         action "usb_devaddr=`echo $device-name | sed 's#^ugen##'` && \
                 chown root:saned /dev/usb/${usb_devaddr}.* && \
                 chmod 0660 /dev/usb/${usb_devaddr}.* && \
                 su saned -c '/usr/local/bin/scanbuttond \
                 -s /usr/local/etc/scanbuttond/buttonpressed.sh \
                 -S /usr/local/etc/scanbuttond/initscanner.sh \
                 -b /usr/local/lib/libscanbtnd-backend_epson.so'";
};

usb_devaddr is created by removing "ugen" from device-name.  Then it 
sets owner and permissions on the device and runs scanbuttond as user 
"saned".

> 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?

Different models should have different product codes.  Failing that, 
there might be other information available, like a model number or 
serial number.
---902635197-1433074227-1307241194=:34792--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?alpine.BSF.2.00.1106041955030.34792>