genesys: Reduce duplication of scanner status printing

merge-requests/250/head
Povilas Kanapickas 2019-11-30 19:06:46 +02:00
rodzic df8a411de3
commit 6626453804
8 zmienionych plików z 21 dodań i 79 usunięć

Wyświetl plik

@ -1021,10 +1021,7 @@ static void gl124_stop_action(Genesys_Device* dev)
// post scan gpio : without that HOMSNR is unreliable
gl124_homsnr_gpio(dev);
auto status = scanner_read_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
scanner_read_print_status(*dev);
val40 = dev->interface->read_register(REG_0x100);
@ -1050,9 +1047,6 @@ static void gl124_stop_action(Genesys_Device* dev)
while (loop > 0)
{
auto status = scanner_read_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
val40 = dev->interface->read_register(REG_0x100);
/* if scanner is in command mode, we are done */

Wyświetl plik

@ -1210,10 +1210,7 @@ void CommandSetGl646::detect_document_end(Genesys_Device* dev) const
unsigned int bytes_left;
// test for document presence
auto status = scanner_read_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
scanner_read_print_status(*dev);
gl646_gpio_read(dev->interface->get_usb_device(), &gpio);
DBG(DBG_info, "%s: GPIO=0x%02x\n", __func__, gpio);
@ -1280,9 +1277,6 @@ void CommandSetGl646::eject_document(Genesys_Device* dev) const
// test status : paper event + HOMESNR -> no more doc ?
auto status = scanner_read_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
// home sensor is set when document is inserted
if (status.is_at_home) {
@ -1346,7 +1340,6 @@ void CommandSetGl646::eject_document(Genesys_Device* dev) const
count = 0;
do {
status = scanner_read_status(*dev);
debug_print_status(dbg, status);
dev->interface->sleep_ms(200);
count++;
@ -1391,9 +1384,6 @@ static void end_scan_impl(Genesys_Device* dev, Genesys_Register_Set* reg, bool c
/* we need to compute scanfsh before cancelling scan */
if (dev->model->is_sheetfed) {
auto status = scanner_read_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
if (status.is_scanning_finished) {
scanfsh = 1;
}
@ -1414,9 +1404,6 @@ static void end_scan_impl(Genesys_Device* dev, Genesys_Register_Set* reg, bool c
for (i = 0; i < 30; i++) /* do not wait longer than wait 3 seconds */
{
auto status = scanner_read_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
if (status.is_scanning_finished) {
scanfsh = 1;
}
@ -1437,9 +1424,6 @@ static void end_scan_impl(Genesys_Device* dev, Genesys_Register_Set* reg, bool c
{
auto status = scanner_read_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
if (status.is_scanning_finished) {
scanfsh = 1;
@ -1483,10 +1467,6 @@ void CommandSetGl646::slow_back_home(Genesys_Device* dev, bool wait_until_home)
int loop = 0;
auto status = scanner_read_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
dev->scanhead_position_in_steps = 0;
if (status.is_at_home) {
@ -2754,8 +2734,6 @@ void CommandSetGl646::init(Genesys_Device* dev) const
// to detect real power up condition, we write to REG_0x41 with pwrbit set, then read it back.
// When scanner is cold (just replugged) PWRBIT will be set in the returned value
auto status = scanner_read_status(*dev);
debug_print_status(dbg, status);
if (status.is_replugged) {
DBG(DBG_info, "%s: device is cold\n", __func__);
} else {

Wyświetl plik

@ -1868,10 +1868,7 @@ static void gl841_stop_action(Genesys_Device* dev)
Genesys_Register_Set local_reg;
unsigned int loop;
auto status = scanner_read_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
scanner_read_print_status(*dev);
uint8_t val40 = dev->interface->read_register(0x40);

Wyświetl plik

@ -1331,10 +1331,7 @@ static void gl843_stop_action(Genesys_Device* dev)
DBG_HELPER(dbg);
unsigned int loop;
auto status = scanner_read_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
scanner_read_print_status(*dev);
uint8_t val40 = dev->interface->read_register(REG_0x40);
@ -1360,9 +1357,6 @@ static void gl843_stop_action(Genesys_Device* dev)
loop = 10;
while (loop > 0) {
auto status = scanner_read_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
val40 = dev->interface->read_register(0x40);
/* if scanner is in command mode, we are done */
@ -1774,10 +1768,6 @@ static void gl843_park_xpa_lamp(Genesys_Device* dev)
while (loop < 600) /* do not wait longer then 60 seconds */
{
auto status = scanner_read_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
if (status.is_at_home) {
DBG(DBG_info, "%s: reached home position\n", __func__);
DBG(DBG_proc, "%s: finished\n", __func__);
@ -1875,9 +1865,6 @@ void CommandSetGl843::slow_back_home(Genesys_Device* dev, bool wait_until_home)
while (loop < 300) /* do not wait longer then 30 seconds */
{
auto status = scanner_read_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
if (status.is_at_home) {
DBG(DBG_info, "%s: reached home position\n", __func__);

Wyświetl plik

@ -857,10 +857,7 @@ static void gl846_stop_action(Genesys_Device* dev)
// post scan gpio : without that HOMSNR is unreliable
gl846_homsnr_gpio(dev);
auto status = scanner_read_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
scanner_read_print_status(*dev);
uint8_t val40 = dev->interface->read_register(REG_0x40);
@ -884,9 +881,6 @@ static void gl846_stop_action(Genesys_Device* dev)
loop = 10;
while (loop > 0) {
auto status = scanner_read_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
val40 = dev->interface->read_register(REG_0x40);
/* if scanner is in command mode, we are done */

Wyświetl plik

@ -869,10 +869,7 @@ static void gl847_stop_action(Genesys_Device* dev)
// post scan gpio : without that HOMSNR is unreliable
gl847_homsnr_gpio(dev);
auto status = scanner_read_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
scanner_read_print_status(*dev);
uint8_t val40 = dev->interface->read_register(REG_0x40);
@ -898,9 +895,6 @@ static void gl847_stop_action(Genesys_Device* dev)
while (loop > 0)
{
auto status = scanner_read_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
val40 = dev->interface->read_register(REG_0x40);
/* if scanner is in command mode, we are done */

Wyświetl plik

@ -302,6 +302,11 @@ Status scanner_read_status(Genesys_Device& dev)
status.is_lamp_on = value & LAMPSTS;
status.is_front_end_busy = value & FEBUSY;
status.is_motor_enabled = value & MOTORENB;
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
return status;
}
@ -309,20 +314,14 @@ 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);
}
scanner_read_status(dev);
dev.interface->sleep_ms(100);
return scanner_read_status(dev);
}
// second is reliable
status = scanner_read_status(dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
return status;
void scanner_read_print_status(Genesys_Device& dev)
{
scanner_read_status(dev);
}
/**
@ -1700,10 +1699,6 @@ void sanei_genesys_wait_for_home(Genesys_Device* dev)
elapsed_ms += 100;
status = scanner_read_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
} while (elapsed_ms < timeout_ms && !status.is_at_home);
/* if after the timeout, head is still not parked, error out */

Wyświetl plik

@ -257,7 +257,10 @@ Status scanner_read_status(Genesys_Device& dev);
// 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);
// reads and prints the scanner status
void scanner_read_print_status(Genesys_Device& dev);
void debug_print_status(DebugMessageHelper& dbg, Status status);
extern void sanei_genesys_write_ahb(Genesys_Device* dev, uint32_t addr, uint32_t size,
uint8_t* data);