[sane-devel] saned on win32 with HP backend - Mini-HowTo
Richard Metzger
richardmetzger at web.de
Tue Jan 9 17:11:38 CET 2007
Hi everyone,
I'm aware, that SANE primarily centers around making Unix/Linux connected scanners to their work, but sometimes, there might be the need to make it work the other way round.
I've an old HP Deskjet IIcx connected to a Windows box (because it's primary use is there) and I wanted to access it remotely from Linux.
After some debugging the involved SANE executables under Win32/CygWin, I found out, that when the reader process in the HP backend was forked, the file descriptor for the scanner device was no longer valid (in the forked process).
Later I discovered, that this has been diagnosed earlier already: details can be found at https://alioth.debian.org/tracker/index.php?func=detail&aid=301141&group_id=30186&atid=410366
After changing hp-handle.c in function reader_process according to sane-backends-1.0.15-BUG-alm.cygwin.tar.gz as described in the above link, it finally worked flawlessly.
In order to keep it down to the least amount of files necessary, I copied the following files to a separate directory
(C:\Programme\sane\saned)
cygsane-1.dll (as generated by compiling SANE)
cygsane-hp-1.dll (as generated by compiling SANE)
cygwin1.dll (copied from CygWin)
dll.conf (the configuration file for the DLL backend)
enter (a file containing a CR/LF - needed for runsane.bat)
hp.conf (the configuration file for the HP backend)
runsane.bat (a simple and stupid deamon implementation - see below)
saned.conf (the saned configuration file - contains the IP addresses of the clients allowed to connect)
saned.exe (as generated by compiling SANE)
In order to restart saned each time after a client (like e.g. XSANE) has used it, I wrapped it in a little batch loop:
-------------------runsane.bat--------------------
rem to run saned as a "background service"
rem
set thisdir=c:\Programme\sane\saned
echo %thisdir%
rem get rid of any possible trace info
del sdtrace
rem uncomment for more debugging info
rem set SANE_DEBUG_HP=255
rem set SANE_DEBUG_SANEI_SCSI=255
rem set SANE_DEBUG_DLL=255
set SANE_CONFIG_DIR=%thisdir%
:restart
date < enter >> sdtrace
time < enter >> sdtrace
rescan >> sdtrace
saned.exe -d128 >>sdtrace 2>&1
echo "--------restarting------------------------" >> sdtrace
goto restart
---------------end of runsane.bat----------------
Usually the scanner itself is not turned on, when that Windows box is booting, so I also included a call to the M$ SCSI bus rescan utility (found at http://support.microsoft.com/kb/308669) to make sure Windows knows the device before actually starting saned.
Also I prefer to have a "minimum level" of tracing on all the time, hence I do some recording to a file called sdtrace.
With this "logic" I first turn on the scanner, then connect to it from my linux system using e.g.
xsane net:ip-address-of-the-win-box:hp
The first connect fails (because the above batch utility is running saned already, before the scanner has been recognized). The second start of xsane successfully connects and utilizes the scanner perfectly. (a great THANK YOU to all you SANE developers !! ).
Now the only remaining cosmetic step was to hide the window the above runsane.bat is running in from the desktop.
I did this using the autoexnt utility following the steps at http://support.microsoft.com/kb/243486 and using an autoexnt.bat that looks like:
rem autoexnt.bat
rem ------------start the sane daemon------------------
cd \programme\sane\saned
start cmd.exe /c runsane.bat
Again - thanks to the SANE development community.
Richard.
(hoping this little HowTo might be helpful - and not being too offtopic with this HowTo)
_______________________________________________________________________
Viren-Scan für Ihren PC! Jetzt für jeden. Sofort, online und kostenlos.
Gleich testen! http://www.pc-sicherheit.web.de/freescan/?mc=022222
More information about the sane-devel
mailing list