Discussion:
[sane-devel] Best way to stop scanimage?
Jeff Sadowski
2017-09-28 14:30:36 UTC
Permalink
Is there a good way to stop scanimage? Other signals to send to it that it
may prefer?

It seems sometimes if I stop it I need to reset the scanner.
m. allan noah
2017-09-28 14:36:52 UTC
Permalink
Just let it complete?

allan
Post by Jeff Sadowski
Is there a good way to stop scanimage? Other signals to send to it that it
may prefer?
It seems sometimes if I stop it I need to reset the scanner.
--
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
--
"well, I stand up next to a mountain- and I chop it down with the edge
of my hand"
--
sane-devel mailing list: sane-***@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
to sane-devel-***@lists.alioth.debian.org
Jeff Sadowski
2017-09-28 14:42:05 UTC
Permalink
If I watch the image it is downloading and see it isn't quite right and I
don't want to wait for the scanner to reach the end sometimes it is nice to
stop it there. I think I found my issue I may have been sending it the
wrong signals in the past.
I may have been sending it a signal 9 vs signal 15.
Post by m. allan noah
Just let it complete?
allan
Post by Jeff Sadowski
Is there a good way to stop scanimage? Other signals to send to it that
it
Post by Jeff Sadowski
may prefer?
It seems sometimes if I stop it I need to reset the scanner.
--
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
--
"well, I stand up next to a mountain- and I chop it down with the edge
of my hand"
Jeff Sadowski
2017-09-28 14:49:09 UTC
Permalink
Ooooh Ctrl-C sends the INT(-2) signal that is the signal I think I want.
Post by Jeff Sadowski
If I watch the image it is downloading and see it isn't quite right and I
don't want to wait for the scanner to reach the end sometimes it is nice to
stop it there. I think I found my issue I may have been sending it the
wrong signals in the past.
I may have been sending it a signal 9 vs signal 15.
Post by m. allan noah
Just let it complete?
allan
Post by Jeff Sadowski
Is there a good way to stop scanimage? Other signals to send to it that
it
Post by Jeff Sadowski
may prefer?
It seems sometimes if I stop it I need to reset the scanner.
--
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
--
"well, I stand up next to a mountain- and I chop it down with the edge
of my hand"
Olaf Meeuwissen
2017-09-29 09:51:12 UTC
Permalink
Hi Jeff,
Post by Jeff Sadowski
Post by Jeff Sadowski
Is there a good way to stop scanimage?
Ooooh Ctrl-C sends the INT(-2) signal that is the signal I think I want.
You've already found out how to solve your issue but here are the
details.

Sending a *single* SIGINT or SIGTERM (and if supported by your system at
compile time SIGHUP or SIGPIPE) will cancel the scan in progress. This
should leave your scanner in a usable state.

Sending one of these signals again will abort the scan in progress (and
may leave your scanner in an unusable state).

You can send signals with the kill command or via the keyboard. The
latter is somewhat key binding dependent but usually Ctrl-C will do the
Right Thing.

Hope this helps,
--
Olaf Meeuwissen, LPIC-2 FSF Associate Member since 2004-01-27
GnuPG key: F84A2DD9/B3C0 2F47 EA19 64F4 9F13 F43E B8A4 A88A F84A 2DD9
Support Free Software https://my.fsf.org/donate
Join the Free Software Foundation https://my.fsf.org/join
--
sane-devel mailing list: sane-***@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
to sane-devel-***@lists.alioth.debian.org
Jeff Sadowski
2017-09-29 13:52:49 UTC
Permalink
Thank you Olaf, :-)

I am developing a php interface I'm calling it php saneng I have it on
bitbucket for now and using proc_open. I will send the signal via
proc_terminate giving it the second option being the signal I want to use.
I had a similar project I got working in the past specifically for my
scanner and I seem to recall I was giving it signal SIGTERM and I think
that was causing issues where as when I would test from the command line
and use ctrl+c it would leave the scanner in a usable state. So now that I
read about what ctrl+c sends (SIGINT) I think it would be better to send
that. Maybe there is something wrong with brothers backend that it prefers
a SIGINT over a SIGTERM. I'll experiment and let you know once I get my
project a little farther along. My similar project I had got working was
destroyed when an upgrade failed and I forgot to back it up. No biggy I
should have a better working one in a few weeks.
Post by Olaf Meeuwissen
Hi Jeff,
Post by Jeff Sadowski
On Thu, Sep 28, 2017 at 10:30 AM, Jeff Sadowski <
Post by Jeff Sadowski
Is there a good way to stop scanimage?
Ooooh Ctrl-C sends the INT(-2) signal that is the signal I think I want.
You've already found out how to solve your issue but here are the
details.
Sending a *single* SIGINT or SIGTERM (and if supported by your system at
compile time SIGHUP or SIGPIPE) will cancel the scan in progress. This
should leave your scanner in a usable state.
Sending one of these signals again will abort the scan in progress (and
may leave your scanner in an unusable state).
You can send signals with the kill command or via the keyboard. The
latter is somewhat key binding dependent but usually Ctrl-C will do the
Right Thing.
Hope this helps,
--
Olaf Meeuwissen, LPIC-2 FSF Associate Member since 2004-01-27
GnuPG key: F84A2DD9/B3C0 2F47 EA19 64F4 9F13 F43E B8A4 A88A F84A 2DD9
Support Free Software https://my.fsf.org/donate
Join the Free Software Foundation https://my.fsf.org/join
Olaf Meeuwissen
2017-09-29 14:31:46 UTC
Permalink
Hi Jeff,
Post by Jeff Sadowski
Thank you Olaf, :-)
I am developing a php interface I'm calling it php saneng I have it on
bitbucket for now and using proc_open. I will send the signal via
proc_terminate giving it the second option being the signal I want to use.
I had a similar project I got working in the past specifically for my
scanner and I seem to recall I was giving it signal SIGTERM and I think
that was causing issues where as when I would test from the command line
and use ctrl+c it would leave the scanner in a usable state. So now that I
read about what ctrl+c sends (SIGINT) I think it would be better to send
that. Maybe there is something wrong with brothers backend that it prefers
a SIGINT over a SIGTERM. I'll experiment and let you know once I get my
project a little farther along. My similar project I had got working was
destroyed when an upgrade failed and I forgot to back it up. No biggy I
should have a better working one in a few weeks.
The sighandler in scanimage simply calls sane_cancel() the first time
around and _exit(0) the second. The signal would normally be handled
by the scanimage frontend. Some backends register their own handlers
which may change the picture I painted in my earlier mail.

# Sorry, didn't think things thru. It's Friday night ...

Since Brother's backend is a non-free black box, you're in the dark as
to what it does and just have to give things a try :-(

Hope this helps,
--
Olaf Meeuwissen, LPIC-2 FSF Associate Member since 2004-01-27
GnuPG key: F84A2DD9/B3C0 2F47 EA19 64F4 9F13 F43E B8A4 A88A F84A 2DD9
Support Free Software https://my.fsf.org/donate
Join the Free Software Foundation https://my.fsf.org/join
--
sane-devel mailing list: sane-***@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
to sane-devel-***@lists.alioth.debian.org
Jeff
2017-09-30 21:16:32 UTC
Permalink
Post by Jeff Sadowski
I am developing a php interface I'm calling it php saneng I have it on
bitbucket for now and using proc_open. I will send the signal via
You are not the first. Have you looked at
https://sourceforge.net/projects/phpsane/ or
https://github.com/anomen-s/php-sane or https://github.com/sbs20/scanserv ?

I should probably point a few things before you continue down the dark
path of making a wrapper around scanimage.

When I started writing gscan2pdf back in 2006, it was exactly that, a
Gtk2 wrapper around scanimage, written in Perl.

It seemed like a good idea to wrap scanimage at the time, but it quickly
became clear that the problem is that you have no way of handling option
reloads. You can make it work for one scanner easily enough, but in a
general sense, it is impossible.

You are completely at the whim of the backend if an option, e.g. source
or depth, option force a reload. And they do, which changes unexpected
things. For instance some scanners support one page size (i.e. scan
size) for flatbed, and another for ADF.

You can work around this by calling scanimage [extra options] --help
every time the user changes an option, but this will be slow. You can
make it quicker by caching the options, but this is error-prone.

You will find that because of this, the order in which the options are
set is vitally important. i.e. for the above example, you have to set
the source option before the geometry options, as the range of geometry
options is changed by source. And confusingly, some backends have
different names for the same options.

In the end, I wrote Perl bindings for the SANE API. This solved all of
the above problems, as you then get reload callbacks:

http://search.cpan.org/~ratcliffe/Image-Sane-0.14/

However, it is non-trivial. Here is a tutorial on writing PHP extensions
in C:

http://web.archive.org/web/20110222035803/http://devzone.zend.com/article/1021

Good luck.

Regards

Jeff
Jeff Sadowski
2017-10-01 00:09:14 UTC
Permalink
Thank you for the input.

I'm redoing phpsane. I'll look at the others but I came up with a method
that seems to work a little better then I have seen so far. Like I
mentioned I'm using proc_open in a process that I put in the background and
to allow me to watch the image as it is being pulled. I am pulling the
selection interface I saw on phpsane. I talked to the developer of phpsane
and he suggested I rebuild it. I can successfully pull scanner specific
options and create a custom option list for them. I'll add the option to
stop and try it out. But I will caution other users on that. I will cache
options and scanner returns to speed things up.

I was even successful at allowing an array input in html :-)
Post by Jeff
Post by Jeff Sadowski
I am developing a php interface I'm calling it php saneng I have it on
bitbucket for now and using proc_open. I will send the signal via
You are not the first. Have you looked at
https://sourceforge.net/projects/phpsane/ or
https://github.com/anomen-s/php-sane or https://github.com/sbs20/scanserv ?
I should probably point a few things before you continue down the dark
path of making a wrapper around scanimage.
When I started writing gscan2pdf back in 2006, it was exactly that, a
Gtk2 wrapper around scanimage, written in Perl.
It seemed like a good idea to wrap scanimage at the time, but it quickly
became clear that the problem is that you have no way of handling option
reloads. You can make it work for one scanner easily enough, but in a
general sense, it is impossible.
You are completely at the whim of the backend if an option, e.g. source
or depth, option force a reload. And they do, which changes unexpected
things. For instance some scanners support one page size (i.e. scan
size) for flatbed, and another for ADF.
You can work around this by calling scanimage [extra options] --help
every time the user changes an option, but this will be slow. You can
make it quicker by caching the options, but this is error-prone.
You will find that because of this, the order in which the options are
set is vitally important. i.e. for the above example, you have to set
the source option before the geometry options, as the range of geometry
options is changed by source. And confusingly, some backends have
different names for the same options.
In the end, I wrote Perl bindings for the SANE API. This solved all of
http://search.cpan.org/~ratcliffe/Image-Sane-0.14/
However, it is non-trivial. Here is a tutorial on writing PHP extensions
http://web.archive.org/web/20110222035803/http://devzone.
zend.com/article/1021
Good luck.
Regards
Jeff
--
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
Jeff Sadowski
2017-10-01 00:30:55 UTC
Permalink
I also run scanimage under script otherwise I don't get the continuous
output.
Post by Jeff Sadowski
Thank you for the input.
I'm redoing phpsane. I'll look at the others but I came up with a method
that seems to work a little better then I have seen so far. Like I
mentioned I'm using proc_open in a process that I put in the background and
to allow me to watch the image as it is being pulled. I am pulling the
selection interface I saw on phpsane. I talked to the developer of phpsane
and he suggested I rebuild it. I can successfully pull scanner specific
options and create a custom option list for them. I'll add the option to
stop and try it out. But I will caution other users on that. I will cache
options and scanner returns to speed things up.
I was even successful at allowing an array input in html :-)
Post by Jeff
Post by Jeff Sadowski
I am developing a php interface I'm calling it php saneng I have it on
bitbucket for now and using proc_open. I will send the signal via
You are not the first. Have you looked at
https://sourceforge.net/projects/phpsane/ or
https://github.com/anomen-s/php-sane or https://github.com/sbs20/scanserv ?
I should probably point a few things before you continue down the dark
path of making a wrapper around scanimage.
When I started writing gscan2pdf back in 2006, it was exactly that, a
Gtk2 wrapper around scanimage, written in Perl.
It seemed like a good idea to wrap scanimage at the time, but it quickly
became clear that the problem is that you have no way of handling option
reloads. You can make it work for one scanner easily enough, but in a
general sense, it is impossible.
You are completely at the whim of the backend if an option, e.g. source
or depth, option force a reload. And they do, which changes unexpected
things. For instance some scanners support one page size (i.e. scan
size) for flatbed, and another for ADF.
You can work around this by calling scanimage [extra options] --help
every time the user changes an option, but this will be slow. You can
make it quicker by caching the options, but this is error-prone.
You will find that because of this, the order in which the options are
set is vitally important. i.e. for the above example, you have to set
the source option before the geometry options, as the range of geometry
options is changed by source. And confusingly, some backends have
different names for the same options.
In the end, I wrote Perl bindings for the SANE API. This solved all of
http://search.cpan.org/~ratcliffe/Image-Sane-0.14/
However, it is non-trivial. Here is a tutorial on writing PHP extensions
http://web.archive.org/web/20110222035803/http://devzone.zen
d.com/article/1021
Good luck.
Regards
Jeff
--
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
Loading...