[sane-devel] problem setting custom resolution
Fri, 22 Aug 2003 08:03:36 +0200
On Tue, Sep 23, 2003 at 10:34:13AM +0530, aneesh m raj wrote:
> Im trying to read the scanned data using sane form UMAX 2000p but
> when i set a custom resolution the read is causing some problem. This
> is my code.
Which problem exactly? Does it work with other frontends?
The code looks mostly ok for me, only some error checking for NULL-pointers
is missing. And be careful not to create buffer overflows with strcpy.
You should put sane_start inside the outer "do" loop if this loop is
intended for multi-pass scanning.
> status = read_data(devHnd, buffer, MAX_LEN, &len);
> if(status == SANE_STATUS_GOOD )
> else if(status != SANE_STATUS_EOF)
> printf("Reading scanned data failed...\n");
> buffer = (SANE_Byte*)malloc(sizeof(SANE_Byte) * MAX_LEN);
I don't understand why you free the buffer and malloc it right again.
> }while( status == SANE_STATUS_GOOD && len != 0);
len can be 0 when you called sane_set_io_mode and set the io_mode to
> if( status == SANE_STATUS_EOF)
> printf("Reading complete...\n");
> ret = 1;
> printf("Reason: %s",(char*)sane_strstatus(status));
If you get an error here, I'd leave the "do" loop. It doesn't really
make sense to try to read the other frames if reading one of them
resulted in an error.
> any help is appreciated
How do you set the resolution? To which value? How does read_data()