kopia lustrzana https://gitlab.com/sane-project/backends
fix asynchronous parking issues
rodzic
948aa52e54
commit
d0ea6b8647
|
@ -6841,7 +6841,7 @@ genesys_buffer_image(Genesys_Scanner *s)
|
|||
return SANE_STATUS_NO_MEM;
|
||||
}
|
||||
|
||||
/* loop reading data until we reach maximu or EOF */
|
||||
/* loop reading data until we reach maximum or EOF */
|
||||
total = 0;
|
||||
while (total < maximum && status != SANE_STATUS_EOF)
|
||||
{
|
||||
|
@ -6882,6 +6882,7 @@ genesys_buffer_image(Genesys_Scanner *s)
|
|||
if (dev->model->is_sheetfed == SANE_FALSE)
|
||||
{
|
||||
dev->model->cmd_set->slow_back_home (dev, dev->model->flags & GENESYS_FLAG_MUST_WAIT);
|
||||
dev->parking = !(s->dev->model->flags & GENESYS_FLAG_MUST_WAIT);
|
||||
}
|
||||
|
||||
/* update counters */
|
||||
|
@ -7180,7 +7181,7 @@ sane_close (SANE_Handle handle)
|
|||
}
|
||||
if (!s)
|
||||
{
|
||||
DBG (DBG_error, "close: invalid handle %p\n", handle);
|
||||
DBG (DBG_error, "sane_close: invalid handle %p\n", handle);
|
||||
return; /* oops, not a handle we know about */
|
||||
}
|
||||
|
||||
|
@ -7191,23 +7192,17 @@ sane_close (SANE_Handle handle)
|
|||
}
|
||||
else
|
||||
{
|
||||
/* if no MUST_WAIT flag, the head may be parking asynchronously
|
||||
* so we wait it to head at home */
|
||||
if(!(s->dev->model->flags & GENESYS_FLAG_MUST_WAIT))
|
||||
/* in case scanner is parking, wait for the head
|
||||
* to reach home position */
|
||||
if(s->dev->parking==SANE_TRUE)
|
||||
{
|
||||
loop=0;
|
||||
do
|
||||
{
|
||||
usleep (100000); /* sleep 100 ms */
|
||||
status = sanei_genesys_get_status (s->dev, &val);
|
||||
status = sanei_genesys_wait_for_home (s->dev);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG (DBG_error,
|
||||
"sane_close: failed to read home sensor: %s\n",
|
||||
"sane_close: failed to wait for head to park: %s\n",
|
||||
sane_strstatus (status));
|
||||
}
|
||||
++loop;
|
||||
} while(loop<300 && !(val & HOMESNR) && status==SANE_STATUS_GOOD);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7965,6 +7960,9 @@ sane_cancel (SANE_Handle handle)
|
|||
s->dev->img_buffer=NULL;
|
||||
}
|
||||
|
||||
/* no need to end scan if we are parking the head */
|
||||
if(s->dev->parking==SANE_FALSE)
|
||||
{
|
||||
status = s->dev->model->cmd_set->end_scan (s->dev, s->dev->reg, SANE_TRUE);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
|
@ -7972,9 +7970,12 @@ sane_cancel (SANE_Handle handle)
|
|||
sane_strstatus (status));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* park head if flatbed scanner */
|
||||
if (s->dev->model->is_sheetfed == SANE_FALSE)
|
||||
{
|
||||
if(s->dev->parking==SANE_FALSE)
|
||||
{
|
||||
status = s->dev->model->cmd_set->slow_back_home (s->dev, s->dev->model->flags & GENESYS_FLAG_MUST_WAIT);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
|
@ -7984,6 +7985,8 @@ sane_cancel (SANE_Handle handle)
|
|||
sane_strstatus (status));
|
||||
return;
|
||||
}
|
||||
s->dev->parking = !(s->dev->model->flags & GENESYS_FLAG_MUST_WAIT);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ /* in case of sheetfed scanners, we have to eject the document if still present */
|
||||
|
|
|
@ -1069,6 +1069,9 @@ sanei_genesys_wait_for_home (Genesys_Device * dev)
|
|||
|
||||
DBGSTART;
|
||||
|
||||
/* clearthe parking status whatever the outcome of the function */
|
||||
dev->parking=SANE_FALSE;
|
||||
|
||||
/* read initial status, if head isn't at home and motor is on
|
||||
* we are parking, so we wait.
|
||||
* gl847/gl124 need 2 reads for reliable results */
|
||||
|
|
|
@ -633,6 +633,7 @@ struct Genesys_Device
|
|||
SANE_Int lamp_off_time;
|
||||
|
||||
SANE_Bool read_active;
|
||||
SANE_Bool parking; /**> signal wether the park command has been issued */
|
||||
SANE_Bool document; /**> for sheetfed scanner's, is TRUE when there
|
||||
is a document in the scanner */
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue