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?