Canon Scanner on LINUX Shows Vertical Bar


Published: 2019-01-09
Updated: 2019-01-24
Web: https://fritzthecat-blog.blogspot.com/2019/01/canon-scanner-on-linux-shows-vertical.html


I spent an afternoon staring at LINUX forums to get my scanner working. There was a bug introduced in Ubuntu 18.04 that hit Canon scanners, mine is a CanoScan LIDE 200. Symptom was that there was a thick vertical bar in the middle of the image, being black when scanning grey, else being randomly coloured. It is a known bug, nevertheless a system-update did not fix it, because the fix might open a bug for another type of scanner (at least this is what I understood from the forums).

I use the graphical xsane scanner tool, which is a frontend for the sane-genesys backend drivers. The bug was reported to be in the backend, which is called "libsane1". To fix it I followed the advices given on a launchpad web page, it was the entry of date 2018-12-01, written by gary17, that helped. But of course not without problems.

Commands to fix libsane1 on Ubuntu 18.04

Following were the commands I launched, in a terminal window, to get my scanner working.


sudo apt-get install dpkg-dev fakeroot

This installs two needed libraries, unless they are already installed. They serve for compiling and building Debian packages (Ubuntu is a Debian derivate).


cd $HOME/programs/
mkdir sanebackend-1.0.27-fix
cd sanebackend-1.0.27-fix
apt-get source libsane1

We need to get the current source code of the genesys drivers, here I create a directory where to put these sources, and change into it. Then I download the sources by apt-get, not as super-user because this is not needed to compile them, and I don't want files in my user-directory that belong to root.

A decent developer already found the problem and published the solution. So we just need to patch the source, here is the diff-text:


2075c2075,2079
< if (dev->model->flags & GENESYS_FLAG_SHADING_REPARK && dev->model->cmd_set->rewind)
---
> if (dev->model->flags & GENESYS_FLAG_SHADING_REPARK && dev->model->cmd_set->slow_back_home)
> {
> status = dev->model->cmd_set->slow_back_home (dev, dev->model->flags);
> }
> else if (dev->model->flags & GENESYS_FLAG_SHADING_REPARK && dev->model->cmd_set->rewind)

Save this into file genesys.c.diff, or store the contents of this link into it.


patch sane-backends-1.0.27/backend/genesys.c < genesys.c.diff

This command fixes the source code using the diff-file. Now we need to build and install.


sudo apt-get build-dep libsane1

This prepares all system-dependencies for package libsane1 so that we can build it. build-dep is an apt-get command just like install and remove.


cd sane-backends-1.0.27
./configure
dpkg-buildpackage -rfakeroot -uc -b

Here I change into the source-directory of libsane1 and "configure" it, which is a platfom-preparation of the "build". Makefiles get generated. This takes a while.

The final dpkg-buildpackage command starts the compilation. This again will take some time, and output a lot of compiler messages.


echo $?

This command outputs the exit-code of the latest command, in this case the compilation. If it is NOT zero (0 is positive!), something went wrong. I got 2 as exit code, and saw following error message:


....
kpathsea: Running mktexmf ptmr7t
! I can't find file `ptmr7t'.
....

This happened on generating "manpages", i.e. the UNIX documentation for the library. As I did not know how I could bypass this, and the new driver was not built due to this failing sub-build, I tried to find hints about this error message. I found out that it originates from TeX statements like the following:


\usepackage{times,mathptmx,courier}

And I found out that the times font is obsolete. So a missing font for the documentation made the build of a scanner driver fail! Was it called dependency-hell :-?

I searched where the font was used, and found it just once in file doc/sane.tex in line 3:


\documentclass[11pt]{report}

\usepackage{times,graphicx,url}
% ....

So I searched for another font that I could apply there, and I found it on a TeX forum. I edited the doc/sane.tex file and replaced "times" by "helvet". Then I ran again the compilation:


dpkg-buildpackage -rfakeroot -uc -b

Yes, it failed again. This time because of a missing m4/libtool.m4 file. I tried to run ./configure again, but there was no such script any more. Instead of starting all over I found a workaround by copying an existing libtool.m4:


cp /usr/share/aclocal/libtool.m4 m4/

Another compilation now finished successfully:


dpkg-buildpackage -rfakeroot -uc -b
.....
echo $?
0

The exit code 0 reports a successful build. The resulting Debian-package was in ../libsane-dev_1.0.27-1~experimental3ubuntu2_amd64.deb. I installed this package into the operating-system by following command:


cd ..
sudo dpkg -i libsane1_1.0.27-1~experimental3ubuntu2_amd64.deb

It finished successfully. Now I started xsane and tried to scan a page, without rebooting the system:

No vertical bar showed any more!

To protect my fix against system-updates I launched this command:


sudo apt-mark hold libsane1

Response was: libsane1 set on hold. Hope this will be respected by the Ubuntu updater! Else I will have to come back here and do the same again, until they find out how to fix this bug for all types of scanners.

Resume

Using an open-source operating system may cause lost afternoons :-)

But why did I "stare" at the LINUX forums?
Because these entries are missing quality, they ...

I spent 90% of that afternoon trying to understand instructions and considering risks, only 10% with real editing work. So, does quality of communication count?





ɔ⃝ Fritz Ritzberger, 2019-01-09