kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Extract reliable reading of home sensor to separate function
rodzic
2ca325c638
commit
df8a411de3
|
@ -1205,18 +1205,7 @@ void CommandSetGl124::slow_back_home(Genesys_Device* dev, bool wait_until_home)
|
|||
// post scan gpio : without that HOMSNR is unreliable
|
||||
gl124_homsnr_gpio(dev);
|
||||
|
||||
// first read gives HOME_SENSOR true
|
||||
auto status = scanner_read_status(*dev);
|
||||
if (DBG_LEVEL >= DBG_io) {
|
||||
debug_print_status(dbg, status);
|
||||
}
|
||||
dev->interface->sleep_ms(100);
|
||||
|
||||
// second is reliable
|
||||
status = scanner_read_status(*dev);
|
||||
if (DBG_LEVEL >= DBG_io) {
|
||||
debug_print_status(dbg, status);
|
||||
}
|
||||
auto status = scanner_read_reliable_status(*dev);
|
||||
|
||||
if (status.is_at_home) {
|
||||
DBG (DBG_info, "%s: already at home, completed\n", __func__);
|
||||
|
|
|
@ -2257,17 +2257,7 @@ void CommandSetGl841::slow_back_home(Genesys_Device* dev, bool wait_until_home)
|
|||
dev->cmd_set->save_power(dev, false);
|
||||
|
||||
// first read gives HOME_SENSOR true
|
||||
auto status = scanner_read_status(*dev);
|
||||
if (DBG_LEVEL >= DBG_io) {
|
||||
debug_print_status(dbg, status);
|
||||
}
|
||||
dev->interface->sleep_ms(100);
|
||||
|
||||
// second is reliable
|
||||
status = scanner_read_status(*dev);
|
||||
if (DBG_LEVEL >= DBG_io) {
|
||||
debug_print_status(dbg, status);
|
||||
}
|
||||
auto status = scanner_read_reliable_status(*dev);
|
||||
|
||||
dev->scanhead_position_in_steps = 0;
|
||||
|
||||
|
|
|
@ -1811,19 +1811,7 @@ void CommandSetGl843::slow_back_home(Genesys_Device* dev, bool wait_until_home)
|
|||
/* regular slow back home */
|
||||
dev->scanhead_position_in_steps = 0;
|
||||
|
||||
// first read gives HOME_SENSOR true
|
||||
auto status = scanner_read_status(*dev);
|
||||
if (DBG_LEVEL >= DBG_io) {
|
||||
debug_print_status(dbg, status);
|
||||
}
|
||||
|
||||
dev->interface->sleep_ms(100);
|
||||
|
||||
// second is reliable
|
||||
status = scanner_read_status(*dev);
|
||||
if (DBG_LEVEL >= DBG_io) {
|
||||
debug_print_status(dbg, status);
|
||||
}
|
||||
auto status = scanner_read_reliable_status(*dev);
|
||||
|
||||
if (status.is_at_home) {
|
||||
return;
|
||||
|
|
|
@ -957,17 +957,7 @@ void CommandSetGl846::slow_back_home(Genesys_Device* dev, bool wait_until_home)
|
|||
gl846_homsnr_gpio(dev);
|
||||
|
||||
// first read gives HOME_SENSOR true
|
||||
auto status = scanner_read_status(*dev);
|
||||
if (DBG_LEVEL >= DBG_io) {
|
||||
debug_print_status(dbg, status);
|
||||
}
|
||||
dev->interface->sleep_ms(100);
|
||||
|
||||
// second is reliable
|
||||
status = scanner_read_status(*dev);
|
||||
if (DBG_LEVEL >= DBG_io) {
|
||||
debug_print_status(dbg, status);
|
||||
}
|
||||
auto status = scanner_read_reliable_status(*dev);
|
||||
|
||||
/* is sensor at home? */
|
||||
if (status.is_at_home) {
|
||||
|
|
|
@ -1010,17 +1010,7 @@ void CommandSetGl847::slow_back_home(Genesys_Device* dev, bool wait_until_home)
|
|||
gl847_homsnr_gpio(dev);
|
||||
|
||||
// first read gives HOME_SENSOR true
|
||||
auto status = scanner_read_status(*dev);
|
||||
if (DBG_LEVEL >= DBG_io) {
|
||||
debug_print_status(dbg, status);
|
||||
}
|
||||
dev->interface->sleep_ms(100);
|
||||
|
||||
// second is reliable
|
||||
status = scanner_read_status(*dev);
|
||||
if (DBG_LEVEL >= DBG_io) {
|
||||
debug_print_status(dbg, status);
|
||||
}
|
||||
auto status = scanner_read_reliable_status(*dev);
|
||||
|
||||
if (status.is_at_home) {
|
||||
DBG(DBG_info, "%s: already at home, completed\n", __func__);
|
||||
|
|
|
@ -305,6 +305,26 @@ Status scanner_read_status(Genesys_Device& dev)
|
|||
return status;
|
||||
}
|
||||
|
||||
Status scanner_read_reliable_status(Genesys_Device& dev)
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
|
||||
auto status = scanner_read_status(dev);
|
||||
if (DBG_LEVEL >= DBG_io) {
|
||||
debug_print_status(dbg, status);
|
||||
}
|
||||
|
||||
dev.interface->sleep_ms(100);
|
||||
|
||||
// second is reliable
|
||||
status = scanner_read_status(dev);
|
||||
if (DBG_LEVEL >= DBG_io) {
|
||||
debug_print_status(dbg, status);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* decodes and prints content of status register
|
||||
* @param val value read from status register
|
||||
|
|
|
@ -250,8 +250,13 @@ inline GenesysRegister* sanei_genesys_get_address(Genesys_Register_Set* regs, ui
|
|||
|
||||
extern void sanei_genesys_init_cmd_set(Genesys_Device* dev);
|
||||
|
||||
// reads the status of the scanner
|
||||
Status scanner_read_status(Genesys_Device& dev);
|
||||
|
||||
// reads the status of the scanner reliably. This is done by reading the status twice. The first
|
||||
// read sometimes returns the home sensor as engaged when this is not true.
|
||||
Status scanner_read_reliable_status(Genesys_Device& dev);
|
||||
|
||||
extern void debug_print_status(DebugMessageHelper& dbg, Status status);
|
||||
|
||||
extern void sanei_genesys_write_ahb(Genesys_Device* dev, uint32_t addr, uint32_t size,
|
||||
|
|
Ładowanie…
Reference in New Issue