diff options
Diffstat (limited to 'perl-install/detect_devices.pm')
-rw-r--r-- | perl-install/detect_devices.pm | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/perl-install/detect_devices.pm b/perl-install/detect_devices.pm index 4d861bfac..4d77e06ef 100644 --- a/perl-install/detect_devices.pm +++ b/perl-install/detect_devices.pm @@ -601,109 +601,6 @@ sub usbKeyboard2country_code { unpack("C", $tmp); } -sub whatUsbport() { - # The printer manufacturer and model names obtained with the usb_probe() - # function were very messy, once there was a lot of noise around the - # manufacturers name ("Inc.", "SA", "International", ...) and second, - # all Epson inkjets answered with the name "Epson Stylus Color 760" which - # lead many newbies to install their Epson Stylus Photo XXX as an Epson - # Stylus Color 760 ... - # - # This routine based on an ioctl request gives very clean and correct - # manufacturer and model names, so that they are easily matched to the - # printer entries in the Foomatic database - my @res; - foreach my $i (0..15) { - my $port = "/dev/usb/lp$i"; - my $realport = devices::make($port); - next if !$realport; - next if ! -r $realport; - open(my $PORT, $realport) or next; - my $idstr = ""; - # Calculation of IOCTL function 0x84005001 (to get device ID - # string): - # len = 1024 - # IOCNR_GET_DEVICE_ID = 1 - # LPIOC_GET_DEVICE_ID(len) = - # _IOC(_IOC_READ, 'P', IOCNR_GET_DEVICE_ID, len) - # _IOC(), _IOC_READ as defined in /usr/include/asm/ioctl.h - # Use "eval" so that program does not stop when IOCTL fails - eval { - my $output = "\0" x 1024; - ioctl($PORT, 0x84005001, $output); - $idstr = $output; - } or do { - close $PORT; - next; - }; - close $PORT; - # Remove non-printable characters - $idstr =~ tr/[\x00-\x1f]/\./; - # Extract the printer data from the ID string - my ($manufacturer, $model, $serialnumber, $description, - $commandset, $sku) = - ("", "", "", "", ""); - if ($idstr =~ /MFG:([^;]+);/ || $idstr =~ /MANUFACTURER:([^;]+);/) { - $manufacturer = $1; - $manufacturer =~ s/Hewlett[-\s_]Packard/HP/; - $manufacturer =~ s/HEWLETT[-\s_]PACKARD/HP/; - } - # For HP's multi-function devices the real model name is in the "SKU" - # field. So use this field with priority for $model when it exists. - if ($idstr =~ /MDL:([^;]+);/ || $idstr =~ /MODEL:([^;]+);/) { - $model ||= $1; - } - if ($idstr =~ /SKU:([^;]+);/) { - $sku = $1; - } - if ($idstr =~ /DES:([^;]+);/ || $idstr =~ /DESCRIPTION:([^;]+);/) { - $description = $1; - $description =~ s/Hewlett[-\s_]Packard/HP/; - $description =~ s/HEWLETT[-\s_]PACKARD/HP/; - } - if ($idstr =~ /SE*R*N:([^;]+);/) { - $serialnumber = $1; - } - if ($idstr =~ /CMD:([^;]+);/ || - $idstr =~ /COMMAND\s*SET:([^;]+);/) { - $commandset ||= $1; - } - # Was there a manufacturer and a model in the string? - if ($manufacturer eq "" || $model eq "") { - next; - } - # No description field? Make one out of manufacturer and model. - if ($description eq "") { - $description = "$manufacturer $model"; - } - # Store this auto-detection result in the data structure - push @res, { port => $port, val => - { CLASS => 'PRINTER', - MODEL => $model, - MANUFACTURER => $manufacturer, - DESCRIPTION => $description, - SERIALNUMBER => $serialnumber, - 'COMMAND SET' => $commandset, - SKU => $sku - } }; - } - @res; -} - -#-CLASS:PRINTER; -#-MODEL:HP LaserJet 1100; -#-MANUFACTURER:Hewlett-Packard; -#-DESCRIPTION:HP LaserJet 1100 Printer; -#-COMMAND SET:MLC,PCL,PJL; -sub whatPrinter { - my @res = (whatParport(), whatUsbport()); - grep { $_->{val}{CLASS} eq "PRINTER" } @res; -} - -sub whatPrinterPort() { - grep { tryWrite($_) } qw(/dev/lp0 /dev/lp1 /dev/lp2 /dev/usb/lp0 /dev/usb/lp1 /dev/usb/lp2 /dev/usb/lp3 /dev/usb/lp4 /dev/usb/lp5 /dev/usb/lp6 /dev/usb/lp7 /dev/usb/lp8 /dev/usb/lp9); -} - sub probeSerialDevices { foreach (0..3) { #- make sure the device are created before probing, |