genesys: Return errors as exceptions from *slow_back_home()

merge-requests/104/head
Povilas Kanapickas 2019-07-20 11:02:01 +03:00
rodzic 075d733613
commit d75aa89c9f
12 zmienionych plików z 84 dodań i 124 usunięć

Wyświetl plik

@ -1884,7 +1884,7 @@ static void genesys_repark_sensor_before_shading(Genesys_Device* dev)
if (dev->model->cmd_set->rewind) { if (dev->model->cmd_set->rewind) {
TIE(dev->model->cmd_set->rewind(dev)); TIE(dev->model->cmd_set->rewind(dev));
} else { } else {
TIE(dev->model->cmd_set->slow_back_home(dev, SANE_TRUE)); dev->model->cmd_set->slow_back_home(dev, SANE_TRUE);
} }
if (dev->settings.scan_method == ScanMethod::TRANSPARENCY || if (dev->settings.scan_method == ScanMethod::TRANSPARENCY ||
@ -1987,7 +1987,7 @@ genesys_white_shading_calibration (Genesys_Device * dev, const Genesys_Sensor& s
if (dev->model->flags & GENESYS_FLAG_SHADING_REPARK) if (dev->model->flags & GENESYS_FLAG_SHADING_REPARK)
{ {
status = dev->model->cmd_set->slow_back_home (dev, SANE_TRUE); dev->model->cmd_set->slow_back_home(dev, SANE_TRUE);
} }
return status; return status;
@ -3684,13 +3684,7 @@ genesys_start_scan (Genesys_Device * dev, SANE_Bool lamp_off)
} }
dev->parking = SANE_FALSE; dev->parking = SANE_FALSE;
status = dev->model->cmd_set->slow_back_home (dev, SANE_TRUE); dev->model->cmd_set->slow_back_home (dev, SANE_TRUE);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: failed to move scanhead to home position: %s\n", __func__,
sane_strstatus(status));
return status;
}
dev->scanhead_position_in_steps = 0; dev->scanhead_position_in_steps = 0;
} }
else else
@ -3699,13 +3693,8 @@ genesys_start_scan (Genesys_Device * dev, SANE_Bool lamp_off)
/* TODO: check we can drop this since we cannot have the /* TODO: check we can drop this since we cannot have the
scanner's head wandering here */ scanner's head wandering here */
dev->parking = SANE_FALSE; dev->parking = SANE_FALSE;
status = dev->model->cmd_set->slow_back_home (dev, SANE_TRUE); dev->model->cmd_set->slow_back_home (dev, SANE_TRUE);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: failed to move scanhead to home position: %s\n", __func__,
sane_strstatus(status));
return status;
}
dev->scanhead_position_in_steps = 0; dev->scanhead_position_in_steps = 0;
} }
} }
@ -3793,7 +3782,7 @@ genesys_start_scan (Genesys_Device * dev, SANE_Bool lamp_off)
dev->model->cmd_set->needs_home_before_init_regs_for_scan(dev) && dev->model->cmd_set->needs_home_before_init_regs_for_scan(dev) &&
dev->model->cmd_set->slow_back_home) dev->model->cmd_set->slow_back_home)
{ {
RIE(dev->model->cmd_set->slow_back_home(dev, SANE_TRUE)); dev->model->cmd_set->slow_back_home(dev, SANE_TRUE);
} }
if (dev->settings.scan_method == ScanMethod::TRANSPARENCY || if (dev->settings.scan_method == ScanMethod::TRANSPARENCY ||
@ -4293,7 +4282,7 @@ genesys_read_ordered_data (Genesys_Device * dev, SANE_Byte * destination,
&& !(dev->model->flags & GENESYS_FLAG_MUST_WAIT) && !(dev->model->flags & GENESYS_FLAG_MUST_WAIT)
&& dev->parking == SANE_FALSE) && dev->parking == SANE_FALSE)
{ {
dev->model->cmd_set->slow_back_home (dev, SANE_FALSE); dev->model->cmd_set->slow_back_home(dev, SANE_FALSE);
dev->parking = SANE_TRUE; dev->parking = SANE_TRUE;
} }
return SANE_STATUS_EOF; return SANE_STATUS_EOF;
@ -5956,7 +5945,7 @@ genesys_buffer_image(Genesys_Scanner *s)
if (dev->model->is_sheetfed == SANE_FALSE && if (dev->model->is_sheetfed == SANE_FALSE &&
dev->parking == SANE_FALSE) dev->parking == 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); dev->parking = !(s->dev->model->flags & GENESYS_FLAG_MUST_WAIT);
} }
@ -7194,7 +7183,7 @@ sane_read_impl(SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_Int*
&& !(dev->model->flags & GENESYS_FLAG_MUST_WAIT) && !(dev->model->flags & GENESYS_FLAG_MUST_WAIT)
&& dev->parking == SANE_FALSE) && dev->parking == SANE_FALSE)
{ {
dev->model->cmd_set->slow_back_home (dev, SANE_FALSE); dev->model->cmd_set->slow_back_home(dev, SANE_FALSE);
dev->parking = SANE_TRUE; dev->parking = SANE_TRUE;
} }
return SANE_STATUS_EOF; return SANE_STATUS_EOF;
@ -7313,13 +7302,9 @@ void sane_cancel_impl(SANE_Handle handle)
{ {
if(s->dev->parking==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); s->dev->model->cmd_set->slow_back_home (s->dev, s->dev->model->flags &
if (status != SANE_STATUS_GOOD) GENESYS_FLAG_MUST_WAIT);
{
DBG(DBG_error, "%s: failed to move scanhead to home position: %s\n", __func__,
sane_strstatus(status));
return;
}
s->dev->parking = !(s->dev->model->flags & GENESYS_FLAG_MUST_WAIT); s->dev->parking = !(s->dev->model->flags & GENESYS_FLAG_MUST_WAIT);
} }
} }

Wyświetl plik

@ -1732,9 +1732,7 @@ SANE_Status gl124_rewind(Genesys_Device * dev)
* @param wait_until_home true to make the function waiting for head * @param wait_until_home true to make the function waiting for head
* to be home before returning, if fals returne immediately * to be home before returning, if fals returne immediately
* @returns SANE_STATUS_GOO on success */ * @returns SANE_STATUS_GOO on success */
static static void gl124_slow_back_home(Genesys_Device* dev, SANE_Bool wait_until_home)
SANE_Status
gl124_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
{ {
DBG_HELPER_ARGS(dbg, "wait_until_home = %d", wait_until_home); DBG_HELPER_ARGS(dbg, "wait_until_home = %d", wait_until_home);
Genesys_Register_Set local_reg; Genesys_Register_Set local_reg;
@ -1768,7 +1766,7 @@ gl124_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
{ {
DBG (DBG_info, "%s: already at home, completed\n", __func__); DBG (DBG_info, "%s: already at home, completed\n", __func__);
dev->scanhead_position_in_steps = 0; dev->scanhead_position_in_steps = 0;
return SANE_STATUS_GOOD; return;
} }
/* feed a little first */ /* feed a little first */
@ -1839,7 +1837,7 @@ gl124_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
{ {
DBG(DBG_info, "%s: reached home position\n", __func__); DBG(DBG_info, "%s: reached home position\n", __func__);
dev->scanhead_position_in_steps = 0; dev->scanhead_position_in_steps = 0;
return SANE_STATUS_GOOD; return;
} }
sanei_genesys_sleep_ms(100); sanei_genesys_sleep_ms(100);
++loop; ++loop;
@ -1847,12 +1845,10 @@ gl124_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
/* 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 the motor */
gl124_stop_action (dev); gl124_stop_action (dev);
DBG(DBG_error, "%s: timeout while waiting for scanhead to go home\n", __func__); throw SaneException(SANE_STATUS_IO_ERROR, "timeout while waiting for scanhead to go home");
return SANE_STATUS_IO_ERROR;
} }
DBG(DBG_info, "%s: scanhead is still moving\n", __func__); DBG(DBG_info, "%s: scanhead is still moving\n", __func__);
return SANE_STATUS_GOOD;
} }
/** @brief moves the slider to steps at motor base dpi /** @brief moves the slider to steps at motor base dpi
@ -2907,7 +2903,7 @@ gl124_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor
gl124_stop_action(dev); gl124_stop_action(dev);
status = gl124_slow_back_home (dev, SANE_TRUE); gl124_slow_back_home(dev, SANE_TRUE);
return status; return status;
} }

Wyświetl plik

@ -471,8 +471,7 @@ static void gl124_begin_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
static SANE_Status static SANE_Status
gl124_end_scan (Genesys_Device * dev, Genesys_Register_Set * reg, gl124_end_scan (Genesys_Device * dev, Genesys_Register_Set * reg,
SANE_Bool check_stop); SANE_Bool check_stop);
static SANE_Status static void gl124_slow_back_home(Genesys_Device* dev, SANE_Bool wait_until_home);
gl124_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home);
static SANE_Status gl124_init(Genesys_Device * dev); static SANE_Status gl124_init(Genesys_Device * dev);
static void gl124_send_shading_data(Genesys_Device* dev, const Genesys_Sensor& sensor, static void gl124_send_shading_data(Genesys_Device* dev, const Genesys_Sensor& sensor,
uint8_t* data, int size); uint8_t* data, int size);

Wyświetl plik

@ -2057,9 +2057,7 @@ gl646_end_scan (Genesys_Device * dev, Genesys_Register_Set * reg,
* @param dev scanner's device * @param dev scanner's device
* @param wait_until_home true if the function waits until head parked * @param wait_until_home true if the function waits until head parked
*/ */
static static void gl646_slow_back_home(Genesys_Device* dev, SANE_Bool wait_until_home)
SANE_Status
gl646_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
{ {
DBG_HELPER_ARGS(dbg, "wait_until_home = %d\n", wait_until_home); DBG_HELPER_ARGS(dbg, "wait_until_home = %d\n", wait_until_home);
Genesys_Settings settings; Genesys_Settings settings;
@ -2079,7 +2077,7 @@ gl646_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
if (val & REG41_HOMESNR) /* is sensor at home? */ if (val & REG41_HOMESNR) /* is sensor at home? */
{ {
DBG(DBG_info, "%s: end since already at home\n", __func__); DBG(DBG_info, "%s: end since already at home\n", __func__);
return SANE_STATUS_GOOD; return;
} }
/* stop motor if needed */ /* stop motor if needed */
@ -2099,15 +2097,14 @@ gl646_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
if (((val & (REG41_MOTMFLG | REG41_HOMESNR)) == REG41_HOMESNR)) /* at home and motor is off */ if (((val & (REG41_MOTMFLG | REG41_HOMESNR)) == REG41_HOMESNR)) /* at home and motor is off */
{ {
DBG(DBG_info, "%s: already at home and not moving\n", __func__); DBG(DBG_info, "%s: already at home and not moving\n", __func__);
return SANE_STATUS_GOOD; return;
} }
sanei_genesys_sleep_ms(100); sanei_genesys_sleep_ms(100);
} }
if (!i) /* the loop counted down to 0, scanner still is busy */ if (!i) /* the loop counted down to 0, scanner still is busy */
{ {
DBG(DBG_error, "%s: motor is still on: device busy\n", __func__); throw SaneException(SANE_STATUS_DEVICE_BUSY, "motor is still on: device busy");
return SANE_STATUS_DEVICE_BUSY;
} }
/* setup for a backward scan of 65535 steps, with no actual data reading */ /* setup for a backward scan of 65535 steps, with no actual data reading */
@ -2149,7 +2146,7 @@ gl646_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
if (dev->model->is_sheetfed == SANE_TRUE) if (dev->model->is_sheetfed == SANE_TRUE)
{ {
DBG(DBG_proc, "%s: end \n", __func__); DBG(DBG_proc, "%s: end \n", __func__);
return SANE_STATUS_GOOD; return;
} }
// starts scan // starts scan
@ -2167,23 +2164,21 @@ gl646_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
DBG(DBG_info, "%s: reached home position\n", __func__); DBG(DBG_info, "%s: reached home position\n", __func__);
DBG(DBG_proc, "%s: end\n", __func__); DBG(DBG_proc, "%s: end\n", __func__);
sanei_genesys_sleep_ms(500); sanei_genesys_sleep_ms(500);
return SANE_STATUS_GOOD; return;
} }
sanei_genesys_sleep_ms(100); sanei_genesys_sleep_ms(100);
++loop; ++loop;
} }
// when we come here then the scanner needed too much time for this, so we better stop the // when we come here then the scanner needed too much time for this, so we better
// motor // stop the motor
gl646_stop_motor(dev); catch_all_exceptions(__func__, [&](){ gl646_stop_motor (dev); });
end_scan(dev, &dev->reg, SANE_TRUE, SANE_FALSE); catch_all_exceptions(__func__, [&](){ end_scan(dev, &dev->reg, SANE_TRUE, SANE_FALSE); });
DBG(DBG_error, "%s: timeout while waiting for scanhead to go home\n", __func__); throw SaneException(SANE_STATUS_IO_ERROR, "timeout while waiting for scanhead to go home");
return SANE_STATUS_IO_ERROR;
} }
DBG(DBG_info, "%s: scanhead is still moving\n", __func__); DBG(DBG_info, "%s: scanhead is still moving\n", __func__);
return SANE_STATUS_GOOD;
} }
/** /**
@ -3442,8 +3437,8 @@ gl646_repark_head (Genesys_Device * dev)
} }
while (steps < expected); while (steps < expected);
/* toggle motor flag, put an huge step number and redo move backward */ // toggle motor flag, put an huge step number and redo move backward
status = gl646_slow_back_home (dev, 1); gl646_slow_back_home(dev, 1);
return status; return status;
} }
@ -3624,7 +3619,7 @@ gl646_init (Genesys_Device * dev)
} }
else else
{ {
RIE (gl646_slow_back_home (dev, SANE_TRUE)); gl646_slow_back_home(dev, SANE_TRUE);
} }
} }

Wyświetl plik

@ -173,9 +173,7 @@ static
SANE_Status SANE_Status
gl646_save_power (Genesys_Device * dev, SANE_Bool enable); gl646_save_power (Genesys_Device * dev, SANE_Bool enable);
static static void gl646_slow_back_home(Genesys_Device* dev, SANE_Bool wait_until_home);
SANE_Status
gl646_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home);
static static
SANE_Status SANE_Status

Wyświetl plik

@ -2886,9 +2886,8 @@ static void gl841_feed(Genesys_Device* dev, int steps)
throw SaneException(SANE_STATUS_IO_ERROR, "timeout while waiting for scanhead to go home"); throw SaneException(SANE_STATUS_IO_ERROR, "timeout while waiting for scanhead to go home");
} }
/* Moves the slider to the home (top) position slowly */ // Moves the slider to the home (top) position slowly
static SANE_Status static void gl841_slow_back_home(Genesys_Device* dev, SANE_Bool wait_until_home)
gl841_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
{ {
DBG_HELPER_ARGS(dbg, "wait_until_home = %d", wait_until_home); DBG_HELPER_ARGS(dbg, "wait_until_home = %d", wait_until_home);
Genesys_Register_Set local_reg; Genesys_Register_Set local_reg;
@ -2900,7 +2899,7 @@ gl841_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
{ {
DBG(DBG_proc, "%s: there is no \"home\"-concept for sheet fed\n", __func__); DBG(DBG_proc, "%s: there is no \"home\"-concept for sheet fed\n", __func__);
DBG(DBG_proc, "%s: finished\n", __func__); DBG(DBG_proc, "%s: finished\n", __func__);
return SANE_STATUS_GOOD; return;
} }
// reset gpio pin // reset gpio pin
@ -2939,7 +2938,7 @@ gl841_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
{ {
DBG(DBG_info, "%s: already at home, completed\n", __func__); DBG(DBG_info, "%s: already at home, completed\n", __func__);
dev->scanhead_position_in_steps = 0; dev->scanhead_position_in_steps = 0;
return SANE_STATUS_GOOD; return;
} }
/* end previous scan if any */ /* end previous scan if any */
@ -2991,20 +2990,19 @@ gl841_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
{ {
DBG(DBG_info, "%s: reached home position\n", __func__); DBG(DBG_info, "%s: reached home position\n", __func__);
DBG(DBG_proc, "%s: finished\n", __func__); DBG(DBG_proc, "%s: finished\n", __func__);
return SANE_STATUS_GOOD; return;
} }
sanei_genesys_sleep_ms(100); sanei_genesys_sleep_ms(100);
++loop; ++loop;
} }
/* 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");
} }
DBG(DBG_info, "%s: scanhead is still moving\n", __func__); DBG(DBG_info, "%s: scanhead is still moving\n", __func__);
return SANE_STATUS_GOOD;
} }
/* Automatically set top-left edge of the scan area by scanning a 200x200 pixels /* Automatically set top-left edge of the scan area by scanning a 200x200 pixels
@ -4283,8 +4281,8 @@ sanei_gl841_repark_head (Genesys_Device * dev)
gl841_feed(dev,232); gl841_feed(dev,232);
/* toggle motor flag, put an huge step number and redo move backward */ // toggle motor flag, put an huge step number and redo move backward
status = gl841_slow_back_home (dev, SANE_TRUE); gl841_slow_back_home(dev, SANE_TRUE);
return status; return status;
} }
@ -4380,8 +4378,8 @@ gl841_init (Genesys_Device * dev)
// Set analog frontend // Set analog frontend
gl841_set_fe(dev, sensor, AFE_INIT); gl841_set_fe(dev, sensor, AFE_INIT);
/* Move home */ // Move home
RIE (gl841_slow_back_home (dev, SANE_TRUE)); gl841_slow_back_home(dev, SANE_TRUE);
// Init shading data // Init shading data
sanei_genesys_init_shading_data(dev, sensor, sensor.sensor_pixels); sanei_genesys_init_shading_data(dev, sensor, sensor.sensor_pixels);

Wyświetl plik

@ -2222,7 +2222,7 @@ gl843_end_scan (Genesys_Device * dev, Genesys_Register_Set * reg,
/** @brief park XPA lamp /** @brief park XPA lamp
* park the XPA lamp if needed * park the XPA lamp if needed
*/ */
static SANE_Status gl843_park_xpa_lamp (Genesys_Device * dev) static void gl843_park_xpa_lamp(Genesys_Device* dev)
{ {
DBG_HELPER(dbg); DBG_HELPER(dbg);
Genesys_Register_Set local_reg; Genesys_Register_Set local_reg;
@ -2279,7 +2279,7 @@ static SANE_Status gl843_park_xpa_lamp (Genesys_Device * dev)
gl843_set_xpa_motor_power(dev, false); gl843_set_xpa_motor_power(dev, false);
dev->needs_home_ta = SANE_FALSE; dev->needs_home_ta = SANE_FALSE;
return SANE_STATUS_GOOD; return;
} }
sanei_genesys_sleep_ms(100); sanei_genesys_sleep_ms(100);
++loop; ++loop;
@ -2287,25 +2287,22 @@ static SANE_Status gl843_park_xpa_lamp (Genesys_Device * dev)
/* we are not parked here.... should we fail ? */ /* we are not parked here.... should we fail ? */
DBG(DBG_info, "%s: XPA lamp is not parked\n", __func__); DBG(DBG_info, "%s: XPA lamp is not parked\n", __func__);
return SANE_STATUS_GOOD;
} }
/** @brief Moves the slider to the home (top) position slowly /** @brief Moves the slider to the home (top) position slowly
* */ * */
static SANE_Status static void gl843_slow_back_home(Genesys_Device* dev, SANE_Bool wait_until_home)
gl843_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
{ {
DBG_HELPER_ARGS(dbg, "wait_until_home = %d", wait_until_home); DBG_HELPER_ARGS(dbg, "wait_until_home = %d", wait_until_home);
Genesys_Register_Set local_reg; Genesys_Register_Set local_reg;
SANE_Status status = SANE_STATUS_GOOD;
GenesysRegister *r; GenesysRegister *r;
uint8_t val; uint8_t val;
float resolution; float resolution;
int loop = 0; int loop = 0;
if (dev->needs_home_ta) { if (dev->needs_home_ta) {
RIE(gl843_park_xpa_lamp(dev)); gl843_park_xpa_lamp(dev);
} }
/* regular slow back home */ /* regular slow back home */
dev->scanhead_position_in_steps = 0; dev->scanhead_position_in_steps = 0;
@ -2324,7 +2321,7 @@ gl843_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
} }
if (val & HOMESNR) /* is sensor at home? */ if (val & HOMESNR) /* is sensor at home? */
{ {
return SANE_STATUS_GOOD; return;
} }
local_reg = dev->reg; local_reg = dev->reg;
@ -2393,20 +2390,19 @@ gl843_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
{ {
DBG(DBG_info, "%s: reached home position\n", __func__); DBG(DBG_info, "%s: reached home position\n", __func__);
DBG(DBG_proc, "%s: finished\n", __func__); DBG(DBG_proc, "%s: finished\n", __func__);
return SANE_STATUS_GOOD; return;
} }
sanei_genesys_sleep_ms(100); sanei_genesys_sleep_ms(100);
++loop; ++loop;
} }
/* 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
gl843_stop_action (dev); // the motor
DBG(DBG_error, "%s: timeout while waiting for scanhead to go home\n", __func__); catch_all_exceptions(__func__, [&](){ gl843_stop_action(dev); });
return SANE_STATUS_IO_ERROR; throw SaneException(SANE_STATUS_IO_ERROR, "timeout while waiting for scanhead to go home");
} }
DBG(DBG_info, "%s: scanhead is still moving\n", __func__); DBG(DBG_info, "%s: scanhead is still moving\n", __func__);
return SANE_STATUS_GOOD;
} }
/* Automatically set top-left edge of the scan area by scanning a 200x200 pixels /* Automatically set top-left edge of the scan area by scanning a 200x200 pixels
@ -3499,7 +3495,7 @@ gl843_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor
gl843_stop_action(dev); gl843_stop_action(dev);
status=gl843_slow_back_home (dev, SANE_TRUE); gl843_slow_back_home(dev, SANE_TRUE);
return status; return status;
} }

Wyświetl plik

@ -1477,9 +1477,8 @@ gl846_end_scan (Genesys_Device * dev, Genesys_Register_Set * reg,
return status; return status;
} }
/* Moves the slider to the home (top) postion slowly */ // Moves the slider to the home (top) postion slowly
static SANE_Status static void gl846_slow_back_home(Genesys_Device* dev, SANE_Bool wait_until_home)
gl846_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
{ {
DBG_HELPER_ARGS(dbg, "wait_until_home = %d", wait_until_home); DBG_HELPER_ARGS(dbg, "wait_until_home = %d", wait_until_home);
Genesys_Register_Set local_reg; Genesys_Register_Set local_reg;
@ -1514,7 +1513,7 @@ gl846_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
{ {
DBG(DBG_info, "%s: already at home, completed\n", __func__); DBG(DBG_info, "%s: already at home, completed\n", __func__);
dev->scanhead_position_in_steps = 0; dev->scanhead_position_in_steps = 0;
return SANE_STATUS_GOOD; return;
} }
local_reg = dev->reg; local_reg = dev->reg;
@ -1584,20 +1583,19 @@ gl846_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
DBG(DBG_info, "%s: reached home position\n", __func__); DBG(DBG_info, "%s: reached home position\n", __func__);
gl846_stop_action (dev); gl846_stop_action (dev);
dev->scanhead_position_in_steps = 0; dev->scanhead_position_in_steps = 0;
return SANE_STATUS_GOOD; return;
} }
sanei_genesys_sleep_ms(100); sanei_genesys_sleep_ms(100);
++loop; ++loop;
} }
/* 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
gl846_stop_action (dev); // the motor
DBG(DBG_error, "%s: timeout while waiting for scanhead to go home\n", __func__); catch_all_exceptions(__func__, [&](){ gl846_stop_action(dev); });
return SANE_STATUS_IO_ERROR; throw SaneException(SANE_STATUS_IO_ERROR, "timeout while waiting for scanhead to go home");
} }
DBG(DBG_info, "%s: scanhead is still moving\n", __func__); DBG(DBG_info, "%s: scanhead is still moving\n", __func__);
return SANE_STATUS_GOOD;
} }
/* Automatically set top-left edge of the scan area by scanning a 200x200 pixels /* Automatically set top-left edge of the scan area by scanning a 200x200 pixels
@ -2226,7 +2224,7 @@ gl846_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor, Genesys_Reg
/* go back home */ /* go back home */
if(move>20) if(move>20)
{ {
status=gl846_slow_back_home (dev, SANE_TRUE); gl846_slow_back_home(dev, SANE_TRUE);
} }
return status; return status;
@ -2932,7 +2930,7 @@ gl846_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor
gl846_stop_action(dev); gl846_stop_action(dev);
status=gl846_slow_back_home (dev, SANE_TRUE); gl846_slow_back_home(dev, SANE_TRUE);
return status; return status;
} }

Wyświetl plik

@ -362,8 +362,7 @@ static void gl846_feed(Genesys_Device* dev, unsigned int steps);
static void gl846_stop_action(Genesys_Device* dev); static void gl846_stop_action(Genesys_Device* dev);
static SANE_Status static void gl846_slow_back_home(Genesys_Device* dev, SANE_Bool wait_until_home);
gl846_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home);
static void gl846_boot(Genesys_Device* dev, SANE_Bool cold); static void gl846_boot(Genesys_Device* dev, SANE_Bool cold);

Wyświetl plik

@ -1539,9 +1539,7 @@ SANE_Status gl847_rewind(Genesys_Device * dev)
* @param wait_until_home true to make the function waiting for head * @param wait_until_home true to make the function waiting for head
* to be home before returning, if fals returne immediately * to be home before returning, if fals returne immediately
* @returns SANE_STATUS_GOO on success */ * @returns SANE_STATUS_GOO on success */
static static void gl847_slow_back_home(Genesys_Device* dev, SANE_Bool wait_until_home)
SANE_Status
gl847_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
{ {
DBG_HELPER_ARGS(dbg, "wait_until_home = %d", wait_until_home); DBG_HELPER_ARGS(dbg, "wait_until_home = %d", wait_until_home);
Genesys_Register_Set local_reg; Genesys_Register_Set local_reg;
@ -1576,7 +1574,7 @@ gl847_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
{ {
DBG(DBG_info, "%s: already at home, completed\n", __func__); DBG(DBG_info, "%s: already at home, completed\n", __func__);
dev->scanhead_position_in_steps = 0; dev->scanhead_position_in_steps = 0;
return SANE_STATUS_GOOD; return;
} }
local_reg = dev->reg; local_reg = dev->reg;
@ -1646,20 +1644,19 @@ gl847_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
DBG(DBG_info, "%s: reached home position\n", __func__); DBG(DBG_info, "%s: reached home position\n", __func__);
gl847_stop_action (dev); gl847_stop_action (dev);
dev->scanhead_position_in_steps = 0; dev->scanhead_position_in_steps = 0;
return SANE_STATUS_GOOD; return;
} }
sanei_genesys_sleep_ms(100); sanei_genesys_sleep_ms(100);
++loop; ++loop;
} }
/* 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
gl847_stop_action (dev); // the motor
DBG(DBG_error, "%s: timeout while waiting for scanhead to go home\n", __func__); catch_all_exceptions(__func__, [&](){ gl847_stop_action(dev); });
return SANE_STATUS_IO_ERROR; throw SaneException(SANE_STATUS_IO_ERROR, "timeout while waiting for scanhead to go home");
} }
DBG(DBG_info, "%s: scanhead is still moving\n", __func__); DBG(DBG_info, "%s: scanhead is still moving\n", __func__);
return SANE_STATUS_GOOD;
} }
/* Automatically set top-left edge of the scan area by scanning a 200x200 pixels /* Automatically set top-left edge of the scan area by scanning a 200x200 pixels
@ -2284,10 +2281,9 @@ gl847_led_calibration (Genesys_Device * dev, Genesys_Sensor& sensor, Genesys_Reg
sensor.exposure.green = exp[1]; sensor.exposure.green = exp[1];
sensor.exposure.blue = exp[2]; sensor.exposure.blue = exp[2];
/* go back home */ // go back home
if(move>20) if (move>20) {
{ gl847_slow_back_home(dev, SANE_TRUE);
status=gl847_slow_back_home (dev, SANE_TRUE);
} }
return status; return status;
@ -3056,7 +3052,7 @@ gl847_coarse_gain_calibration(Genesys_Device * dev, const Genesys_Sensor& sensor
gl847_stop_action(dev); gl847_stop_action(dev);
status=gl847_slow_back_home (dev, SANE_TRUE); gl847_slow_back_home(dev, SANE_TRUE);
return status; return status;
} }

Wyświetl plik

@ -1273,8 +1273,8 @@ sanei_genesys_asic_init(Genesys_Device* dev, int /*max_regs*/)
dev->already_initialized = SANE_TRUE; dev->already_initialized = SANE_TRUE;
/* Move to home if needed */ // Move to home if needed
RIE (dev->model->cmd_set->slow_back_home (dev, SANE_TRUE)); dev->model->cmd_set->slow_back_home(dev, SANE_TRUE);
dev->scanhead_position_in_steps = 0; dev->scanhead_position_in_steps = 0;
/* Set powersaving (default = 15 minutes) */ /* Set powersaving (default = 15 minutes) */

Wyświetl plik

@ -1090,7 +1090,7 @@ struct Genesys_Command_Set
Genesys_Register_Set& regs); Genesys_Register_Set& regs);
void (*wait_for_motor_stop) (Genesys_Device* dev); void (*wait_for_motor_stop) (Genesys_Device* dev);
SANE_Status (*slow_back_home) (Genesys_Device * dev, SANE_Bool wait_until_home); void (*slow_back_home) (Genesys_Device* dev, SANE_Bool wait_until_home);
SANE_Status (*rewind) (Genesys_Device * dev); SANE_Status (*rewind) (Genesys_Device * dev);
void (*bulk_write_register) (Genesys_Device* dev, Genesys_Register_Set& regs); void (*bulk_write_register) (Genesys_Device* dev, Genesys_Register_Set& regs);