[sane-devel] problem setting custom resolution

abel deuring a.deuring at satzbau-gmbh.de
Fri Aug 22 15:25:28 BST 2003


aneesh m raj wrote:
> 
> Hi,
> This is the resolution range value
> Rang min:4915200
> Range max:78643200
> This is in FIXED format when I UNFIX it I''l get 75 and 1200
> The user will set the resolution in UNFIXED form  in the range 75 to 1200
> When I set the resolution I'll convert the value by
> if (opt->type == SANE_TYPE_FIXED)
>     d = strtod (option, &end) * (1 << SANE_FIXED_SCALE_SHIFT);
> and after that I'll set the option
> 
> I'm I doing right....the problem is the scanner wont scan...seems like it is
> getting jammed.

My experience writing different kinds of software has always been that
it is a good idea to distrust my own code, when an error ouccurs. Sure,
it is possible to discover errors made by others, but in most cases a
fresh piece of code is buggy. I can't see, what might be wrong with your
code (or with the umax_pp backend), but I'm afraid that only people who
are able to read crystal balls could give you a better answer. 

A general strategy to trace bugs in such a case is to either run the
program under a debugger (gdb is quite good in this job) or to add many
printf (or fprintf(stderr,...)) calls to the source code. This way,
you'll be able to see, where the program is stuck. This gives quite
often a first clue about the cause of the problem, inspecting variables
(via the debugger or via something like printf("value of 'ret' at line
123 %i in function XYZ\n", ret); )will give you further insight, what
might be wrong.

Abel

PS: If you look into the source files of any Sane backend, you'll notice
many DBG macros. They do exactly what I described: They print some
information about the status of a backend in a certain situation/certain
function.



More information about the sane-devel mailing list