0

My scanner (scanner function of the MX860 multifunction printer) was being recognized using the sane-find-scanner command or using scanimage -L. It was working with Simple Scan, the scanimage utility, and sane-backend (with C++). All of a sudden it stopped working -- the device is not recognized by sane on Linux anymore.

I'm using a dual-boot Lubuntu 18.04/Windows 10. Windows 10 still recognizes the scanner.

It happened when I was using sane-backend in C++, but I'm not sure how this could have caused the error-- I don't think the code could have broken the recognition of the scanner. The printer is definitely supported by sane, and it is securely connected to power and connected via USB cable to my computer.

If you think it may be the culprit, here's the C++ code. It reads from the scanner and saves the data into a PNM image file. It was working fine until the outFile.open() suddenly began to return the status of Invalid argument, which is when scanimage -L stopped recognizing the scanner.

unsigned char data[50000];
int maxLength = 50000;
int length;

std::ofstream outFile;
outFile.open("./out/test.pnm");

SANE_Handle handle;
SANE_Parameters parm;
SANE_Status openStatus = sane_open("pixma:04A91735_10C369", &handle);
SANE_Status paramStatus = sane_get_parameters(handle, &parm);
SANE_Status startStatus = sane_start(handle);
SANE_Status readStatus;

// write header of PNM file
outFile << "P6\n# SANE data follows\n" << parm.pixels_per_line << " " << parm.lines << "\n" << ((parm.depth <= 8) ? 255 : 65535) << "\n";

do {
  readStatus = sane_read(handle, data, maxLength, &length);
  outFile.write((const char *) data, length);
} while(readStatus == SANE_STATUS_GOOD);
sane_close(handle);
outFile.close();

// debugging
std::cout << sane_strstatus(openStatus) << std::endl;
std::cout << sane_strstatus(paramStatus) << std::endl;
std::cout << sane_strstatus(startStatus) << std::endl;
std::cout << sane_strstatus(readStatus) << " " << length << std::endl;

Any thoughts?

Jonathan Lam
  • 428
  • 1
  • 7
  • 20
  • The first port of call is to see if any updates or new configurations broke it - first see if its recognised _at all_ using `lsusb` (might want to run `lsusb | grep MX860` to save time) and if it does recognise it, then try a live Linux USB to see if sane works there. If so, you probably broke it with a new configuration of sorts - if it shows up in lsusb then you know Linux sees it, but Sane doesn't. – QuickishFM Jan 19 '19 at 22:15
  • `lsusb` gives `Bus 001 Device 007: ID 04a9:1735 Canon, Inc.`, so it is recognized by Linux, and the printing function still works when connected by USB. Does that indicate anything to you? – Jonathan Lam Jan 19 '19 at 22:17
  • Good idea with the live USB -- I'll try that. – Jonathan Lam Jan 19 '19 at 22:18
  • That's a good sign - the USB device interfaces correctly with Linux still, and confirmed with the printer working. It seems from here the mismatch is between sane and the scanner device. If you haven't saved anything of value to the sane libraries/config, then perhaps try to reinstall sane and see if it fixes it to as it was. A liveUSB further tests whether sane works as it should have a "vanilla" config. – QuickishFM Jan 19 '19 at 22:20
  • @QuickishFM I don't have a liveUSB on hand but I tried purging the sane libraries and reinstalling them (`scanimage` comes with the OS, though, so I didn't remove that). Still no luck. May burn a liveUSB soon to try – Jonathan Lam Jan 19 '19 at 22:31
  • If you have the computer power to virtualise another OS, then you could also run a live USB iso in Virtualbox and pass through the USB device for the printer/scanner and test it that way. I suspect it may still be a settings issue so I'm thinking the bad config might have been saved across reinstalls - check for anything involving sane in your `.config` folder or your home folder. Then rename it and reboot, if might fix the issue. – QuickishFM Jan 19 '19 at 22:39
  • @QuickishFM I solved it some time later, but I'm not sure why the solution wasn't necessary when it was working before this problem appeared. – Jonathan Lam Jan 20 '19 at 20:54
  • i ran into this issue and rebooting the computer fixed the issue – Michael Sep 23 '20 at 17:26

1 Answers1

1

I found this out a few hours later. In the output of scanimage -L there was the following text:

# No USB scanners found. If you expected something different, make sure that
# you have loaded a kernel driver for your USB host controller and have setup
# the USB system correctly. See man sane-usb for details.
# SANE has been built without libusb support. This may be a reason
# for not detecting USB scanners. Read README for more details.

I installed libusb (apt install libusb-1.0-0-dev) and re-made sane-backends (./configure && make && sudo make install in the sane-backends directory).

This solved the problem. However, I don't know why the script worked in the first place without libusb installed before.

Jonathan Lam
  • 428
  • 1
  • 7
  • 20
  • did you have to build anything from source to begin with? i'm not following why this should even be necessary – Michael Sep 23 '20 at 17:18