Return-Path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=hRdGaBz/7Ufy8KP5z/jWg+15Y2cUI7LRWTfbRbQuYXQ=; b=DJQys5zphl3nyrhQQr080sh09vstLnccegkE+FERn0zf0NDsFeeY3iAiM2NvQpc+RO erfUw04t6wE3oEBTc5fOvhl9742wtovuA5jbdYoh9ttvE6+RfTJtIIYydvSwcMJzK5nU szRHnCKN+PGkc9GQyy4QMzfT19rwvZ3/DF6hCCKY+hPoF5ig9cB6+uTmUlRuWCg9/Yt8 +oTMkB6+ChBpqQMYmn1pIoCvOTECGbAaHMXXqCZGmIF+YuCBb2tuulziqZ+Kt8jELrn2 RO+XiFHW6CORHQ+DyaDIg3ErQvMzuUPi8pOrxdUxV2BH21hK8lBhY4cFrs653hx5Ahvr /VZQ== References: <12af8541-3113-341d-6b7f-d7393203368f@gmail.com> <949aea1f-a0f0-df47-1538-d7782f5350ab@redhat.com> <66430674-dc47-4a81-406b-aedefc065a37@gmail.com> <9d87166cb02c637e30e7d165c8293275@suse.de> From: Till Kamppeter Message-ID: <9b91cd9c-2766-dcd8-89e2-f7fed0072319@gmail.com> Date: Wed, 24 Feb 2021 18:23:51 +0100 MIME-Version: 1.0 In-Reply-To: <9d87166cb02c637e30e7d165c8293275@suse.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Printing-architecture] Automatic printer setup with Printer Applications List-Id: Printing architecture under linux List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Johannes Meixner , printing-architecture@lists.linux-foundation.org, Michael Sweet , Jai Luthra , Zdenek Dohnal On 24/02/2021 15:01, Johannes Meixner wrote: > I had experienced in the past some overenthusiastic > "let's simply just collect printer IEEE1284 IDs" or > "let's simply just collect printer USB VID/PIDs" > attempts by overenthusiastic wishful-thinkers > that appeared every now and then but never ever it > resulted really useful data - only duplicates for > well know printer devices like some HP LaserJets > but basically nothing for all those zillions of > printer devices that manufacturers continuously spill out > and unexperienced end-users "just buy" in the next shop. > > I took me some longer time of experience what works > reasonably well in practice out there in real world > how to auto-match based on the manufacturer & model > strings which is the only data that is always there. > > So a 90% working auto-match based on the manufacturer & model > works in 90% of the cases in practice out there in real world > while a 100% working auto-match based on IEEE1284 IDs or > USB VID/PIDs works only in less than about 20% of the > cases in practice out there in real world. > > My auto-match based on the manufacturer & model strings > is in SUSE's YaST2 printer module in somewhat human readable > form only in my old YCP code (the new autogenerated Ruby code > is no longer actually human readable - at least not for me). > > I could try to dig that out but I fear what comes out is a pile > of hacks that I just somehow put together to make that stuff > work reasonably well in practice out there in real world. > I go a similar way, matching by make and model, as we do not have device IDs and VID/PID for all printers (and there is a bunch of older Epsons all having the same VID/PID despite being different models). What I do is taking the observed make and model, normalizing it to some form how a human would read it: all lowercase, any amount of non-alphanumeric characters replaced by a single separator character, a separator character between words, where a word boundary is any group of non-alphanumeric characters, a transition between letter and digit or digit and letter, and '+' is replaced by the word "plus", as model names often differ by an added '+'. The separator usually is space or '-', ending up that the resulting string only contains letters, digits, and the separator character. We also add mssing manufacturer names by known model names, remove different representations of the same manufacturer, ... Examples: HP LaserJet 4500 -> hp--lasejet-4500 Hewlett Packard laserjet 2+ -> hp--laserjet-2-plus ecosys 1800s -> kyocera--ecosys-1800-s The names in the list of supported models I normalize the same way. So if we do not have the exact writing of a make/model name as of a device ID but a less exact writing of a third-party driver developer for example, the normalized strings will most probably match, but false matches are not very probable, as manufacturers would not market two different models whose names sound the same, for example names only differing by upper/lowercase or by non-alphanumeric characters. The code for this, as I use it in the PostScript Printer Application (https://github.com/OpenPrinting/ps-printer-app) is in the libcupsfilters library: https://github.com/OpenPrinting/cups-filters/blob/26770bc5690e950767e3dffc70b5231937e0a2ca/cupsfilters/ieee1284.c#L618 It has also functionality to normalize for sorted lists, replacing each group of digits by a number zero-padded to 6 digits. My algorithm work for prioritizing drivers is in scp-dbus-service, of system-config-printer: https://github.com/OpenPrinting/system-config-printer/blob/master/scp-dbus-service.py Till