[sane-devel] question about SANE_FIX macro
jazz_johnson at verizon.net
jazz_johnson at verizon.net
Tue Oct 23 20:25:57 UTC 2007
Hi,
I've been debugging my hs2p Ricoh IS450/420 driver and am having a problem with set_window()
returning with ILLEGAL REQUEST:
[hs2p] sane_start: sending SET WINDOW DATA
[hs2p] >> set_window
[hs2p] set_window: SET WINDOW COMMAND Transfer Length = 648 (should be 648)
[hs2p] set_window: SET WINDOW COMMAND Window Descriptor Length = 640 (should be 640)
[hs2p] set_window: COPYING 648 bytes from settings to Set Window Command (648)
[hs2p] set_window: calling sanei_scsi_cmd(3,&win,658)
[hs2p] sense_handler: result=0x70, sense=0x5, asc=0x26, ascq=0
[hs2p] sense_handler: ErrorCode 70 ValidData: 0 EOM: 0 ILI: 0 InvalidBytes: 0
[hs2p] sense_handler: sense=70 00 05 00 00 00 00 06 00 00 00 00 26 00 00 00
[hs2p] sense_handler: sense_key=0x5 'ILLEGAL REQUEST - Used such as when illegal parameter exists in data or command'
[hs2p] Looking up ascq=(0x26,0)=0x2600
[hs2p] sense_handler: ascq=(0,0): 0x2600 'Invalid field in parameter list (check field pointer.'
[hs2p] sense_handler : 'ILLEGAL REQUEST'-'Used such as when illegal parameter exists in data or command' 'Invalid field in parameter list (check field pointer.' return:4
[hs2p] << set_window
[hs2p] SET WINDOW DATA failed: Invalid argument
I want to set the Scanner's window to be measured in mm.
So I borrowed a piece of code from bh.c
static SANE_Status
attach (SANE_String_Const devname, HS2P_Device ** devp)
{
double mm;
<...>
dev->info.winWidth = _4btol(&jbuf.Window.width[0]);
dev->info.winHeight = _4btol(&jbuf.Window.length[0]);
/* 4692 / 400 * 25.4 = 297 */
mm = (dev->info.resBasicX > 0) ?
((double)dev->info.winWidth / (double)dev->info.resBasicX *MM_PER_INCH) : 0.0;
dev->info.x_range.min = SANE_FIX(0.0);
dev->info.x_range.max = SANE_FIX(mm);
dev->info.x_range.quant = SANE_FIX(0.0);
DBG(11,"attach: winWidth=%d resBasicX=%d mm/in=%f mm=%lf\n",
dev->info.winWidth, dev->info.resBasicX, MM_PER_INCH, mm);
DBG(11,"attach: RANGE x_range.max=%ld, y_range.max=%ld\n",
dev->info.x_range.max, dev->info.y_range.max);
<...>
}
when I run
'SANEI_SCSI_DEBUG=128 SANE_DEBUG_HS2p=999 scanimage -d hs2p:/dev/scanner'
I get the following:
[hs2p] attach: Window(W/L) = (4692/6803)
[hs2p] attach: winWidth=4692 resBasicX=400 mm/in=25.400000 mm=297.942000
[hs2p] attach: RANGE x_range.max=19525926, y_range.max=28310929
[hs2p] <<< attach:
x_range.max should be 297 and y_range.max should be 431
x_range is defined as SANE_Range:
typedef struct {
SANE_Range xres_range;
SANE_Range yres_range;
SANE_Range x_range;
SANE_Range y_range;
<...>
} HS2P_Info;
More information about the sane-devel
mailing list