genesys: Return errors as exceptions from *get_status()

merge-requests/101/head
Povilas Kanapickas 2019-07-14 23:40:46 +03:00
rodzic e388fc5058
commit f153fb109e
9 zmienionych plików z 108 dodań i 288 usunięć

Wyświetl plik

@ -3568,7 +3568,7 @@ genesys_wait_not_moving (Genesys_Device * dev, int mseconds)
DBG(DBG_proc, "%s: waiting %d mseconds for motor to stop\n", __func__, mseconds);
while (mseconds > 0)
{
RIE (sanei_genesys_get_status (dev, &value));
sanei_genesys_get_status(dev, &value);
if (dev->model->cmd_set->test_motor_flag_bit (value))
{

Wyświetl plik

@ -1861,26 +1861,18 @@ gl124_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
/* post scan gpio : without that HOMSNR is unreliable */
gl124_homsnr_gpio(dev);
/* first read gives HOME_SENSOR true */
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus(status));
return status;
}
// first read gives HOME_SENSOR true
sanei_genesys_get_status(dev, &val);
if (DBG_LEVEL >= DBG_io)
{
sanei_genesys_print_status (val);
}
sanei_genesys_sleep_ms(100);
/* second is reliable */
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus(status));
return status;
}
// second is reliable
sanei_genesys_get_status(dev, &val);
if (DBG_LEVEL >= DBG_io)
{
sanei_genesys_print_status (val);
@ -1980,13 +1972,7 @@ gl124_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
while (loop < 300) /* do not wait longer then 30 seconds */
{
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__,
sane_strstatus(status));
return status;
}
sanei_genesys_get_status(dev, &val);
if (val & HOMESNR) /* home sensor */
{
@ -2103,13 +2089,10 @@ gl124_feed (Genesys_Device * dev, unsigned int steps, int reverse)
return status;
}
/* wait until feed count reaches the required value, but do not
* exceed 30s */
do
{
status = sanei_genesys_get_status (dev, &val);
}
while (status == SANE_STATUS_GOOD && !(val & FEEDFSH));
// wait until feed count reaches the required value, but do not exceed 30s
do {
sanei_genesys_get_status(dev, &val);
} while (!(val & FEEDFSH));
/* then stop scanning */
RIE(gl124_stop_action (dev));
@ -2354,7 +2337,7 @@ static void gl124_wait_for_motor_stop(Genesys_Device* dev)
DBG_HELPER(dbg);
uint8_t val40, val;
TIE(sanei_genesys_get_status(dev, &val));
sanei_genesys_get_status(dev, &val);
sanei_genesys_read_register(dev, REG100, &val40);
if ((val & MOTORENB) == 0 && (val40 & REG100_MOTMFLG) == 0)
@ -2362,7 +2345,7 @@ static void gl124_wait_for_motor_stop(Genesys_Device* dev)
do {
sanei_genesys_sleep_ms(10);
TIE(sanei_genesys_get_status(dev, &val));
sanei_genesys_get_status(dev, &val);
sanei_genesys_read_register(dev, REG100, &val40);
} while ((val & MOTORENB) ||(val40 & REG100_MOTMFLG));
sanei_genesys_sleep_ms(50);

Wyświetl plik

@ -1805,12 +1805,7 @@ gl646_load_document (Genesys_Device * dev)
return SANE_STATUS_GOOD;
}
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: failed to read status: %s\n", __func__, sane_strstatus(status));
return status;
}
sanei_genesys_get_status(dev, &val);
/* HOMSNR is set if a document is inserted */
if ((val & REG41_HOMESNR))
@ -1890,12 +1885,7 @@ gl646_load_document (Genesys_Device * dev)
count = 0;
do
{
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: failed to read status: %s\n", __func__, sane_strstatus(status));
return status;
}
sanei_genesys_get_status(dev, &val);
sanei_genesys_sleep_ms(200);
count++;
}
@ -1931,8 +1921,8 @@ gl646_detect_document_end (Genesys_Device * dev)
uint8_t val, gpio;
unsigned int bytes_left, lines;
/* test for document presence */
RIE (sanei_genesys_get_status (dev, &val));
// test for document presence
sanei_genesys_get_status(dev, &val);
if (DBG_LEVEL > DBG_info)
{
print_status (val);
@ -2013,13 +2003,9 @@ gl646_eject_document (Genesys_Device * dev)
DBG(DBG_info, "%s: GPIO=0x%02x\n", __func__, gpio);
/* test status : paper event + HOMESNR -> no more doc ? */
status = sanei_genesys_get_status (dev, &state);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: failed to read status: %s\n", __func__, sane_strstatus(status));
return status;
}
// test status : paper event + HOMESNR -> no more doc ?
sanei_genesys_get_status(dev, &state);
DBG(DBG_info, "%s: state=0x%02x\n", __func__, state);
if (DBG_LEVEL > DBG_info)
{
@ -2042,12 +2028,7 @@ gl646_eject_document (Genesys_Device * dev)
do
{
sanei_genesys_sleep_ms(200);
status = sanei_genesys_get_status (dev, &state);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: failed to read status: %s\n", __func__, sane_strstatus(status));
return status;
}
sanei_genesys_get_status(dev, &state);
}
while (state & REG41_MOTMFLG);
@ -2105,12 +2086,8 @@ gl646_eject_document (Genesys_Device * dev)
count = 0;
do
{
status = sanei_genesys_get_status (dev, &state);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: failed to read status: %s\n", __func__, sane_strstatus(status));
return status;
}
sanei_genesys_get_status(dev, &state);
print_status (state);
sanei_genesys_sleep_ms(200);
count++;
@ -2164,12 +2141,8 @@ end_scan (Genesys_Device * dev, Genesys_Register_Set * reg,
/* we need to compute scanfsh before cancelling scan */
if (dev->model->is_sheetfed == SANE_TRUE)
{
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: failed to read register: %s\n", __func__, sane_strstatus(status));
return status;
}
sanei_genesys_get_status(dev, &val);
if (val & REG41_SCANFSH)
scanfsh = 1;
if (DBG_LEVEL > DBG_io2)
@ -2200,13 +2173,8 @@ end_scan (Genesys_Device * dev, Genesys_Register_Set * reg,
{
for (i = 0; i < 30; i++) /* do not wait longer than wait 3 seconds */
{
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: failed to read register: %s\n", __func__,
sane_strstatus(status));
return status;
}
sanei_genesys_get_status(dev, &val);
if (val & REG41_SCANFSH)
scanfsh = 1;
if (DBG_LEVEL > DBG_io2)
@ -2230,13 +2198,8 @@ end_scan (Genesys_Device * dev, Genesys_Register_Set * reg,
{
for (i = 0; i < 300; i++) /* do not wait longer than wait 30 seconds */
{
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: failed to read register: %s\n", __func__,
sane_strstatus(status));
return status;
}
sanei_genesys_get_status(dev, &val);
if (val & REG41_SCANFSH)
scanfsh = 1;
if (DBG_LEVEL > DBG_io)
@ -2290,12 +2253,8 @@ gl646_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
int i;
int loop = 0;
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus(status));
return status;
}
sanei_genesys_get_status(dev, &val);
if (DBG_LEVEL > DBG_io)
{
print_status (val);
@ -2326,13 +2285,8 @@ gl646_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
val = REG41_MOTMFLG;
for (i = 400; i > 0 && (val & REG41_MOTMFLG); i--) /* do not wait longer than 40 seconds, count down to get i = 0 when busy */
{
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: Failed to read home sensor & motor status: %s\n", __func__,
sane_strstatus(status));
return status;
}
sanei_genesys_get_status(dev, &val);
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__);
@ -2412,13 +2366,7 @@ gl646_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
{
while (loop < 300) /* do not wait longer then 30 seconds */
{
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: Failed to read home sensor: %s\n", __func__,
sane_strstatus(status));
return status;
}
sanei_genesys_get_status(dev, &val);
if (val & 0x08) /* home sensor */
{
@ -3767,11 +3715,9 @@ gl646_init (Genesys_Device * dev)
uint32_t addr = 0xdead;
size_t len;
/* to detect real power up condition, we write to REG41
* with pwrbit set, then read it back. When scanner is cold (just replugged)
* PWRBIT will be set in the returned value
*/
RIE (sanei_genesys_get_status (dev, &cold));
// to detect real power up condition, we write to REG41 with pwrbit set, then read it back. When
// scanner is cold (just replugged) PWRBIT will be set in the returned value
sanei_genesys_get_status(dev, &cold);
DBG(DBG_info, "%s: status=0x%02x\n", __func__, cold);
cold = !(cold & REG41_PWRBIT);
if (cold)
@ -4087,7 +4033,7 @@ simple_scan (Genesys_Device * dev, const Genesys_Sensor& sensor,
do
{
sanei_genesys_sleep_ms(10);
RIE (sanei_genesys_get_status (dev, &val));
sanei_genesys_get_status(dev, &val);
if (DBG_LEVEL > DBG_info)
{
print_status (val);

Wyświetl plik

@ -2745,7 +2745,7 @@ gl841_stop_action (Genesys_Device * dev)
uint8_t val40, val;
unsigned int loop;
sanei_genesys_get_status (dev, &val);
sanei_genesys_get_status(dev, &val);
if (DBG_LEVEL >= DBG_io)
{
sanei_genesys_print_status (val);
@ -2826,12 +2826,7 @@ gl841_eject_document (Genesys_Device * dev)
local_reg.clear();
val = 0;
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: failed to read status register: %s\n", __func__, sane_strstatus(status));
return status;
}
sanei_genesys_get_status(dev, &val);
status = gl841_stop_action (dev);
if (status != SANE_STATUS_GOOD)
@ -3199,12 +3194,7 @@ gl841_feed (Genesys_Device * dev, int steps)
loop = 0;
while (loop < 300) /* do not wait longer then 30 seconds */
{
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus(status));
return status;
}
sanei_genesys_get_status(dev, &val);
if (!(val & REG41_MOTORENB)) /* motor enabled */
{
@ -3254,26 +3244,18 @@ gl841_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
}
gl841_save_power(dev, SANE_FALSE);
/* first read gives HOME_SENSOR true */
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus(status));
return status;
}
// first read gives HOME_SENSOR true
sanei_genesys_get_status(dev, &val);
if (DBG_LEVEL >= DBG_io)
{
sanei_genesys_print_status (val);
}
sanei_genesys_sleep_ms(100);
/* second is reliable */
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus(status));
return status;
}
// second is reliable
sanei_genesys_get_status(dev, &val);
if (DBG_LEVEL >= DBG_io)
{
sanei_genesys_print_status (val);
@ -3349,13 +3331,7 @@ gl841_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
{
while (loop < 300) /* do not wait longer then 30 seconds */
{
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__,
sane_strstatus(status));
return status;
}
sanei_genesys_get_status(dev, &val);
if (val & REG41_HOMESNR) /* home sensor */
{
@ -4804,7 +4780,7 @@ gl841_init (Genesys_Device * dev)
/* Check if the device has already been initialized and powered up */
if (dev->already_initialized)
{
RIE (sanei_genesys_get_status (dev, &val));
sanei_genesys_get_status(dev, &val);
if (val & REG41_PWRBIT)
{
DBG(DBG_info, "%s: already initialized\n", __func__);

Wyświetl plik

@ -2382,13 +2382,8 @@ static SANE_Status gl843_park_xpa_lamp (Genesys_Device * dev)
while (loop < 600) /* do not wait longer then 60 seconds */
{
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__,
sane_strstatus(status));
return status;
}
sanei_genesys_get_status(dev, &val);
if (DBG_LEVEL >= DBG_io2)
{
sanei_genesys_print_status (val);
@ -2433,22 +2428,14 @@ gl843_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
/* regular slow back home */
dev->scanhead_position_in_steps = 0;
/* first read gives HOME_SENSOR true */
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus(status));
return status;
}
// first read gives HOME_SENSOR true
sanei_genesys_get_status(dev, &val);
sanei_genesys_sleep_ms(100);
/* second is reliable */
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus(status));
return status;
}
// second is reliable
sanei_genesys_get_status(dev, &val);
if (DBG_LEVEL >= DBG_io)
{
sanei_genesys_print_status (val);
@ -2530,13 +2517,8 @@ gl843_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
while (loop < 300) /* do not wait longer then 30 seconds */
{
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__,
sane_strstatus(status));
return status;
}
sanei_genesys_get_status(dev, &val);
if (DBG_LEVEL >= DBG_io2)
{
sanei_genesys_print_status (val);
@ -2808,13 +2790,10 @@ gl843_feed (Genesys_Device * dev, unsigned int steps)
return status;
}
/* wait until feed count reaches the required value, but do not
* exceed 30s */
do
{
status = sanei_genesys_get_status (dev, &val);
}
while (status == SANE_STATUS_GOOD && !(val & FEEDFSH));
// wait until feed count reaches the required value, but do not exceed 30s
do {
sanei_genesys_get_status(dev, &val);
} while (!(val & FEEDFSH));
// looks like the scanner locks up if we scan immediately after feeding
sanei_genesys_sleep_ms(100);

Wyświetl plik

@ -477,12 +477,12 @@ gl846_set_adi_fe (Genesys_Device * dev, uint8_t set)
int i;
uint8_t val8;
/* wait for FE to be ready */
status = sanei_genesys_get_status (dev, &val8);
// wait for FE to be ready
sanei_genesys_get_status(dev, &val8);
while (val8 & REG41_FEBUSY)
{
sanei_genesys_sleep_ms(10);
status = sanei_genesys_get_status (dev, &val8);
sanei_genesys_get_status(dev, &val8);
};
if (set == AFE_INIT)
@ -1472,7 +1472,7 @@ gl846_stop_action (Genesys_Device * dev)
/* post scan gpio : without that HOMSNR is unreliable */
gl846_homsnr_gpio(dev);
status = sanei_genesys_get_status (dev, &val);
sanei_genesys_get_status(dev, &val);
if (DBG_LEVEL >= DBG_io)
{
sanei_genesys_print_status (val);
@ -1502,7 +1502,7 @@ gl846_stop_action (Genesys_Device * dev)
loop = 10;
while (loop > 0)
{
status = sanei_genesys_get_status (dev, &val);
sanei_genesys_get_status(dev, &val);
if (DBG_LEVEL >= DBG_io)
{
sanei_genesys_print_status (val);
@ -1605,26 +1605,18 @@ gl846_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
/* post scan gpio : without that HOMSNR is unreliable */
gl846_homsnr_gpio(dev);
/* first read gives HOME_SENSOR true */
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus(status));
return status;
}
// first read gives HOME_SENSOR true
sanei_genesys_get_status(dev, &val);
if (DBG_LEVEL >= DBG_io)
{
sanei_genesys_print_status (val);
}
sanei_genesys_sleep_ms(100);
/* second is reliable */
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus(status));
return status;
}
// second is reliable
sanei_genesys_get_status(dev, &val);
if (DBG_LEVEL >= DBG_io)
{
sanei_genesys_print_status (val);
@ -1715,13 +1707,7 @@ gl846_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
{
while (loop < 300) /* do not wait longer then 30 seconds */
{
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__,
sane_strstatus(status));
return status;
}
sanei_genesys_get_status(dev, &val);
if (val & HOMESNR) /* home sensor */
{
@ -1986,13 +1972,10 @@ gl846_feed (Genesys_Device * dev, unsigned int steps)
return status;
}
/* wait until feed count reaches the required value, but do not
* exceed 30s */
do
{
status = sanei_genesys_get_status (dev, &val);
}
while (status == SANE_STATUS_GOOD && !(val & FEEDFSH));
// wait until feed count reaches the required value, but do not exceed 30s
do {
sanei_genesys_get_status(dev, &val);
} while (!(val & FEEDFSH));
/* then stop scanning */
RIE(gl846_stop_action (dev));

Wyświetl plik

@ -497,12 +497,12 @@ gl847_set_ad_fe (Genesys_Device * dev, uint8_t set)
int i;
uint8_t val8;
/* wait for FE to be ready */
status = sanei_genesys_get_status (dev, &val8);
// wait for FE to be ready
sanei_genesys_get_status(dev, &val8);
while (val8 & REG41_FEBUSY)
{
sanei_genesys_sleep_ms(10);
status = sanei_genesys_get_status (dev, &val8);
sanei_genesys_get_status(dev, &val8);
};
if (set == AFE_INIT)
@ -1486,7 +1486,7 @@ gl847_stop_action (Genesys_Device * dev)
/* post scan gpio : without that HOMSNR is unreliable */
gl847_homsnr_gpio(dev);
sanei_genesys_get_status (dev, &val);
sanei_genesys_get_status(dev, &val);
if (DBG_LEVEL >= DBG_io)
{
sanei_genesys_print_status (val);
@ -1512,7 +1512,7 @@ gl847_stop_action (Genesys_Device * dev)
loop = 10;
while (loop > 0)
{
sanei_genesys_get_status (dev, &val);
sanei_genesys_get_status(dev, &val);
if (DBG_LEVEL >= DBG_io)
{
sanei_genesys_print_status (val);
@ -1660,26 +1660,18 @@ gl847_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
/* post scan gpio : without that HOMSNR is unreliable */
gl847_homsnr_gpio(dev);
/* first read gives HOME_SENSOR true */
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus(status));
return status;
}
// first read gives HOME_SENSOR true
sanei_genesys_get_status(dev, &val);
if (DBG_LEVEL >= DBG_io)
{
sanei_genesys_print_status (val);
}
sanei_genesys_sleep_ms(100);
/* second is reliable */
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus(status));
return status;
}
// second is reliable
sanei_genesys_get_status(dev, &val);
if (DBG_LEVEL >= DBG_io)
{
sanei_genesys_print_status (val);
@ -1771,13 +1763,7 @@ gl847_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home)
{
while (loop < 300) /* do not wait longer then 30 seconds */
{
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__,
sane_strstatus(status));
return status;
}
sanei_genesys_get_status(dev, &val);
if (val & HOMESNR) /* home sensor */
{
@ -2037,13 +2023,11 @@ gl847_feed (Genesys_Device * dev, unsigned int steps)
return status;
}
/* wait until feed count reaches the required value, but do not
* exceed 30s */
do
{
status = sanei_genesys_get_status (dev, &val);
// wait until feed count reaches the required value, but do not exceed 30s
do {
sanei_genesys_get_status(dev, &val);
}
while (status == SANE_STATUS_GOOD && !(val & FEEDFSH));
while (!(val & FEEDFSH));
/* then stop scanning */
RIE(gl847_stop_action (dev));

Wyświetl plik

@ -640,16 +640,14 @@ sanei_genesys_fe_write_data (Genesys_Device * dev, uint8_t addr,
/** read the status register
*/
SANE_Status
sanei_genesys_get_status (Genesys_Device * dev, uint8_t * status)
void sanei_genesys_get_status(Genesys_Device* dev, uint8_t* status)
{
DBG_HELPER(dbg);
if (dev->model->asic_type == GENESYS_GL124) {
sanei_genesys_read_hregister(dev, 0x101, status);
return SANE_STATUS_GOOD;
return;
}
sanei_genesys_read_register(dev, 0x41, status);
return SANE_STATUS_GOOD;
}
/**
@ -814,15 +812,9 @@ sanei_genesys_test_buffer_empty (Genesys_Device * dev, SANE_Bool * empty)
{
DBG_HELPER(dbg);
uint8_t val = 0;
SANE_Status status = SANE_STATUS_GOOD;
sanei_genesys_sleep_ms(1);
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
DBG(DBG_error, "%s: failed to read buffer status: %s\n", __func__, sane_strstatus(status));
return status;
}
sanei_genesys_get_status(dev, &val);
if (dev->model->cmd_set->test_buffer_empty_bit (val))
{
@ -1343,26 +1335,11 @@ sanei_genesys_wait_for_home (Genesys_Device * dev)
/* clear the 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 */
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
DBG (DBG_error,
"%s: failed to read home sensor: %s\n", __func__,
sane_strstatus (status));
return status;
}
// 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
sanei_genesys_get_status(dev, &val);
sanei_genesys_sleep_ms(10);
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
DBG (DBG_error,
"%s: failed to read home sensor: %s\n", __func__,
sane_strstatus (status));
return status;
}
sanei_genesys_get_status(dev, &val);
/* if at home, return */
if(val & HOMESNR)
@ -1377,25 +1354,17 @@ sanei_genesys_wait_for_home (Genesys_Device * dev)
do
{
sanei_genesys_sleep_ms(100);
status = sanei_genesys_get_status (dev, &val);
if (status != SANE_STATUS_GOOD)
{
DBG (DBG_error,
"%s: failed to read home sensor: %s\n", __func__,
sane_strstatus (status));
return status;
}
sanei_genesys_get_status(dev, &val);
if (DBG_LEVEL >= DBG_io2)
{
sanei_genesys_print_status (val);
}
++loop;
}
while (loop < max && !(val & HOMESNR) && status == SANE_STATUS_GOOD);
} while (loop < max && !(val & HOMESNR));
/* if after the timeout, head is still not parked, error out */
if(loop >= max && !(val & HOMESNR) && status == SANE_STATUS_GOOD)
{
if (loop >= max && !(val & HOMESNR)) {
DBG (DBG_error, "%s: failed to reach park position %ds\n", __func__, max/10);
return SANE_STATUS_IO_ERROR;
}

Wyświetl plik

@ -1733,7 +1733,7 @@ extern void sanei_genesys_bulk_read_data(Genesys_Device * dev, uint8_t addr, uin
extern void sanei_genesys_bulk_write_data(Genesys_Device* dev, uint8_t addr, uint8_t* data,
size_t len);
extern SANE_Status sanei_genesys_get_status (Genesys_Device * dev, uint8_t * status);
extern void sanei_genesys_get_status(Genesys_Device* dev, uint8_t* status);
extern void sanei_genesys_print_status (uint8_t val);