Minor fixes to improve usb-transfer stuff.

DEVEL_2_0_BRANCH-1
Gerhard Jaeger 2002-01-20 16:08:36 +00:00
rodzic 7fbdae8348
commit ddf779d8db
5 zmienionych plików z 66 dodań i 74 usunięć

Wyświetl plik

@ -1230,7 +1230,7 @@ static SetDef Settings[] =
* Have a look at the Hw0x0400_0x1000_0 or Hw0x07B3_0x0017_0 for further
* description
*
* The fouth entry is simply the name of the device, which will be
* The fourth entry is simply the name of the device, which will be
* displayed by the frontend
*/
{ NULL, NULL, NULL, NULL } /* last entry, never remove... */

Wyświetl plik

@ -59,6 +59,8 @@
#define DEV_LampPositive 4
#define DEV_LampNegative 5
#define _MSECS(tv) ((tv.tv_sec*1000)+(tv.tv_usec/1000))
/* HEINER: check the tick counts 'cause 1 tick on NT is about 10ms */
static u_long dwCrystalFrequency = 48000000UL;
@ -87,37 +89,36 @@ static Bool usb_MotorOn( int handle, Bool fOn )
*/
static Bool usb_IsScannerReady( pPlustek_Device dev )
{
u_char value;
u_char value;
double len;
long timeout;
struct timeval t;
#if 1
_UIO( usbio_ReadReg( dev->fd, 7, &value));
/* time in ms = 1000*scanner length in inches/max step speed/in */
len = (dev->usbDev.Caps.Normal.Size.y/(double)_MEASURE_BASE) + 5;
len = (1000.0 * len)/dev->usbDev.HwSetting.dMaxMoveSpeed;
gettimeofday( &t, NULL);
timeout = _MSECS(t) + len;
if( value == 0 )
_UIO( usbio_ResetLM983x( dev ));
if(value == 0 || value >= 0x20) {
if( usbio_WriteReg( dev->fd, 0x07, 0 )) {
return SANE_TRUE;
}
}
#else
SANE_Word delay;
for( delay = 0; delay < 300; delay++ ) {
do {
_UIO( usbio_ReadReg( dev->fd, 7, &value));
if( value == 0 )
if( value == 0 )
return SANE_TRUE;
if (value >= 8)
_UIO( usbio_WriteReg( dev->fd, 0x07, 0 ));
usleep( 100000 );
}
#endif
if( value == 3 || value >= 0x20) {
if( !usbio_WriteReg( dev->fd, 0x07, 0 )) {
DBG( _DBG_ERROR, "Scanner not ready!!!\n" );
return SANE_FALSE;
}
}
gettimeofday( &t, NULL);
} while( _MSECS(t) < timeout );
DBG( _DBG_ERROR, "Scanner not ready!!!\n" );
return SANE_FALSE;
}

Wyświetl plik

@ -68,24 +68,45 @@
#define usbio_ReadReg(fd, reg, value) \
sanei_lm983x_read (fd, reg, value, 1, 0)
/*.............................................................................
/**
* function to read the contents of a LM983x register and regarding some
* extra stuff, like flushing register 2 when writing register 0x58, etc
*
* @param handle -
* @param reg -
* @param value -
* @return
*/
static Bool usbio_WriteReg( SANE_Int handle, SANE_Byte reg, SANE_Byte value )
{
int i;
SANE_Byte data;
_UIO( sanei_lm983x_write_byte( handle, reg, value));
/* retry loop... */
for( i = 0; i < 100; i++ ) {
/* Flush register 0x02 when register 0x58 is written */
if( 0x58 == reg ) {
_UIO( sanei_lm983x_write_byte( handle, reg, value ));
/* Flush register 0x02 when register 0x58 is written */
if( 0x58 == reg ) {
_UIO( usbio_ReadReg( handle, 2, &data ));
_UIO( usbio_ReadReg( handle, 2, &data ));
_UIO( usbio_ReadReg( handle, 2, &data ));
_UIO( usbio_ReadReg( handle, 2, &data ));
}
if( reg != 7 )
return SANE_TRUE;
/* verify register 7 */
_UIO( usbio_ReadReg( handle, 7, &data ));
if( data == value ) {
return SANE_TRUE;
}
}
return SANE_TRUE;
return SANE_FALSE;
}
/*.............................................................................

Wyświetl plik

@ -1037,14 +1037,21 @@ static Bool usb_IsDataAvailableInDRAM( pPlustek_Device dev )
DBG( _DBG_INFO, "usb_IsDataAvailableInDRAM()\n" );
gettimeofday( &t, NULL);
/* dwTicks = t.tv_sec * 1e6 + t.tv_usec + 30000UL; */
dwTicks = t.tv_sec + 30;
for(;;) {
_UIO( sanei_lm983x_read( dev->fd, 0x01, a_bBand, 3, SANE_FALSE ));
gettimeofday( &t, NULL);
if( t.tv_sec > dwTicks )
break;
if( usb_IsEscPressed()) {
DBG(_DBG_INFO,"usb_IsDataAvailableInDRAM() - Cancel detected...\n");
return SANE_FALSE;
}
/* It is not stable for read */
if((a_bBand[0] != a_bBand[1]) && (a_bBand[1] != a_bBand[2]))
continue;
@ -1060,45 +1067,8 @@ static Bool usb_IsDataAvailableInDRAM( pPlustek_Device dev )
DBG( _DBG_INFO, "Data is available\n" );
return SANE_TRUE;
}
else
continue;
gettimeofday( &t, NULL);
/* if((t.tv_sec * 1e6 + t.tv_usec) > dwTicks ) */
if( t.tv_sec > dwTicks )
break;
}
#if 0
DWORD dw, dwTimeout = GetTickCount ();
/* Polling register 0x01 to see if there is available data */
BYTE a_bBand [3];
while ((dw = (GetTickCount() - dwTimeout)) < 30000UL) {
if( DriverUSB.BulkIn (0x01, a_bBand, 3, FALSE)) {
/* It is not stable for read */
if ((a_bBand [0] != a_bBand [1]) && (a_bBand [1] != a_bBand [2]))
continue;
if (a_bBand [0] > m_bOldScanData) {
if(m_pParam->bSource != SOURCE_Reflection)
Sleep (30 * a_bRegs[0x08] * Device.Caps.OpticDpi.x / 600);
else
Sleep (20 * a_bRegs[0x08] * Device.Caps.OpticDpi.x / 600);
return SANE_TRUE;
}
else
continue;
}
break;
}
#endif
DBG( _DBG_INFO, "NO Data available\n" );
return SANE_FALSE;
}

Wyświetl plik

@ -628,7 +628,7 @@ static SANE_Status init_options( Plustek_Scanner *s )
s->val[OPT_NUM_OPTS].w = NUM_OPTIONS;
/* "Scan Mode" group: */
s->opt[OPT_MODE_GROUP].name = "Scanmode-group";
s->opt[OPT_MODE_GROUP].name = "scanmode-group";
s->opt[OPT_MODE_GROUP].title = SANE_I18N("Scan Mode");
s->opt[OPT_MODE_GROUP].desc = "";
s->opt[OPT_MODE_GROUP].type = SANE_TYPE_GROUP;
@ -708,8 +708,8 @@ static SANE_Status init_options( Plustek_Scanner *s )
s->val[OPT_RESOLUTION].w = s->hw->dpi_range.min;
/* "Geometry" group: */
s->opt[OPT_GEOMETRY_GROUP].name = "geometry-group";
s->opt[OPT_GEOMETRY_GROUP].title = SANE_I18N("Geometry");
s->opt[OPT_GEOMETRY_GROUP].name = "Geometry Group";
s->opt[OPT_GEOMETRY_GROUP].desc = "";
s->opt[OPT_GEOMETRY_GROUP].type = SANE_TYPE_GROUP;
s->opt[OPT_GEOMETRY_GROUP].cap = SANE_CAP_ADVANCED;