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 // post scan gpio : without that HOMSNR is unreliable
gl124_homsnr_gpio(dev); gl124_homsnr_gpio(dev);
auto status = scanner_read_status(*dev); scanner_read_print_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
val40 = dev->interface->read_register(REG_0x100); val40 = dev->interface->read_register(REG_0x100);
@ -1050,9 +1047,6 @@ static void gl124_stop_action(Genesys_Device* dev)
while (loop > 0) while (loop > 0)
{ {
auto status = scanner_read_status(*dev); auto status = scanner_read_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
val40 = dev->interface->read_register(REG_0x100); val40 = dev->interface->read_register(REG_0x100);
/* if scanner is in command mode, we are done */ /* 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; unsigned int bytes_left;
// test for document presence // test for document presence
auto status = scanner_read_status(*dev); scanner_read_print_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
gl646_gpio_read(dev->interface->get_usb_device(), &gpio); gl646_gpio_read(dev->interface->get_usb_device(), &gpio);
DBG(DBG_info, "%s: GPIO=0x%02x\n", __func__, 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 ? // test status : paper event + HOMESNR -> no more doc ?
auto status = scanner_read_status(*dev); auto status = scanner_read_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
// home sensor is set when document is inserted // home sensor is set when document is inserted
if (status.is_at_home) { if (status.is_at_home) {
@ -1346,7 +1340,6 @@ void CommandSetGl646::eject_document(Genesys_Device* dev) const
count = 0; count = 0;
do { do {
status = scanner_read_status(*dev); status = scanner_read_status(*dev);
debug_print_status(dbg, status);
dev->interface->sleep_ms(200); dev->interface->sleep_ms(200);
count++; 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 */ /* we need to compute scanfsh before cancelling scan */
if (dev->model->is_sheetfed) { if (dev->model->is_sheetfed) {
auto status = scanner_read_status(*dev); auto status = scanner_read_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
if (status.is_scanning_finished) { if (status.is_scanning_finished) {
scanfsh = 1; 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 */ for (i = 0; i < 30; i++) /* do not wait longer than wait 3 seconds */
{ {
auto status = scanner_read_status(*dev); auto status = scanner_read_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
if (status.is_scanning_finished) { if (status.is_scanning_finished) {
scanfsh = 1; 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); auto status = scanner_read_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
if (status.is_scanning_finished) { if (status.is_scanning_finished) {
scanfsh = 1; scanfsh = 1;
@ -1483,10 +1467,6 @@ void CommandSetGl646::slow_back_home(Genesys_Device* dev, bool wait_until_home)
int loop = 0; int loop = 0;
auto status = scanner_read_status(*dev); auto status = scanner_read_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
dev->scanhead_position_in_steps = 0; dev->scanhead_position_in_steps = 0;
if (status.is_at_home) { 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. // 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 // When scanner is cold (just replugged) PWRBIT will be set in the returned value
auto status = scanner_read_status(*dev); auto status = scanner_read_status(*dev);
debug_print_status(dbg, status);
if (status.is_replugged) { if (status.is_replugged) {
DBG(DBG_info, "%s: device is cold\n", __func__); DBG(DBG_info, "%s: device is cold\n", __func__);
} else { } else {

Wyświetl plik

@ -1868,10 +1868,7 @@ static void gl841_stop_action(Genesys_Device* dev)
Genesys_Register_Set local_reg; Genesys_Register_Set local_reg;
unsigned int loop; unsigned int loop;
auto status = scanner_read_status(*dev); scanner_read_print_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
uint8_t val40 = dev->interface->read_register(0x40); 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); DBG_HELPER(dbg);
unsigned int loop; unsigned int loop;
auto status = scanner_read_status(*dev); scanner_read_print_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
uint8_t val40 = dev->interface->read_register(REG_0x40); uint8_t val40 = dev->interface->read_register(REG_0x40);
@ -1360,9 +1357,6 @@ static void gl843_stop_action(Genesys_Device* dev)
loop = 10; loop = 10;
while (loop > 0) { while (loop > 0) {
auto status = scanner_read_status(*dev); auto status = scanner_read_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
val40 = dev->interface->read_register(0x40); val40 = dev->interface->read_register(0x40);
/* if scanner is in command mode, we are done */ /* 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 */ while (loop < 600) /* do not wait longer then 60 seconds */
{ {
auto status = scanner_read_status(*dev); auto status = scanner_read_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
if (status.is_at_home) { if (status.is_at_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__);
@ -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 */ while (loop < 300) /* do not wait longer then 30 seconds */
{ {
auto status = scanner_read_status(*dev); auto status = scanner_read_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
if (status.is_at_home) { if (status.is_at_home) {
DBG(DBG_info, "%s: reached home position\n", __func__); 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 // post scan gpio : without that HOMSNR is unreliable
gl846_homsnr_gpio(dev); gl846_homsnr_gpio(dev);
auto status = scanner_read_status(*dev); scanner_read_print_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
uint8_t val40 = dev->interface->read_register(REG_0x40); uint8_t val40 = dev->interface->read_register(REG_0x40);
@ -884,9 +881,6 @@ static void gl846_stop_action(Genesys_Device* dev)
loop = 10; loop = 10;
while (loop > 0) { while (loop > 0) {
auto status = scanner_read_status(*dev); auto status = scanner_read_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
val40 = dev->interface->read_register(REG_0x40); val40 = dev->interface->read_register(REG_0x40);
/* if scanner is in command mode, we are done */ /* 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 // post scan gpio : without that HOMSNR is unreliable
gl847_homsnr_gpio(dev); gl847_homsnr_gpio(dev);
auto status = scanner_read_status(*dev); scanner_read_print_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
uint8_t val40 = dev->interface->read_register(REG_0x40); uint8_t val40 = dev->interface->read_register(REG_0x40);
@ -898,9 +895,6 @@ static void gl847_stop_action(Genesys_Device* dev)
while (loop > 0) while (loop > 0)
{ {
auto status = scanner_read_status(*dev); auto status = scanner_read_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
val40 = dev->interface->read_register(REG_0x40); val40 = dev->interface->read_register(REG_0x40);
/* if scanner is in command mode, we are done */ /* 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_lamp_on = value & LAMPSTS;
status.is_front_end_busy = value & FEBUSY; status.is_front_end_busy = value & FEBUSY;
status.is_motor_enabled = value & MOTORENB; status.is_motor_enabled = value & MOTORENB;
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
return status; return status;
} }
@ -309,20 +314,14 @@ Status scanner_read_reliable_status(Genesys_Device& dev)
{ {
DBG_HELPER(dbg); DBG_HELPER(dbg);
auto status = scanner_read_status(dev); scanner_read_status(dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
dev.interface->sleep_ms(100); dev.interface->sleep_ms(100);
return scanner_read_status(dev);
}
// second is reliable void scanner_read_print_status(Genesys_Device& dev)
status = scanner_read_status(dev); {
if (DBG_LEVEL >= DBG_io) { scanner_read_status(dev);
debug_print_status(dbg, status);
}
return status;
} }
/** /**
@ -1700,10 +1699,6 @@ void sanei_genesys_wait_for_home(Genesys_Device* dev)
elapsed_ms += 100; elapsed_ms += 100;
status = scanner_read_status(*dev); status = scanner_read_status(*dev);
if (DBG_LEVEL >= DBG_io) {
debug_print_status(dbg, status);
}
} while (elapsed_ms < timeout_ms && !status.is_at_home); } while (elapsed_ms < timeout_ms && !status.is_at_home);
/* if after the timeout, head is still not parked, error out */ /* 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. // read sometimes returns the home sensor as engaged when this is not true.
Status scanner_read_reliable_status(Genesys_Device& dev); 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, extern void sanei_genesys_write_ahb(Genesys_Device* dev, uint32_t addr, uint32_t size,
uint8_t* data); uint8_t* data);