[sane-devel] TPU functionality in epson2-backend.

Martin Zackrisson martin.zackrisson at cmb.gu.se
Tue Nov 29 16:14:16 UTC 2011


On 11/24/2011 12:27 AM, Olaf Meeuwissen wrote:
> Martin Zackrisson<martin.zackrisson at cmb.gu.se>  writes:
>
>> I've dug through the code and made copy/paste/rename adjustments
>> everywhere it seemed reasonable (first day with c-code...). This will
>> probably more show how lost I am than anything else, but below are the
>> diffs for all files I've been poking around (don't think I forgot
>> any). I think my main issue is that I have no clue how to connect the
>> static that I made (SANE_EPSON_CAP_FULL_SENSOR_IN_TPU) to what is
>> being sent in the scanner in "define esci_set_full_sensor(s,v)
>> e2_esc_cmd( s,(s)->hw->cmd->set_full_sensor, v)". That is to give
>> set_full_sensor the value of SANE_EPSON_CAP_FULL_SENSOR_IN_TPU.
> Your SANE_EPSON_CAP_FULL_SENSOR_IN_TPU defines a two byte value but
> s->hw->cmd->set_full_sensor is only a single byte.  The e2_esc_cmd()
> route will not work as it was written for scanner commands that all
> start with an ESC (0x1b).
>
> You have to write your own esci_set_full_sensor() (see esci_set_zoom()
> in epson2-cmd.c for inspiration) and make that send the two bytes of
> SANE_EPSON_CAP_FULL_SENSOR_IN_TPU as well as the 0 or 1 value you want
> to set.  BTW, I have no clue as to the command handshake but expect it
> to be similar to that of esci_set_zoom().
>
Here's my new take on the code, it compiles and everything but scanimage 
--all-options doesn't report my feature. I really don't get where that 
happens so it's hard to know if what I've done makes any sense or not to 
the scanner... (sorry for all the code, renamed everything to match the 
name of the capability description from Epson)

diff ./epson2.c ../../sane-backends-1.0.22/backend//epson2.c
1340a1341,1354
 >     /* full sensor in TPU */
 >     s->opt[OPT_UNDEFINEDIMAGESIZE].name = "undefinedimagesize";
 >     s->opt[OPT_UNDEFINEDIMAGESIZE].title = SANE_I18N("Undefined Image 
Size");
 >     s->opt[OPT_UNDEFINEDIMAGESIZE].desc = SANE_I18N("In TPU mode some 
scanners (e.g. V700) apply auto size dropping for the scanning area. 
This option by-passes that 'functionality'");
 >     s->opt[OPT_UNDEFINEDIMAGESIZE].type = SANE_TYPE_BOOL;
 >     s->val[OPT_UNDEFINEDIMAGESIZE].w = SANE_FALSE;
 >
 >     s->opt[OPT_UNDEFINEDIMAGESIZE].cap |= SANE_CAP_ADVANCED;
 >
 >     if (s->hw->undefinedimagesize == SANE_TRUE)
 >         s->opt[OPT_UNDEFINEDIMAGESIZE].cap &= ~SANE_CAP_INACTIVE;
 >     else
 >         s->opt[OPT_UNDEFINEDIMAGESIZE].cap |= SANE_CAP_INACTIVE;
 >
1622a1637
 >     case OPT_UNDEFINEDIMAGESIZE:
1715a1731
 >     /*s->fullSensor = SANE_FALSE;     since this option isn't 
documented best not always activate */
1734a1751,1752
 >         deactivateOption(s, OPT_UNDEFINEDIMAGESIZE, &dummy);
 >
1746a1765,1772
 >         /* enable full size scanning */
 >         if (s->hw->cmd->set_undefinedimagesize != 0) {
 >             /*s->hw->x_range = &s->hw->x_range;
 >             s->hw->y_range = &s->hw->y_range;*/
 >             activateOption(s, OPT_UNDEFINEDIMAGESIZE, &dummy);
 >         } else {
 >             deactivateOption(s, OPT_UNDEFINEDIMAGESIZE, &dummy);
 >         }
1772a1799
 >         deactivateOption(s, OPT_UNDEFINEDIMAGESIZE, &dummy);
1958a1986
 >     case OPT_UNDEFINEDIMAGESIZE:
2059a2088,2089
 >     s->hw->cmd->set_undefinedimagesize[0] = 0x80;
 >     s->hw->cmd->set_undefinedimagesize[1] = 0x3D;
diff ./epson2-commands.c 
../../sane-backends-1.0.22/backend//epson2-commands.c
56a57,84
 > /* Test implementation of ICAP_UNDEFINEDIMAGESIZE */
 > SANE_Status
 > esci_set_undefinedimagesize(Epson_Scanner * s, SANE_Bool x)
 > {
 >     SANE_Status status;
 >
 >     unsigned char handshake[2];
 >     SANE_Bool params[1];
 >
 >     DBG(8, "%s: undefinedimagesize = %d\n", __func__, x);
 >
 >     if (!s->hw->cmd->set_undefinedimagesize) {
 >         DBG(1, "%s: not supported\n", __func__);
 >         return SANE_STATUS_GOOD;
 >     }
 >
 >     handshake[0] = s->hw->cmd->set_undefinedimagesize[0];
 >     handshake[1] = s->hw->cmd->set_undefinedimagesize[1];
 >
 >     status = e2_cmd_simple(s, handshake, 2);
 >     if (status != SANE_STATUS_GOOD)
 >         return status;
 >
 >     params[0] = x;
 >     return e2_cmd_simple(s, params, 1);
 >
 > }
 >
diff ./epson2-commands.h 
../../sane-backends-1.0.22/backend//epson2-commands.h
31a32
 > /*#define esci_set_undefinedimagesize(s,v)            e2_esc_cmd( 
s,(s)->hw->cmd->set_undefinedimagesize, v)*/
38a40
 > SANE_Status esci_set_undefinedimagesize(Epson_Scanner * s, SANE_Bool x);
diff ./epson2.h ../../sane-backends-1.0.22/backend//epson2.h
99a100,102
 > /* undocumented sensor feature for V700 */
 > #define SANE_EPSON_CAP_UNDEFINEDIMAGESIZE   0x803D
 >
220a224
 >     unsigned char set_undefinedimagesize[2]; /* For scanning the full 
area in TPU on V700*/
262a267
 >     OPT_UNDEFINEDIMAGESIZE,
340a346
 >     SANE_Bool undefinedimagesize; /* does the scanner have support 
for full sensor mode when TPU is source? */
393a400
 >     SANE_Bool undefinedimagesize;
diff ./epson2-ops.c ../../sane-backends-1.0.22/backend//epson2-ops.c
152a153,155
 >     dev->cmd->set_undefinedimagesize[0] = 0x80;
 >     dev->cmd->set_undefinedimagesize[1] = 0x3D;
 >
182a186
 >
473a478,480
 >     s->hw->cmd->set_undefinedimagesize[0] = 0x80;
 >     s->hw->cmd->set_undefinedimagesize[1] = 0x3D;
 >
761a769,773
 >     /* There should be a proper way to test if scanner supports
 >        full sensor mode */
 >
 >     dev->undefinedimagesize = SANE_TRUE;
 >
768a781
 >
994a1008,1016
 >         if (s->hw->undefinedimagesize == SANE_TRUE) {
 >             if (s->val[OPT_UNDEFINEDIMAGESIZE].w == SANE_FALSE) {
 >                 DBG(1, "setting capability 'Undefined Image Size'");
 >                 esci_set_undefinedimagesize(s, SANE_TRUE);
 >             } else {
 >                 DBG(1, "deselecting capability 'Undefined Image Size'");
 >                 esci_set_undefinedimagesize(s, SANE_FALSE);
 >             }
 >         }
1065a1088,1094
 >         if (status != SANE_STATUS_GOOD)
 >             return status;
 >     }
 >
 >     if (SANE_OPTION_IS_ACTIVE(s->opt[OPT_UNDEFINEDIMAGESIZE].cap)) {
 >         status = esci_set_undefinedimagesize(s, 
s->val[OPT_UNDEFINEDIMAGESIZE].w);
 >




More information about the sane-devel mailing list