kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Return errors as exceptions from *eject_document()
rodzic
0bc253de07
commit
a6cbb98069
|
@ -3278,7 +3278,7 @@ static SANE_Status genesys_sheetfed_calibration(Genesys_Device * dev, Genesys_Se
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
dev->model->cmd_set->eject_document(dev);
|
catch_all_exceptions(__func__, [&](){ dev->model->cmd_set->eject_document(dev); });
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3345,7 +3345,7 @@ static SANE_Status genesys_sheetfed_calibration(Genesys_Device * dev, Genesys_Se
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
dev->model->cmd_set->eject_document(dev);
|
catch_all_exceptions(__func__, [&](){ dev->model->cmd_set->eject_document(dev); });
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3365,7 +3365,7 @@ static SANE_Status genesys_sheetfed_calibration(Genesys_Device * dev, Genesys_Se
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
dev->model->cmd_set->eject_document(dev);
|
catch_all_exceptions(__func__, [&](){ dev->model->cmd_set->eject_document(dev); });
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
forward = SANE_FALSE;
|
forward = SANE_FALSE;
|
||||||
|
@ -3382,7 +3382,7 @@ static SANE_Status genesys_sheetfed_calibration(Genesys_Device * dev, Genesys_Se
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
dev->model->cmd_set->eject_document (dev);
|
catch_all_exceptions(__func__, [&](){ dev->model->cmd_set->eject_document(dev); });
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3404,7 +3404,7 @@ static SANE_Status genesys_sheetfed_calibration(Genesys_Device * dev, Genesys_Se
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
dev->model->cmd_set->eject_document (dev);
|
catch_all_exceptions(__func__, [&](){ dev->model->cmd_set->eject_document(dev); });
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3439,13 +3439,8 @@ static SANE_Status genesys_sheetfed_calibration(Genesys_Device * dev, Genesys_Se
|
||||||
/* save the calibration data */
|
/* save the calibration data */
|
||||||
genesys_save_calibration (dev, sensor);
|
genesys_save_calibration (dev, sensor);
|
||||||
|
|
||||||
/* and finally eject calibration sheet */
|
// and finally eject calibration sheet
|
||||||
status = dev->model->cmd_set->eject_document (dev);
|
dev->model->cmd_set->eject_document(dev);
|
||||||
if (status != SANE_STATUS_GOOD)
|
|
||||||
{
|
|
||||||
DBG(DBG_error, "%s: failed to eject document: %s\n", __func__, sane_strstatus(status));
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* resotre settings */
|
/* resotre settings */
|
||||||
dev->settings.xres = xres;
|
dev->settings.xres = xres;
|
||||||
|
@ -6227,7 +6222,7 @@ sane_close_impl(SANE_Handle handle)
|
||||||
/* eject document for sheetfed scanners */
|
/* eject document for sheetfed scanners */
|
||||||
if (s->dev->model->is_sheetfed == SANE_TRUE)
|
if (s->dev->model->is_sheetfed == SANE_TRUE)
|
||||||
{
|
{
|
||||||
s->dev->model->cmd_set->eject_document (s->dev);
|
catch_all_exceptions(__func__, [&](){ s->dev->model->cmd_set->eject_document(s->dev); });
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -7292,12 +7287,7 @@ void sane_cancel_impl(SANE_Handle handle)
|
||||||
}
|
}
|
||||||
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 */
|
||||||
status = s->dev->model->cmd_set->eject_document (s->dev);
|
s->dev->model->cmd_set->eject_document(s->dev);
|
||||||
if (status != SANE_STATUS_GOOD)
|
|
||||||
{
|
|
||||||
DBG(DBG_error, "%s: failed to eject document: %s\n", __func__, sane_strstatus(status));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* enable power saving mode unless we are parking .... */
|
/* enable power saving mode unless we are parking .... */
|
||||||
|
|
|
@ -1787,11 +1787,9 @@ gl646_detect_document_end (Genesys_Device * dev)
|
||||||
* TODO we currently rely on AGOHOME not being set for sheetfed scanners,
|
* TODO we currently rely on AGOHOME not being set for sheetfed scanners,
|
||||||
* maybe check this flag in eject to let the document being eject automaticaly
|
* maybe check this flag in eject to let the document being eject automaticaly
|
||||||
*/
|
*/
|
||||||
static SANE_Status
|
static void gl646_eject_document(Genesys_Device* dev)
|
||||||
gl646_eject_document (Genesys_Device * dev)
|
|
||||||
{
|
{
|
||||||
DBG_HELPER(dbg);
|
DBG_HELPER(dbg);
|
||||||
SANE_Status status = SANE_STATUS_GOOD;
|
|
||||||
|
|
||||||
// FIXME: SEQUENTIAL not really needed in this case
|
// FIXME: SEQUENTIAL not really needed in this case
|
||||||
Genesys_Register_Set regs((Genesys_Register_Set::SEQUENTIAL));
|
Genesys_Register_Set regs((Genesys_Register_Set::SEQUENTIAL));
|
||||||
|
@ -1822,7 +1820,7 @@ gl646_eject_document (Genesys_Device * dev)
|
||||||
dev->document = SANE_FALSE;
|
dev->document = SANE_FALSE;
|
||||||
DBG(DBG_info, "%s: no more document to eject\n", __func__);
|
DBG(DBG_info, "%s: no more document to eject\n", __func__);
|
||||||
DBG(DBG_proc, "%s: end\n", __func__);
|
DBG(DBG_proc, "%s: end\n", __func__);
|
||||||
return status;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// there is a document inserted, eject it
|
// there is a document inserted, eject it
|
||||||
|
@ -1892,8 +1890,6 @@ gl646_eject_document (Genesys_Device * dev)
|
||||||
gl646_gpio_read(dev->usb_dev, &gpio);
|
gl646_gpio_read(dev->usb_dev, &gpio);
|
||||||
|
|
||||||
DBG(DBG_info, "%s: GPIO=0x%02x\n", __func__, gpio);
|
DBG(DBG_info, "%s: GPIO=0x%02x\n", __func__, gpio);
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send the low-level scan command
|
// Send the low-level scan command
|
||||||
|
@ -1952,12 +1948,7 @@ end_scan (Genesys_Device * dev, Genesys_Register_Set * reg,
|
||||||
{
|
{
|
||||||
if (eject == SANE_TRUE && dev->document == SANE_TRUE)
|
if (eject == SANE_TRUE && dev->document == SANE_TRUE)
|
||||||
{
|
{
|
||||||
status = gl646_eject_document (dev);
|
gl646_eject_document(dev);
|
||||||
if (status != SANE_STATUS_GOOD)
|
|
||||||
{
|
|
||||||
DBG(DBG_error, "%s: failed to eject document\n", __func__);
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (check_stop)
|
if (check_stop)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2530,8 +2530,7 @@ static void gl841_get_paper_sensor(Genesys_Device* dev, SANE_Bool * paper_loaded
|
||||||
*paper_loaded = (val & 0x1) == 0;
|
*paper_loaded = (val & 0x1) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SANE_Status
|
static void gl841_eject_document(Genesys_Device* dev)
|
||||||
gl841_eject_document (Genesys_Device * dev)
|
|
||||||
{
|
{
|
||||||
DBG_HELPER(dbg);
|
DBG_HELPER(dbg);
|
||||||
Genesys_Register_Set local_reg;
|
Genesys_Register_Set local_reg;
|
||||||
|
@ -2545,7 +2544,7 @@ gl841_eject_document (Genesys_Device * dev)
|
||||||
{
|
{
|
||||||
DBG(DBG_proc, "%s: there is no \"eject sheet\"-concept for non sheet fed\n", __func__);
|
DBG(DBG_proc, "%s: there is no \"eject sheet\"-concept for non sheet fed\n", __func__);
|
||||||
DBG(DBG_proc, "%s: finished\n", __func__);
|
DBG(DBG_proc, "%s: finished\n", __func__);
|
||||||
return SANE_STATUS_GOOD;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2606,10 +2605,11 @@ gl841_eject_document (Genesys_Device * dev)
|
||||||
|
|
||||||
if (loop == 0)
|
if (loop == 0)
|
||||||
{
|
{
|
||||||
/* when we come here then the scanner needed too much time for this, so we better stop the motor */
|
// when we come here then the scanner needed too much time for this, so we better stop
|
||||||
gl841_stop_action (dev);
|
// the motor
|
||||||
DBG(DBG_error, "%s: timeout while waiting for scanhead to go home\n", __func__);
|
catch_all_exceptions(__func__, [&](){ gl841_stop_action(dev); });
|
||||||
return SANE_STATUS_IO_ERROR;
|
throw SaneException(SANE_STATUS_IO_ERROR,
|
||||||
|
"timeout while waiting for scanhead to go home");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2643,8 +2643,6 @@ gl841_eject_document (Genesys_Device * dev)
|
||||||
gl841_stop_action(dev);
|
gl841_stop_action(dev);
|
||||||
|
|
||||||
dev->document = SANE_FALSE;
|
dev->document = SANE_FALSE;
|
||||||
|
|
||||||
return SANE_STATUS_GOOD;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1775,13 +1775,10 @@ static void gl843_get_paper_sensor(Genesys_Device* dev, SANE_Bool * paper_loaded
|
||||||
*paper_loaded = (val & 0x1) == 0;
|
*paper_loaded = (val & 0x1) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SANE_Status
|
static void gl843_eject_document(Genesys_Device* dev)
|
||||||
gl843_eject_document (Genesys_Device * dev)
|
|
||||||
{
|
{
|
||||||
|
(void) dev;
|
||||||
DBG_HELPER(dbg);
|
DBG_HELPER(dbg);
|
||||||
if (dev == NULL)
|
|
||||||
return SANE_STATUS_INVAL;
|
|
||||||
return SANE_STATUS_GOOD;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1115,7 +1115,7 @@ struct Genesys_Command_Set
|
||||||
/**
|
/**
|
||||||
* eject document from scanner
|
* eject document from scanner
|
||||||
*/
|
*/
|
||||||
SANE_Status (*eject_document) (Genesys_Device * dev);
|
void (*eject_document) (Genesys_Device* dev);
|
||||||
/**
|
/**
|
||||||
* search for an black or white area in forward or reverse
|
* search for an black or white area in forward or reverse
|
||||||
* direction */
|
* direction */
|
||||||
|
|
Ładowanie…
Reference in New Issue