Error during getting option values

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Error during getting option values

Mohit kumar-5
Hi,

In response to the message, I had asked for the retrieval of the option values:

void PopulateScannerData(SANE_Handle handle)
{
        int index;
        unsigned long value;
        SANE_Status status;
        const SANE_Option_Descriptor* options=NULL;
        if(IsSupported(gData,SANE_NAME_SCAN_X_RESOLUTION,&index))
        {
                status = sane_control_option(handle,index,SANE_ACTION_GET_VALUE,(void*)value,0);
                assert(status == SANE_STATUS_GOOD);
                CSane::x_resolution = value;
        }
        if(IsSupported(gData,SANE_NAME_SCAN_Y_RESOLUTION,&index))
        {
                status = sane_control_option(handle,index,SANE_ACTION_GET_VALUE,(void*)value,0);
                assert(status == SANE_STATUS_GOOD);
                CSane::y_resolution = value;
        }
        else
                CSane::y_resolution = CSane::x_resolution;
}

I receive a SIGSEGV in this code. The gdb trace is :

#0  0x465cfaf0 in sanei_hp_accessor_new () from /usr/lib/sane/libsane-hp.so.1
#1  0x465cf903 in sanei_hp_accessor_get () from /usr/lib/sane/libsane-hp.so.1
#2  0x465d32f6 in sanei_hp_choice_isEnabled () from
/usr/lib/sane/libsane-hp.so.1
#3  0x465d8c27 in sanei_hp_optset_control () from /usr/lib/sane/libsane-hp.so.1
#4  0x465d1ed5 in sanei_hp_handle_control () from /usr/lib/sane/libsane-hp.so.1
#5  0x465ca534 in sane_hp_control_option () from /usr/lib/sane/libsane-hp.so.1
#6  0x41eacc2a in sane_dll_control_option () from /usr/lib/libsane.so.1
#7  0x41eacf7b in sane_control_option () from /usr/lib/libsane.so.1
#8  0x41fb358a in PopulateScannerData(void*).....

Can any one tell me what am I doing wrong?

Thanks,
Mohit



Message: 5
Date: Wed, 22 Jun 2005 18:06:25 +0200
From: Henning Meier-Geinitz <[hidden email]>
To: [hidden email]
Subject: Re: [sane-devel] Determining the "SET" values of options
through SANE APIs

Hi,

On Wed, Jun 22, 2005 at 07:17:19PM +0530, Mohit Kumar wrote:
> I was wondering if there is any mechanism for which I can find out
> what are the set values for various options such as resolution, mode
> etc?
>
> sane_get_option_descriptor gives us all the options, but is there any
> way to determine what is the current value of the option?

sane_control_option(), SANE_ACTION_GET_VALUE

Bye,
 Henning

--
sane-devel mailing list: [hidden email]
http://lists.alioth.debian.org/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
             to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Error during getting option values

Peter Fales
On Thu, Jun 23, 2005 at 04:27:59PM +0530, Mohit Kumar wrote:
>       unsigned long value;    
...
> {
> status = sane_control_option(handle,index,SANE_ACTION_GET_VALUE,(void*)value,0);

Value is uninitialized at this point.  I believe you want to pass its
address, not the value of the variable, i.e.:

 status = sane_control_option(handle,index,SANE_ACTION_GET_VALUE,(void*)&value,0);
                                                                       ^

--
Peter Fales

--
sane-devel mailing list: [hidden email]
http://lists.alioth.debian.org/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
             to [hidden email]