kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Fix error handling in the presence of exceptions
rodzic
3050f50b25
commit
89d06c9a3a
|
@ -3026,22 +3026,18 @@ genesys_send_shading_coefficient(Genesys_Device * dev, const Genesys_Sensor& sen
|
|||
* search calibration cache list for an entry matching required scan.
|
||||
* If one is found, set device calibration with it
|
||||
* @param dev scanner's device
|
||||
* @return SANE_STATUS_UNSUPPORTED if no matching cache entry has been
|
||||
* found, SANE_STATUS_GOOD if one has been found and used.
|
||||
* @return false if no matching cache entry has been
|
||||
* found, true if one has been found and used.
|
||||
*/
|
||||
static SANE_Status
|
||||
static bool
|
||||
genesys_restore_calibration(Genesys_Device * dev, Genesys_Sensor& sensor)
|
||||
{
|
||||
// TODO: reindent
|
||||
|
||||
SANE_Status status;
|
||||
|
||||
DBGSTART;
|
||||
|
||||
/* if no cache or no function to evaluate cache entry ther can be no match */
|
||||
if (!dev->model->cmd_set->is_compatible_calibration
|
||||
|| dev->calibration_cache.empty())
|
||||
return SANE_STATUS_UNSUPPORTED;
|
||||
return false;
|
||||
|
||||
/* we walk the link list of calibration cache in search for a
|
||||
* matching one */
|
||||
|
@ -3062,21 +3058,15 @@ genesys_restore_calibration(Genesys_Device * dev, Genesys_Sensor& sensor)
|
|||
|
||||
if(dev->model->cmd_set->send_shading_data==NULL)
|
||||
{
|
||||
status = genesys_send_shading_coefficient(dev, sensor);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to send shading calibration coefficients: %s\n",
|
||||
__func__, sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
TIE(genesys_send_shading_coefficient(dev, sensor));
|
||||
}
|
||||
|
||||
DBG(DBG_proc, "%s: restored\n", __func__);
|
||||
return SANE_STATUS_GOOD;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
DBG(DBG_proc, "%s: completed(nothing found)\n", __func__);
|
||||
return SANE_STATUS_UNSUPPORTED;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -3370,12 +3360,17 @@ static SANE_Status genesys_sheetfed_calibration(Genesys_Device * dev, Genesys_Se
|
|||
/* the afe needs to sends valid data even before calibration */
|
||||
|
||||
/* go to a white area */
|
||||
status = dev->model->cmd_set->search_strip(dev, sensor, forward, SANE_FALSE);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to find white strip: %s\n", __func__, sane_strstatus(status));
|
||||
dev->model->cmd_set->eject_document (dev);
|
||||
return status;
|
||||
try {
|
||||
status = dev->model->cmd_set->search_strip(dev, sensor, forward, SANE_FALSE);
|
||||
if (status != SANE_STATUS_GOOD) {
|
||||
DBG(DBG_error, "%s: failed to find white strip: %s\n", __func__,
|
||||
sane_strstatus(status));
|
||||
dev->model->cmd_set->eject_document (dev);
|
||||
return status;
|
||||
}
|
||||
} catch (...) {
|
||||
dev->model->cmd_set->eject_document(dev);
|
||||
throw;
|
||||
}
|
||||
|
||||
if (dev->model->is_cis)
|
||||
|
@ -3432,13 +3427,18 @@ static SANE_Status genesys_sheetfed_calibration(Genesys_Device * dev, Genesys_Se
|
|||
if (dev->model->flags & GENESYS_FLAG_DARK_CALIBRATION)
|
||||
{
|
||||
/* seek black/white reverse/forward */
|
||||
status = dev->model->cmd_set->search_strip(dev, sensor, forward, SANE_TRUE);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to find black strip: %s\n", __func__, sane_strstatus(status));
|
||||
dev->model->cmd_set->eject_document (dev);
|
||||
return status;
|
||||
}
|
||||
try {
|
||||
status = dev->model->cmd_set->search_strip(dev, sensor, forward, SANE_TRUE);
|
||||
if (status != SANE_STATUS_GOOD) {
|
||||
DBG(DBG_error, "%s: failed to find black strip: %s\n", __func__,
|
||||
sane_strstatus(status));
|
||||
dev->model->cmd_set->eject_document(dev);
|
||||
return status;
|
||||
}
|
||||
} catch (...) {
|
||||
dev->model->cmd_set->eject_document(dev);
|
||||
throw;
|
||||
}
|
||||
|
||||
status = dev->model->cmd_set->init_regs_for_shading(dev, sensor, dev->calib_reg);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
|
@ -3447,25 +3447,34 @@ static SANE_Status genesys_sheetfed_calibration(Genesys_Device * dev, Genesys_Se
|
|||
__func__, sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
status = genesys_dark_shading_calibration(dev, sensor);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
dev->model->cmd_set->eject_document (dev);
|
||||
DBG(DBG_error, "%s: failed to do dark shading calibration: %s\n", __func__,
|
||||
sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
try {
|
||||
status = genesys_dark_shading_calibration(dev, sensor);
|
||||
if (status != SANE_STATUS_GOOD) {
|
||||
dev->model->cmd_set->eject_document(dev);
|
||||
DBG(DBG_error, "%s: failed to do dark shading calibration: %s\n", __func__,
|
||||
sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
} catch (...) {
|
||||
dev->model->cmd_set->eject_document(dev);
|
||||
throw;
|
||||
}
|
||||
forward = SANE_FALSE;
|
||||
}
|
||||
|
||||
|
||||
/* go to a white area */
|
||||
status = dev->model->cmd_set->search_strip(dev, sensor, forward, SANE_FALSE);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to find white strip: %s\n", __func__, sane_strstatus(status));
|
||||
dev->model->cmd_set->eject_document (dev);
|
||||
return status;
|
||||
try {
|
||||
status = dev->model->cmd_set->search_strip(dev, sensor, forward, SANE_FALSE);
|
||||
if (status != SANE_STATUS_GOOD) {
|
||||
DBG(DBG_error, "%s: failed to find white strip: %s\n", __func__,
|
||||
sane_strstatus(status));
|
||||
dev->model->cmd_set->eject_document (dev);
|
||||
return status;
|
||||
}
|
||||
} catch (...) {
|
||||
dev->model->cmd_set->eject_document (dev);
|
||||
throw;
|
||||
}
|
||||
|
||||
status = dev->model->cmd_set->init_regs_for_shading(dev, sensor, dev->calib_reg);
|
||||
|
@ -3475,12 +3484,17 @@ static SANE_Status genesys_sheetfed_calibration(Genesys_Device * dev, Genesys_Se
|
|||
sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
status = genesys_white_shading_calibration(dev, sensor);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
dev->model->cmd_set->eject_document (dev);
|
||||
DBG(DBG_error, "%s: failed eject target: %s\n", __func__, sane_strstatus(status));
|
||||
return status;
|
||||
|
||||
try {
|
||||
status = genesys_white_shading_calibration(dev, sensor);
|
||||
if (status != SANE_STATUS_GOOD) {
|
||||
dev->model->cmd_set->eject_document(dev);
|
||||
DBG(DBG_error, "%s: failed eject target: %s\n", __func__, sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
} catch (...) {
|
||||
dev->model->cmd_set->eject_document (dev);
|
||||
throw;
|
||||
}
|
||||
|
||||
/* in case we haven't black shading data, build it from black pixels
|
||||
|
@ -3619,11 +3633,14 @@ genesys_warmup_lamp (Genesys_Device * dev)
|
|||
}
|
||||
while (empty);
|
||||
|
||||
status = sanei_genesys_read_data_from_scanner(dev, first_line.data(), total_size);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
RIE(sanei_genesys_read_data_from_scanner(dev, first_line.data(), total_size));
|
||||
}
|
||||
try {
|
||||
status = sanei_genesys_read_data_from_scanner(dev, first_line.data(), total_size);
|
||||
if (status != SANE_STATUS_GOOD) {
|
||||
RIE(sanei_genesys_read_data_from_scanner(dev, first_line.data(), total_size));
|
||||
}
|
||||
} catch (...) {
|
||||
RIE(sanei_genesys_read_data_from_scanner(dev, first_line.data(), total_size));
|
||||
}
|
||||
|
||||
RIE(dev->model->cmd_set->end_scan(dev, &dev->reg, SANE_TRUE));
|
||||
|
||||
|
@ -3830,8 +3847,7 @@ genesys_start_scan (Genesys_Device * dev, SANE_Bool lamp_off)
|
|||
}
|
||||
|
||||
/* try to use cached calibration first */
|
||||
status = genesys_restore_calibration (dev, sensor);
|
||||
if (status == SANE_STATUS_UNSUPPORTED)
|
||||
if (!genesys_restore_calibration (dev, sensor))
|
||||
{
|
||||
/* calibration : sheetfed scanners can't calibrate before each scan */
|
||||
/* and also those who have the NO_CALIBRATION flag */
|
||||
|
@ -3853,11 +3869,6 @@ genesys_start_scan (Genesys_Device * dev, SANE_Bool lamp_off)
|
|||
DBG(DBG_warn, "%s: no calibration done\n", __func__);
|
||||
}
|
||||
}
|
||||
else if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to restore calibration: %s\n", __func__, sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
|
||||
/* build look up table for dynamic lineart */
|
||||
if(dev->settings.dynamic_lineart==SANE_TRUE)
|
||||
|
@ -6138,11 +6149,12 @@ genesys_buffer_image(Genesys_Scanner *s)
|
|||
{
|
||||
len = read_size;
|
||||
}
|
||||
|
||||
status = genesys_read_ordered_data(dev, dev->img_buffer.data() + total, &len);
|
||||
if (status != SANE_STATUS_EOF && status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: %s buffering failed\n", __func__, sane_strstatus(status));
|
||||
return status;
|
||||
{
|
||||
DBG(DBG_error, "%s: %s buffering failed\n", __func__, sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
total += len;
|
||||
|
||||
|
|
|
@ -346,7 +346,7 @@ genesys_crop(Genesys_Scanner *s)
|
|||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG (DBG_info, "%s: bad or no edges, bailing\n", __func__);
|
||||
goto cleanup;
|
||||
return SANE_STATUS_GOOD;
|
||||
}
|
||||
DBG (DBG_io, "%s: t:%d b:%d l:%d r:%d\n", __func__, top, bottom, left,
|
||||
right);
|
||||
|
@ -357,13 +357,12 @@ genesys_crop(Genesys_Scanner *s)
|
|||
if (status)
|
||||
{
|
||||
DBG (DBG_warn, "%s: failed to crop\n", __func__);
|
||||
goto cleanup;
|
||||
return SANE_STATUS_GOOD;
|
||||
}
|
||||
|
||||
/* update counters to new image size */
|
||||
dev->total_bytes_to_read = s->params.bytes_per_line * s->params.lines;
|
||||
|
||||
cleanup:
|
||||
DBG (DBG_proc, "%s: completed\n", __func__);
|
||||
return SANE_STATUS_GOOD;
|
||||
}
|
||||
|
|
|
@ -2002,14 +2002,27 @@ gl124_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
|
|||
|
||||
RIE(gl124_setup_scan_gpio(dev,resolution));
|
||||
|
||||
status = gl124_start_action (dev);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status));
|
||||
gl124_stop_action (dev);
|
||||
/* restore original registers */
|
||||
dev->model->cmd_set->bulk_write_register(dev, dev->reg);
|
||||
return status;
|
||||
try {
|
||||
status = gl124_start_action (dev);
|
||||
} catch (...) {
|
||||
DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status));
|
||||
try {
|
||||
gl124_stop_action (dev);
|
||||
} catch (...) {}
|
||||
try {
|
||||
// restore original registers
|
||||
dev->model->cmd_set->bulk_write_register(dev, dev->reg);
|
||||
} catch (...) {}
|
||||
throw;
|
||||
}
|
||||
if (status != SANE_STATUS_GOOD) {
|
||||
DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status));
|
||||
try {
|
||||
gl124_stop_action (dev);
|
||||
} catch (...) {}
|
||||
/* restore original registers */
|
||||
dev->model->cmd_set->bulk_write_register(dev, dev->reg);
|
||||
return status;
|
||||
}
|
||||
|
||||
/* post scan gpio : without that HOMSNR is unreliable */
|
||||
|
@ -3152,7 +3165,14 @@ gl124_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
|
||||
status = gl124_init_scan_regs(dev, sensor, ®s, params);
|
||||
try {
|
||||
status = gl124_init_scan_regs(dev, sensor, ®s, params);
|
||||
} catch (...) {
|
||||
try {
|
||||
sanei_genesys_set_motor_power(regs, false);
|
||||
} catch (...) {}
|
||||
throw;
|
||||
}
|
||||
|
||||
sanei_genesys_set_motor_power(regs, false);
|
||||
|
||||
|
|
|
@ -93,12 +93,14 @@ static SANE_Status
|
|||
gl646_bulk_read_data (Genesys_Device * dev, uint8_t addr,
|
||||
uint8_t * data, size_t len)
|
||||
{
|
||||
SANE_Status status = sanei_genesys_bulk_read_data(dev, addr, data, len);
|
||||
if (status == SANE_STATUS_GOOD && dev->model->is_sheetfed == SANE_TRUE)
|
||||
{
|
||||
gl646_detect_document_end (dev);
|
||||
SANE_Status status = sanei_genesys_bulk_read_data(dev, addr, data, len);
|
||||
if (status != SANE_STATUS_GOOD) {
|
||||
return status;
|
||||
}
|
||||
return status;
|
||||
if (dev->model->is_sheetfed == SANE_TRUE) {
|
||||
gl646_detect_document_end (dev);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
static SANE_Bool
|
||||
|
@ -1854,8 +1856,10 @@ gl646_set_powersaving (Genesys_Device * dev, int delay /* in minutes */ )
|
|||
local_reg.find_reg(0x39).value = exposure_time & 255;
|
||||
|
||||
status = sanei_genesys_bulk_write_register(dev, local_reg);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
if (status != SANE_STATUS_GOOD) {
|
||||
DBG(DBG_error, "%s: Failed to bulk write registers: %s\n", __func__, sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
|
||||
DBG(DBG_proc, "%s: end\n", __func__);
|
||||
return status;
|
||||
|
@ -2229,12 +2233,12 @@ gl646_eject_document (Genesys_Device * dev)
|
|||
do
|
||||
{
|
||||
status = sanei_genesys_get_status (dev, &state);
|
||||
print_status (state);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to read status: %s\n", __func__, sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
print_status (state);
|
||||
sanei_genesys_sleep_ms(200);
|
||||
count++;
|
||||
}
|
||||
|
@ -2532,7 +2536,11 @@ gl646_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
|
|||
}
|
||||
|
||||
/* write scan registers */
|
||||
status = sanei_genesys_bulk_write_register(dev, dev->reg);
|
||||
try {
|
||||
status = sanei_genesys_bulk_write_register(dev, dev->reg);
|
||||
} catch (...) {
|
||||
DBG(DBG_error, "%s: failed to bulk write registers\n", __func__);
|
||||
}
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status));
|
||||
|
||||
|
@ -2631,38 +2639,36 @@ gl646_search_start_position (Genesys_Device * dev)
|
|||
status = simple_scan(dev, sensor, settings, SANE_TRUE, SANE_TRUE, SANE_FALSE, data);
|
||||
|
||||
/* process data if scan is OK */
|
||||
if (status == SANE_STATUS_GOOD)
|
||||
{
|
||||
/* handle stagger case : reorder gray data and thus loose some lines */
|
||||
if (dev->current_setup.stagger > 0)
|
||||
{
|
||||
DBG(DBG_proc, "%s: 'un-staggering'\n", __func__);
|
||||
for (y = 0; y < settings.lines - dev->current_setup.stagger; y++)
|
||||
{
|
||||
/* one point out of 2 is 'unaligned' */
|
||||
for (x = 0; x < settings.pixels; x += 2)
|
||||
{
|
||||
data[y * settings.pixels + x] =
|
||||
data[(y + dev->current_setup.stagger) * settings.pixels +
|
||||
x];
|
||||
}
|
||||
}
|
||||
/* correct line number */
|
||||
settings.lines -= dev->current_setup.stagger;
|
||||
}
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
sanei_genesys_write_pnm_file("gl646_search_position.pnm", data.data(), settings.depth, 1,
|
||||
settings.pixels, settings.lines);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG(DBG_error, "%s: simple_scan failed\n", __func__);
|
||||
DBGCOMPLETED;
|
||||
return status;
|
||||
if (status != SANE_STATUS_GOOD) {
|
||||
DBG(DBG_error, "%s: simple_scan failed\n", __func__);
|
||||
DBGCOMPLETED;
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/* handle stagger case : reorder gray data and thus loose some lines */
|
||||
if (dev->current_setup.stagger > 0)
|
||||
{
|
||||
DBG(DBG_proc, "%s: 'un-staggering'\n", __func__);
|
||||
for (y = 0; y < settings.lines - dev->current_setup.stagger; y++)
|
||||
{
|
||||
/* one point out of 2 is 'unaligned' */
|
||||
for (x = 0; x < settings.pixels; x += 2)
|
||||
{
|
||||
data[y * settings.pixels + x] =
|
||||
data[(y + dev->current_setup.stagger) * settings.pixels +
|
||||
x];
|
||||
}
|
||||
}
|
||||
/* correct line number */
|
||||
settings.lines -= dev->current_setup.stagger;
|
||||
}
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
sanei_genesys_write_pnm_file("gl646_search_position.pnm", data.data(), settings.depth, 1,
|
||||
settings.pixels, settings.lines);
|
||||
}
|
||||
|
||||
/* now search reference points on the data */
|
||||
status =
|
||||
sanei_genesys_search_reference_point (dev, sensor, data.data(),
|
||||
|
@ -4041,6 +4047,7 @@ gl646_init (Genesys_Device * dev)
|
|||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: GPO enable failed ... %s\n", __func__, sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
val = 0;
|
||||
|
||||
|
@ -4049,6 +4056,7 @@ gl646_init (Genesys_Device * dev)
|
|||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: GPO write failed ... %s\n", __func__, sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
|
||||
/* clear GPIO enable */
|
||||
|
@ -4056,6 +4064,7 @@ gl646_init (Genesys_Device * dev)
|
|||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: GPO disable failed ... %s\n", __func__, sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
sanei_genesys_write_register (dev, 0x66, 0x10);
|
||||
sanei_genesys_write_register (dev, 0x66, 0x00);
|
||||
|
@ -4132,11 +4141,7 @@ gl646_init (Genesys_Device * dev)
|
|||
{
|
||||
DBG(DBG_error0, "Your scanner is locked. Please move the lock switch to the "
|
||||
"unlocked position\n");
|
||||
#ifdef SANE_STATUS_HW_LOCKED
|
||||
return SANE_STATUS_HW_LOCKED;
|
||||
#else
|
||||
return SANE_STATUS_JAMMED;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
DBG(DBG_error, "%s: gl646_repark_head failed: %s\n", __func__,
|
||||
|
|
|
@ -1031,22 +1031,6 @@ gl841_set_fe(Genesys_Device * dev, const Genesys_Sensor& sensor, uint8_t set)
|
|||
{
|
||||
DBG(DBG_error, "%s: reset fe failed: %s\n", __func__, sane_strstatus(status));
|
||||
return status;
|
||||
/*
|
||||
if (dev->model->ccd_type == CCD_HP2300
|
||||
|| dev->model->ccd_type == CCD_HP2400)
|
||||
{
|
||||
val = 0x07;
|
||||
status =
|
||||
sanei_usb_control_msg (dev->dn, REQUEST_TYPE_OUT,
|
||||
REQUEST_REGISTER, GPIO_OUTPUT_ENABLE,
|
||||
INDEX, 1, &val);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s failed resetting frontend: %s\n", __func__,
|
||||
sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
DBG(DBG_proc, "%s(): frontend reset complete\n", __func__);
|
||||
}
|
||||
|
@ -1055,8 +1039,10 @@ gl841_set_fe(Genesys_Device * dev, const Genesys_Sensor& sensor, uint8_t set)
|
|||
if (set == AFE_POWER_SAVE)
|
||||
{
|
||||
status = sanei_genesys_fe_write_data (dev, 0x01, 0x02);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
if (status != SANE_STATUS_GOOD) {
|
||||
DBG(DBG_error, "%s: writing data failed: %s\n", __func__, sane_strstatus(status));
|
||||
return status;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -3009,8 +2995,21 @@ gl841_eject_document (Genesys_Device * dev)
|
|||
return status;
|
||||
}
|
||||
|
||||
status = gl841_start_action (dev);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
try {
|
||||
status = gl841_start_action (dev);
|
||||
} catch (...) {
|
||||
DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status));
|
||||
try {
|
||||
gl841_stop_action(dev);
|
||||
} catch (...) {}
|
||||
try {
|
||||
// restore original registers
|
||||
sanei_genesys_bulk_write_register(dev, dev->reg);
|
||||
} catch (...) {}
|
||||
throw;
|
||||
}
|
||||
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status));
|
||||
gl841_stop_action (dev);
|
||||
|
@ -3169,8 +3168,15 @@ gl841_detect_document_end (Genesys_Device * dev)
|
|||
* might have been slow to read data, so we re-evaluate the
|
||||
* amount of data to scan form the hardware settings
|
||||
*/
|
||||
status=sanei_genesys_read_scancnt(dev,&scancnt);
|
||||
if(status!=SANE_STATUS_GOOD)
|
||||
try {
|
||||
status = sanei_genesys_read_scancnt(dev, &scancnt);
|
||||
} catch (...) {
|
||||
dev->total_bytes_to_read = dev->total_bytes_read;
|
||||
dev->read_bytes_left = 0;
|
||||
throw;
|
||||
}
|
||||
|
||||
if(status!=SANE_STATUS_GOOD)
|
||||
{
|
||||
dev->total_bytes_to_read = dev->total_bytes_read;
|
||||
dev->read_bytes_left = 0;
|
||||
|
@ -3326,7 +3332,20 @@ gl841_feed (Genesys_Device * dev, int steps)
|
|||
return status;
|
||||
}
|
||||
|
||||
status = gl841_start_action (dev);
|
||||
try {
|
||||
status = gl841_start_action (dev);
|
||||
} catch (...) {
|
||||
DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status));
|
||||
try {
|
||||
gl841_stop_action (dev);
|
||||
} catch (...) {}
|
||||
try {
|
||||
// send original registers
|
||||
sanei_genesys_bulk_write_register(dev, dev->reg);
|
||||
} catch (...) {}
|
||||
throw;
|
||||
}
|
||||
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -3461,7 +3480,19 @@ gl841_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
|
|||
|
||||
RIE (sanei_genesys_bulk_write_register(dev, local_reg));
|
||||
|
||||
status = gl841_start_action (dev);
|
||||
try {
|
||||
status = gl841_start_action (dev);
|
||||
} catch (...) {
|
||||
DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status));
|
||||
try {
|
||||
gl841_stop_action(dev);
|
||||
} catch (...) {}
|
||||
try {
|
||||
sanei_genesys_bulk_write_register(dev, dev->reg);
|
||||
} catch (...) {}
|
||||
throw;
|
||||
}
|
||||
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -4789,11 +4820,7 @@ gl841_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
DBG (DBG_error0, "**** ****\n");
|
||||
DBG (DBG_error0, "**********************************************\n");
|
||||
DBG (DBG_error0, "**********************************************\n");
|
||||
#ifdef SANE_STATUS_HW_LOCKED
|
||||
return SANE_STATUS_HW_LOCKED;
|
||||
#else
|
||||
return SANE_STATUS_JAMMED;
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1948,7 +1948,11 @@ gl843_detect_document_end (Genesys_Device * dev)
|
|||
DBG(DBG_io, "%s: read_bytes_left=%d\n", __func__, read_bytes_left);
|
||||
|
||||
/* get lines read */
|
||||
status = sanei_genesys_read_scancnt (dev, &scancnt);
|
||||
try {
|
||||
status = sanei_genesys_read_scancnt(dev, &scancnt);
|
||||
} catch (...) {
|
||||
flines = 0;
|
||||
}
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
flines = 0;
|
||||
|
@ -2330,7 +2334,19 @@ static SANE_Status gl843_park_xpa_lamp (Genesys_Device * dev)
|
|||
/* write to scanner and start action */
|
||||
RIE (dev->model->cmd_set->bulk_write_register(dev, local_reg));
|
||||
RIE(gl843_set_xpa_motor_power(dev, true));
|
||||
status = gl843_start_action (dev);
|
||||
try {
|
||||
status = gl843_start_action (dev);
|
||||
} catch (...) {
|
||||
DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status));
|
||||
try {
|
||||
gl843_stop_action(dev);
|
||||
} catch (...) {}
|
||||
try {
|
||||
// restore original registers
|
||||
dev->model->cmd_set->bulk_write_register(dev, dev->reg);
|
||||
} catch (...) {}
|
||||
throw;
|
||||
}
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -2464,7 +2480,19 @@ gl843_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
|
|||
|
||||
RIE (dev->model->cmd_set->bulk_write_register(dev, local_reg));
|
||||
|
||||
status = gl843_start_action (dev);
|
||||
try {
|
||||
status = gl843_start_action (dev);
|
||||
} catch (...) {
|
||||
DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status));
|
||||
try {
|
||||
gl843_stop_action(dev);
|
||||
} catch (...) {}
|
||||
try {
|
||||
// restore original registers
|
||||
dev->model->cmd_set->bulk_write_register(dev, dev->reg);
|
||||
} catch (...) {}
|
||||
throw;
|
||||
}
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -2747,7 +2775,19 @@ gl843_feed (Genesys_Device * dev, unsigned int steps)
|
|||
/* send registers */
|
||||
RIE (dev->model->cmd_set->bulk_write_register(dev, local_reg));
|
||||
|
||||
status = gl843_start_action (dev);
|
||||
try {
|
||||
status = gl843_start_action (dev);
|
||||
} catch (...) {
|
||||
DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status));
|
||||
try {
|
||||
gl843_stop_action(dev);
|
||||
} catch (...) {}
|
||||
try {
|
||||
// restore original registers
|
||||
dev->model->cmd_set->bulk_write_register(dev, dev->reg);
|
||||
} catch (...) {}
|
||||
throw;
|
||||
}
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -3554,7 +3594,15 @@ gl843_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
gl843_compute_session(dev, session, calib_sensor);
|
||||
pixels = session.output_pixels;
|
||||
|
||||
status = gl843_init_scan_regs(dev, calib_sensor, ®s, session);
|
||||
try {
|
||||
status = gl843_init_scan_regs(dev, calib_sensor, ®s, session);
|
||||
} catch (...) {
|
||||
try {
|
||||
sanei_genesys_set_motor_power(regs, false);
|
||||
} catch (...) {}
|
||||
throw;
|
||||
}
|
||||
|
||||
sanei_genesys_set_motor_power(regs, false);
|
||||
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
|
|
|
@ -1731,7 +1731,19 @@ gl846_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
|
|||
|
||||
RIE (dev->model->cmd_set->bulk_write_register(dev, local_reg));
|
||||
|
||||
status = gl846_start_action (dev);
|
||||
try {
|
||||
status = gl846_start_action(dev);
|
||||
} catch (...) {
|
||||
DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status));
|
||||
try {
|
||||
gl846_stop_action(dev);
|
||||
} catch (...) {}
|
||||
try {
|
||||
// restore original registers
|
||||
dev->model->cmd_set->bulk_write_register(dev, dev->reg);
|
||||
} catch (...) {}
|
||||
throw;
|
||||
}
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -2016,7 +2028,19 @@ gl846_feed (Genesys_Device * dev, unsigned int steps)
|
|||
/* send registers */
|
||||
RIE (dev->model->cmd_set->bulk_write_register(dev, local_reg));
|
||||
|
||||
status = gl846_start_action (dev);
|
||||
try {
|
||||
status = gl846_start_action (dev);
|
||||
} catch (...) {
|
||||
DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status));
|
||||
try {
|
||||
gl846_stop_action(dev);
|
||||
} catch (...) {}
|
||||
try {
|
||||
// restore original registers
|
||||
dev->model->cmd_set->bulk_write_register(dev, dev->reg);
|
||||
} catch (...) {}
|
||||
throw;
|
||||
}
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -3225,9 +3249,14 @@ gl846_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
|
||||
status = gl846_init_scan_regs(dev, sensor, ®s, params);
|
||||
|
||||
sanei_genesys_set_motor_power(regs, false);
|
||||
try {
|
||||
status = gl846_init_scan_regs(dev, sensor, ®s, params);
|
||||
} catch (...) {
|
||||
try {
|
||||
sanei_genesys_set_motor_power(regs, false);
|
||||
} catch (...) {}
|
||||
throw;
|
||||
}
|
||||
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
|
|
|
@ -1797,7 +1797,19 @@ gl847_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
|
|||
|
||||
RIE (dev->model->cmd_set->bulk_write_register(dev, local_reg));
|
||||
|
||||
status = gl847_start_action (dev);
|
||||
try {
|
||||
status = gl847_start_action (dev);
|
||||
} catch (...) {
|
||||
DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status));
|
||||
try {
|
||||
gl847_stop_action(dev);
|
||||
} catch (...) {}
|
||||
try {
|
||||
// restore original registers
|
||||
dev->model->cmd_set->bulk_write_register(dev, dev->reg);
|
||||
} catch (...) {}
|
||||
throw;
|
||||
}
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -2082,7 +2094,19 @@ gl847_feed (Genesys_Device * dev, unsigned int steps)
|
|||
/* send registers */
|
||||
RIE (dev->model->cmd_set->bulk_write_register(dev, local_reg));
|
||||
|
||||
status = gl847_start_action (dev);
|
||||
try {
|
||||
status = gl847_start_action (dev);
|
||||
} catch (...) {
|
||||
DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status));
|
||||
try {
|
||||
gl847_stop_action(dev);
|
||||
} catch (...) {}
|
||||
try {
|
||||
// restore original registers
|
||||
dev->model->cmd_set->bulk_write_register(dev, dev->reg);
|
||||
} catch (...) {}
|
||||
throw;
|
||||
}
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
{
|
||||
DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status));
|
||||
|
@ -3328,7 +3352,14 @@ gl847_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor
|
|||
SCAN_FLAG_SINGLE_LINE |
|
||||
SCAN_FLAG_IGNORE_LINE_DISTANCE;
|
||||
|
||||
status = gl847_init_scan_regs(dev, sensor, ®s, params);
|
||||
try {
|
||||
status = gl847_init_scan_regs(dev, sensor, ®s, params);
|
||||
} catch (...) {
|
||||
try {
|
||||
sanei_genesys_set_motor_power(regs, false);
|
||||
} catch (...) {}
|
||||
throw;
|
||||
}
|
||||
|
||||
sanei_genesys_set_motor_power(regs, false);
|
||||
|
||||
|
|
|
@ -1189,7 +1189,7 @@ SANE_Status sanei_genesys_bulk_write_register(Genesys_Device * dev, Genesys_Regi
|
|||
for (const auto& r : reg) {
|
||||
status = sanei_genesys_write_register (dev, r.address, r.value);
|
||||
if (status != SANE_STATUS_GOOD)
|
||||
break;
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue