Re: [sane-devel] Best way to stop scanimage?

2017-09-30 Thread Jeff Sadowski
I also run scanimage under script otherwise I don't get the continuous
output.

On Sat, Sep 30, 2017 at 6:09 PM, Jeff Sadowski 
wrote:

> 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 :-)
>
> On Sat, Sep 30, 2017 at 3:16 PM, Jeff  wrote:
>
>> On 29/09/17 15:52, Jeff Sadowski wrote:
>> > 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.zen
>> d.com/article/1021
>>
>> Good luck.
>>
>> Regards
>>
>> Jeff
>>
>>
>> --
>> sane-devel mailing list: sane-devel@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-requ...@lists.alioth.debian.org
>>
>
>
-- 
sane-devel mailing list: sane-devel@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-requ...@lists.alioth.debian.org

Re: [sane-devel] Best way to stop scanimage?

2017-09-30 Thread 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 :-)

On Sat, Sep 30, 2017 at 3:16 PM, Jeff  wrote:

> On 29/09/17 15:52, Jeff Sadowski wrote:
> > 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
>
>
> --
> sane-devel mailing list: sane-devel@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-requ...@lists.alioth.debian.org
>
-- 
sane-devel mailing list: sane-devel@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-requ...@lists.alioth.debian.org

Re: [sane-devel] Best way to stop scanimage?

2017-09-30 Thread Jeff
On 29/09/17 15:52, Jeff Sadowski wrote:
> 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



signature.asc
Description: OpenPGP digital signature
-- 
sane-devel mailing list: sane-devel@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-requ...@lists.alioth.debian.org

Re: [sane-devel] Best way to stop scanimage?

2017-09-29 Thread Olaf Meeuwissen
Hi Jeff,

Jeff Sadowski writes:

> 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-2FSF Associate Member since 2004-01-27
 GnuPG key: F84A2DD9/B3C0 2F47 EA19 64F4 9F13  F43E B8A4 A88A F84A 2DD9
 Support Free Softwarehttps://my.fsf.org/donate
 Join the Free Software Foundation  https://my.fsf.org/join

-- 
sane-devel mailing list: sane-devel@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-requ...@lists.alioth.debian.org


Re: [sane-devel] Best way to stop scanimage?

2017-09-29 Thread 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.

On Fri, Sep 29, 2017 at 3:51 AM, Olaf Meeuwissen 
wrote:

> Hi Jeff,
>
> Jeff Sadowski writes:
>
> >>> On Thu, Sep 28, 2017 at 10:30 AM, Jeff Sadowski <
> jeff.sadow...@gmail.com>
> >>> wrote:
> >>> > 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-2FSF Associate Member since 2004-01-27
>  GnuPG key: F84A2DD9/B3C0 2F47 EA19 64F4 9F13  F43E B8A4 A88A F84A 2DD9
>  Support Free Softwarehttps://my.fsf.org/donate
>  Join the Free Software Foundation  https://my.fsf.org/join
>
-- 
sane-devel mailing list: sane-devel@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-requ...@lists.alioth.debian.org

Re: [sane-devel] Best way to stop scanimage?

2017-09-29 Thread Olaf Meeuwissen
Hi Jeff,

Jeff Sadowski writes:

>>> On Thu, Sep 28, 2017 at 10:30 AM, Jeff Sadowski 
>>> wrote:
>>> > 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-2FSF Associate Member since 2004-01-27
 GnuPG key: F84A2DD9/B3C0 2F47 EA19 64F4 9F13  F43E B8A4 A88A F84A 2DD9
 Support Free Softwarehttps://my.fsf.org/donate
 Join the Free Software Foundation  https://my.fsf.org/join

-- 
sane-devel mailing list: sane-devel@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-requ...@lists.alioth.debian.org


Re: [sane-devel] Best way to stop scanimage?

2017-09-28 Thread Jeff Sadowski
Ooooh Ctrl-C sends the INT(-2) signal that is the signal I think I want.

On Thu, Sep 28, 2017 at 8:42 AM, Jeff Sadowski 
wrote:

> 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.
>
> On Thu, Sep 28, 2017 at 8:36 AM, m. allan noah  wrote:
>
>> Just let it complete?
>>
>> allan
>>
>> On Thu, Sep 28, 2017 at 10:30 AM, Jeff Sadowski 
>> wrote:
>> > 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.
>> >
>> >
>> > --
>> > sane-devel mailing list: sane-devel@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-requ...@lists.alioth.debian.org
>>
>>
>>
>> --
>> "well, I stand up next to a mountain- and I chop it down with the edge
>> of my hand"
>>
>
>
-- 
sane-devel mailing list: sane-devel@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-requ...@lists.alioth.debian.org

Re: [sane-devel] Best way to stop scanimage?

2017-09-28 Thread 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.

On Thu, Sep 28, 2017 at 8:36 AM, m. allan noah  wrote:

> Just let it complete?
>
> allan
>
> On Thu, Sep 28, 2017 at 10:30 AM, Jeff Sadowski 
> wrote:
> > 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.
> >
> >
> > --
> > sane-devel mailing list: sane-devel@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-requ...@lists.alioth.debian.org
>
>
>
> --
> "well, I stand up next to a mountain- and I chop it down with the edge
> of my hand"
>
-- 
sane-devel mailing list: sane-devel@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-requ...@lists.alioth.debian.org

Re: [sane-devel] Best way to stop scanimage?

2017-09-28 Thread m. allan noah
Just let it complete?

allan

On Thu, Sep 28, 2017 at 10:30 AM, Jeff Sadowski  wrote:
> 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.
>
>
> --
> sane-devel mailing list: sane-devel@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-requ...@lists.alioth.debian.org



-- 
"well, I stand up next to a mountain- and I chop it down with the edge
of my hand"

-- 
sane-devel mailing list: sane-devel@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-requ...@lists.alioth.debian.org