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;
|
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;
|
total = 0;
|
||||||
while (total < maximum && status != SANE_STATUS_EOF)
|
while (total < maximum && status != SANE_STATUS_EOF)
|
||||||
{
|
{
|
||||||
|
@ -6882,6 +6882,7 @@ genesys_buffer_image(Genesys_Scanner *s)
|
||||||
if (dev->model->is_sheetfed == SANE_FALSE)
|
if (dev->model->is_sheetfed == SANE_FALSE)
|
||||||
{
|
{
|
||||||
dev->model->cmd_set->slow_back_home (dev, dev->model->flags & GENESYS_FLAG_MUST_WAIT);
|
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 */
|
/* update counters */
|
||||||
|
@ -7180,7 +7181,7 @@ sane_close (SANE_Handle handle)
|
||||||
}
|
}
|
||||||
if (!s)
|
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 */
|
return; /* oops, not a handle we know about */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7191,24 +7192,18 @@ sane_close (SANE_Handle handle)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* if no MUST_WAIT flag, the head may be parking asynchronously
|
/* in case scanner is parking, wait for the head
|
||||||
* so we wait it to head at home */
|
* to reach home position */
|
||||||
if(!(s->dev->model->flags & GENESYS_FLAG_MUST_WAIT))
|
if(s->dev->parking==SANE_TRUE)
|
||||||
{
|
{
|
||||||
loop=0;
|
status = sanei_genesys_wait_for_home (s->dev);
|
||||||
do
|
if (status != SANE_STATUS_GOOD)
|
||||||
{
|
{
|
||||||
usleep (100000); /* sleep 100 ms */
|
DBG (DBG_error,
|
||||||
status = sanei_genesys_get_status (s->dev, &val);
|
"sane_close: failed to wait for head to park: %s\n",
|
||||||
if (status != SANE_STATUS_GOOD)
|
sane_strstatus (status));
|
||||||
{
|
}
|
||||||
DBG (DBG_error,
|
}
|
||||||
"sane_close: failed to read home sensor: %s\n",
|
|
||||||
sane_strstatus (status));
|
|
||||||
}
|
|
||||||
++loop;
|
|
||||||
} while(loop<300 && !(val & HOMESNR) && status==SANE_STATUS_GOOD);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* here is the place to store calibration cache */
|
/* here is the place to store calibration cache */
|
||||||
|
@ -7965,25 +7960,33 @@ sane_cancel (SANE_Handle handle)
|
||||||
s->dev->img_buffer=NULL;
|
s->dev->img_buffer=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = s->dev->model->cmd_set->end_scan (s->dev, s->dev->reg, SANE_TRUE);
|
/* no need to end scan if we are parking the head */
|
||||||
if (status != SANE_STATUS_GOOD)
|
if(s->dev->parking==SANE_FALSE)
|
||||||
{
|
{
|
||||||
DBG (DBG_error, "sane_cancel: failed to end scan: %s\n",
|
status = s->dev->model->cmd_set->end_scan (s->dev, s->dev->reg, SANE_TRUE);
|
||||||
sane_strstatus (status));
|
if (status != SANE_STATUS_GOOD)
|
||||||
return;
|
{
|
||||||
|
DBG (DBG_error, "sane_cancel: failed to end scan: %s\n",
|
||||||
|
sane_strstatus (status));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* park head if flatbed scanner */
|
/* park head if flatbed scanner */
|
||||||
if (s->dev->model->is_sheetfed == SANE_FALSE)
|
if (s->dev->model->is_sheetfed == SANE_FALSE)
|
||||||
{
|
{
|
||||||
status = s->dev->model->cmd_set->slow_back_home (s->dev, s->dev->model->flags & GENESYS_FLAG_MUST_WAIT);
|
if(s->dev->parking==SANE_FALSE)
|
||||||
if (status != SANE_STATUS_GOOD)
|
{
|
||||||
{
|
status = s->dev->model->cmd_set->slow_back_home (s->dev, s->dev->model->flags & GENESYS_FLAG_MUST_WAIT);
|
||||||
DBG (DBG_error,
|
if (status != SANE_STATUS_GOOD)
|
||||||
"sane_cancel: failed to move scanhead to home position: %s\n",
|
{
|
||||||
sane_strstatus (status));
|
DBG (DBG_error,
|
||||||
return;
|
"sane_cancel: failed to move scanhead to home position: %s\n",
|
||||||
}
|
sane_strstatus (status));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
s->dev->parking = !(s->dev->model->flags & GENESYS_FLAG_MUST_WAIT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /* in case of sheetfed scanners, we have to eject the document if still present */
|
{ /* 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;
|
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
|
/* read initial status, if head isn't at home and motor is on
|
||||||
* we are parking, so we wait.
|
* we are parking, so we wait.
|
||||||
* gl847/gl124 need 2 reads for reliable results */
|
* gl847/gl124 need 2 reads for reliable results */
|
||||||
|
|
|
@ -633,6 +633,7 @@ struct Genesys_Device
|
||||||
SANE_Int lamp_off_time;
|
SANE_Int lamp_off_time;
|
||||||
|
|
||||||
SANE_Bool read_active;
|
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
|
SANE_Bool document; /**> for sheetfed scanner's, is TRUE when there
|
||||||
is a document in the scanner */
|
is a document in the scanner */
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue