kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Add checkpoints to record internal state
rodzic
eadfdb57a4
commit
67588e46ef
|
@ -1419,8 +1419,13 @@ static void genesys_coarse_calibration(Genesys_Device* dev, Genesys_Sensor& sens
|
|||
|
||||
dev->cmd_set->begin_scan(dev, sensor, &dev->calib_reg, false);
|
||||
|
||||
sanei_genesys_read_data_from_scanner(dev, calibration_data.data(), size);
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("coarse_calibration");
|
||||
dev->cmd_set->end_scan(dev, &dev->calib_reg, true);
|
||||
return;
|
||||
}
|
||||
|
||||
sanei_genesys_read_data_from_scanner(dev, calibration_data.data(), size);
|
||||
std::memcpy(all_data.data() + i * size, calibration_data.data(), size);
|
||||
if (i == 3) /* last line */
|
||||
{
|
||||
|
@ -1544,6 +1549,14 @@ static void genesys_shading_calibration_impl(Genesys_Device* dev, const Genesys_
|
|||
bool start_motor = !is_dark;
|
||||
dev->cmd_set->begin_scan(dev, sensor, &dev->calib_reg, start_motor);
|
||||
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint(is_dark ? "dark_shading_calibration"
|
||||
: "white_shading_calibration");
|
||||
dev->cmd_set->end_scan(dev, &dev->calib_reg, true);
|
||||
return;
|
||||
}
|
||||
|
||||
sanei_genesys_read_data_from_scanner(dev, reinterpret_cast<std::uint8_t*>(calibration_data.data()),
|
||||
size);
|
||||
|
||||
|
@ -1739,6 +1752,12 @@ static void genesys_dark_white_shading_calibration(Genesys_Device* dev,
|
|||
|
||||
dev->cmd_set->begin_scan(dev, sensor, &dev->calib_reg, false);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("dark_white_shading_calibration");
|
||||
dev->cmd_set->end_scan(dev, &dev->calib_reg, true);
|
||||
return;
|
||||
}
|
||||
|
||||
sanei_genesys_read_data_from_scanner(dev, calibration_data.data(), size);
|
||||
|
||||
dev->cmd_set->end_scan(dev, &dev->calib_reg, true);
|
||||
|
@ -2977,6 +2996,12 @@ static void genesys_warmup_lamp(Genesys_Device* dev)
|
|||
DBG(DBG_info, "%s: one more loop\n", __func__);
|
||||
dev->cmd_set->begin_scan(dev, sensor, &dev->reg, false);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("warmup_lamp");
|
||||
dev->cmd_set->end_scan(dev, &dev->reg, true);
|
||||
return;
|
||||
}
|
||||
|
||||
wait_until_buffer_non_empty(dev);
|
||||
|
||||
try {
|
||||
|
@ -3182,6 +3207,11 @@ static void genesys_start_scan(Genesys_Device* dev, bool lamp_off)
|
|||
// start effective scan
|
||||
dev->cmd_set->begin_scan(dev, sensor, &dev->reg, true);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("start_scan");
|
||||
return;
|
||||
}
|
||||
|
||||
/*do we really need this? the valid data check should be sufficent -- pierre*/
|
||||
/* waits for head to reach scanning position */
|
||||
expected = dev->reg.get8(0x3d) * 65536
|
||||
|
@ -3299,28 +3329,35 @@ Problems with the first approach:
|
|||
total_bytes_to_read and total_bytes_read help in that case.
|
||||
*/
|
||||
|
||||
genesys_fill_read_buffer(dev);
|
||||
if (is_testing_mode()) {
|
||||
if (dev->total_bytes_read + *len > dev->total_bytes_to_read) {
|
||||
*len = dev->total_bytes_to_read - dev->total_bytes_read;
|
||||
}
|
||||
dev->total_bytes_read += *len;
|
||||
} else {
|
||||
genesys_fill_read_buffer(dev);
|
||||
|
||||
src_buffer = &(dev->read_buffer);
|
||||
src_buffer = &(dev->read_buffer);
|
||||
|
||||
/* move data to destination */
|
||||
bytes = src_buffer->avail();
|
||||
if (bytes > *len)
|
||||
bytes = *len;
|
||||
work_buffer_src = src_buffer->get_read_pos();
|
||||
/* move data to destination */
|
||||
bytes = std::min(src_buffer->avail(), *len);
|
||||
|
||||
std::memcpy(destination, work_buffer_src, bytes);
|
||||
*len = bytes;
|
||||
work_buffer_src = src_buffer->get_read_pos();
|
||||
|
||||
/* avoid signaling some extra data because we have treated a full block
|
||||
* on the last block */
|
||||
if (dev->total_bytes_read + *len > dev->total_bytes_to_read)
|
||||
*len = dev->total_bytes_to_read - dev->total_bytes_read;
|
||||
std::memcpy(destination, work_buffer_src, bytes);
|
||||
*len = bytes;
|
||||
|
||||
/* count bytes sent to frontend */
|
||||
dev->total_bytes_read += *len;
|
||||
/* avoid signaling some extra data because we have treated a full block
|
||||
* on the last block */
|
||||
if (dev->total_bytes_read + *len > dev->total_bytes_to_read) {
|
||||
*len = dev->total_bytes_to_read - dev->total_bytes_read;
|
||||
}
|
||||
|
||||
src_buffer->consume(bytes);
|
||||
/* count bytes sent to frontend */
|
||||
dev->total_bytes_read += *len;
|
||||
|
||||
src_buffer->consume(bytes);
|
||||
}
|
||||
|
||||
/* end scan if all needed data have been read */
|
||||
if(dev->total_bytes_read >= dev->total_bytes_to_read)
|
||||
|
@ -5831,11 +5868,13 @@ void sane_read_impl(SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_
|
|||
dev->local_buffer.produce(local_len);
|
||||
|
||||
dev->binarize_buffer.reset();
|
||||
genesys_gray_lineart(dev, dev->local_buffer.get_read_pos(),
|
||||
dev->binarize_buffer.get_write_pos(local_len / 8),
|
||||
dev->settings.pixels,
|
||||
local_len/dev->settings.pixels,
|
||||
dev->settings.threshold);
|
||||
if (!is_testing_mode()) {
|
||||
genesys_gray_lineart(dev, dev->local_buffer.get_read_pos(),
|
||||
dev->binarize_buffer.get_write_pos(local_len / 8),
|
||||
dev->settings.pixels,
|
||||
local_len / dev->settings.pixels,
|
||||
dev->settings.threshold);
|
||||
}
|
||||
dev->binarize_buffer.produce(local_len / 8);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
|
||||
#include "gl124.h"
|
||||
#include "gl124_registers.h"
|
||||
#include "test_settings.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
@ -1064,6 +1065,10 @@ static void gl124_stop_action(Genesys_Device* dev)
|
|||
|
||||
dev->interface->sleep_ms(100);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
loop = 10;
|
||||
while (loop > 0)
|
||||
{
|
||||
|
@ -1308,6 +1313,11 @@ void CommandSetGl124::slow_back_home(Genesys_Device* dev, bool wait_until_home)
|
|||
// post scan gpio : without that HOMSNR is unreliable
|
||||
gl124_homsnr_gpio(dev);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("slow_back_home");
|
||||
return;
|
||||
}
|
||||
|
||||
if (wait_until_home)
|
||||
{
|
||||
|
||||
|
@ -1407,6 +1417,13 @@ static void gl124_feed(Genesys_Device* dev, unsigned int steps, int reverse)
|
|||
throw;
|
||||
}
|
||||
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("feed");
|
||||
gl124_stop_action(dev);
|
||||
return;
|
||||
}
|
||||
|
||||
// wait until feed count reaches the required value, but do not exceed 30s
|
||||
do {
|
||||
val = sanei_genesys_get_status(dev);
|
||||
|
@ -1464,6 +1481,13 @@ void CommandSetGl124::search_start_position(Genesys_Device* dev) const
|
|||
|
||||
begin_scan(dev, sensor, &local_reg, true);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("search_start_position");
|
||||
end_scan(dev, &local_reg, true);
|
||||
dev->reg = local_reg;
|
||||
return;
|
||||
}
|
||||
|
||||
wait_until_buffer_non_empty(dev);
|
||||
|
||||
// now we're on target, we can read data
|
||||
|
@ -1804,6 +1828,13 @@ static void move_to_calibration_area(Genesys_Device* dev, const Genesys_Sensor&
|
|||
|
||||
DBG (DBG_info, "%s: starting line reading\n", __func__);
|
||||
dev->cmd_set->begin_scan(dev, sensor, ®s, true);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("move_to_calibration_area");
|
||||
gl124_stop_action(dev);
|
||||
return;
|
||||
}
|
||||
|
||||
sanei_genesys_read_data_from_scanner(dev, line.data(), size);
|
||||
|
||||
// stop scanning
|
||||
|
@ -1898,6 +1929,13 @@ SensorExposure CommandSetGl124::led_calibration(Genesys_Device* dev, const Genes
|
|||
|
||||
DBG(DBG_info, "%s: starting line reading\n", __func__);
|
||||
begin_scan(dev, sensor, ®s, true);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("led_calibration");
|
||||
gl124_stop_action(dev);
|
||||
return { 0, 0, 0 };
|
||||
}
|
||||
|
||||
sanei_genesys_read_data_from_scanner(dev, line.data(), total_size);
|
||||
|
||||
// stop scanning
|
||||
|
@ -2063,6 +2101,12 @@ void CommandSetGl124::offset_calibration(Genesys_Device* dev, const Genesys_Sens
|
|||
dev->interface->write_registers(regs);
|
||||
DBG(DBG_info, "%s: starting first line reading\n", __func__);
|
||||
begin_scan(dev, sensor, ®s, true);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("offset_calibration");
|
||||
return;
|
||||
}
|
||||
|
||||
sanei_genesys_read_data_from_scanner(dev, first_line.data(), total_size);
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
|
@ -2209,6 +2253,14 @@ void CommandSetGl124::coarse_gain_calibration(Genesys_Device* dev, const Genesys
|
|||
|
||||
set_fe(dev, sensor, AFE_SET);
|
||||
begin_scan(dev, sensor, ®s, true);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("coarse_gain_calibration");
|
||||
gl124_stop_action(dev);
|
||||
slow_back_home(dev, true);
|
||||
return;
|
||||
}
|
||||
|
||||
sanei_genesys_read_data_from_scanner(dev, line.data(), total_size);
|
||||
|
||||
if (DBG_LEVEL >= DBG_data) {
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
|
||||
#include "gl646.h"
|
||||
#include "gl646_registers.h"
|
||||
#include "test_settings.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
@ -1614,6 +1615,11 @@ void CommandSetGl646::slow_back_home(Genesys_Device* dev, bool wait_until_home)
|
|||
// starts scan
|
||||
dev->cmd_set->begin_scan(dev, sensor, &dev->reg, true);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("slow_back_home");
|
||||
return;
|
||||
}
|
||||
|
||||
/* loop until head parked */
|
||||
if (wait_until_home)
|
||||
{
|
||||
|
@ -1680,7 +1686,7 @@ void CommandSetGl646::search_start_position(Genesys_Device* dev) const
|
|||
|
||||
// scan the desired area
|
||||
std::vector<uint8_t> data;
|
||||
simple_scan(dev, sensor, settings, true, true, false, data);
|
||||
simple_scan(dev, sensor, settings, true, true, false, data, "search_start_position");
|
||||
|
||||
// handle stagger case : reorder gray data and thus loose some lines
|
||||
auto staggered_lines = dev->session.num_staggered_lines;
|
||||
|
@ -2050,7 +2056,11 @@ SensorExposure CommandSetGl646::led_calibration(Genesys_Device* dev, const Genes
|
|||
|
||||
DBG(DBG_info, "%s: starting first line reading\n", __func__);
|
||||
|
||||
simple_scan(dev, calib_sensor, settings, false, true, false, line);
|
||||
simple_scan(dev, calib_sensor, settings, false, true, false, line, "led_calibration");
|
||||
|
||||
if (is_testing_mode()) {
|
||||
return { 0, 0, 0 };
|
||||
}
|
||||
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
|
@ -2207,7 +2217,12 @@ static void ad_fe_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
|
|||
dev->frontend.set_offset(0, bottom);
|
||||
dev->frontend.set_offset(1, bottom);
|
||||
dev->frontend.set_offset(2, bottom);
|
||||
simple_scan(dev, calib_sensor, settings, false, true, false, line);
|
||||
simple_scan(dev, calib_sensor, settings, false, true, false, line,
|
||||
"ad_fe_offset_calibration");
|
||||
|
||||
if (is_testing_mode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
|
@ -2313,7 +2328,8 @@ void CommandSetGl646::offset_calibration(Genesys_Device* dev, const Genesys_Sens
|
|||
|
||||
std::vector<uint8_t> first_line, second_line;
|
||||
|
||||
simple_scan(dev, calib_sensor, settings, false, true, false, first_line);
|
||||
simple_scan(dev, calib_sensor, settings, false, true, false, first_line,
|
||||
"offset_first_line");
|
||||
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
|
@ -2331,7 +2347,8 @@ void CommandSetGl646::offset_calibration(Genesys_Device* dev, const Genesys_Sens
|
|||
dev->frontend.set_offset(0, top);
|
||||
dev->frontend.set_offset(1, top);
|
||||
dev->frontend.set_offset(2, top);
|
||||
simple_scan(dev, calib_sensor, settings, false, true, false, second_line);
|
||||
simple_scan(dev, calib_sensor, settings, false, true, false, second_line,
|
||||
"offset_second_line");
|
||||
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
|
@ -2344,6 +2361,10 @@ void CommandSetGl646::offset_calibration(Genesys_Device* dev, const Genesys_Sens
|
|||
black_pixels);
|
||||
DBG(DBG_io2, "%s: top avg=%d\n", __func__, topavg);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* loop until acceptable level */
|
||||
while ((pass < 32) && (top - bottom > 1))
|
||||
{
|
||||
|
@ -2355,7 +2376,8 @@ void CommandSetGl646::offset_calibration(Genesys_Device* dev, const Genesys_Sens
|
|||
dev->frontend.set_offset(2, (top + bottom) / 2);
|
||||
|
||||
// scan with no move
|
||||
simple_scan(dev, calib_sensor, settings, false, true, false, second_line);
|
||||
simple_scan(dev, calib_sensor, settings, false, true, false, second_line,
|
||||
"offset_calibration_i");
|
||||
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
|
@ -2443,7 +2465,8 @@ static void ad_fe_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sen
|
|||
// loop until each channel raises to acceptable level
|
||||
while ((average < calib_sensor.gain_white_ref) && (pass < 30)) {
|
||||
// scan with no move
|
||||
simple_scan(dev, calib_sensor, settings, false, true, false, line);
|
||||
simple_scan(dev, calib_sensor, settings, false, true, false, line,
|
||||
"ad_fe_coarse_gain_calibration");
|
||||
|
||||
/* log scanning data */
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
|
@ -2575,7 +2598,8 @@ void CommandSetGl646::coarse_gain_calibration(Genesys_Device* dev, const Genesys
|
|||
(average[2] < calib_sensor.gain_white_ref)) && (pass < 30))
|
||||
{
|
||||
// scan with no move
|
||||
simple_scan(dev, calib_sensor, settings, false, true, false, line);
|
||||
simple_scan(dev, calib_sensor, settings, false, true, false, line,
|
||||
"coarse_gain_calibration");
|
||||
|
||||
/* log scanning data */
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
|
@ -2934,7 +2958,8 @@ void CommandSetGl646::move_to_ta(Genesys_Device* dev) const
|
|||
*/
|
||||
static void simple_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Settings settings, bool move, bool forward,
|
||||
bool shading, std::vector<uint8_t>& data)
|
||||
bool shading, std::vector<uint8_t>& data,
|
||||
const char* scan_identifier)
|
||||
{
|
||||
DBG_HELPER_ARGS(dbg, "move=%d, forward=%d, shading=%d", move, forward, shading);
|
||||
unsigned int size, lines, x, y, bpp;
|
||||
|
@ -3008,6 +3033,11 @@ static void simple_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
|
|||
// starts scan
|
||||
dev->cmd_set->begin_scan(dev, sensor, &dev->reg, move);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint(scan_identifier);
|
||||
return;
|
||||
}
|
||||
|
||||
wait_until_buffer_non_empty(dev, true);
|
||||
|
||||
// now we're on target, we can read data
|
||||
|
@ -3093,7 +3123,7 @@ static void simple_move(Genesys_Device* dev, SANE_Int distance)
|
|||
settings.threshold = 0;
|
||||
|
||||
std::vector<uint8_t> data;
|
||||
simple_scan(dev, sensor, settings, true, true, false, data);
|
||||
simple_scan(dev, sensor, settings, true, true, false, data, "simple_move");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3326,7 +3356,11 @@ void CommandSetGl646::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
|
|||
while (pass < 20 && !found)
|
||||
{
|
||||
// scan a full width strip
|
||||
simple_scan(dev, calib_sensor, settings, true, forward, false, data);
|
||||
simple_scan(dev, calib_sensor, settings, true, forward, false, data, "search_strip");
|
||||
|
||||
if (is_testing_mode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
|
|
|
@ -97,7 +97,7 @@ static void simple_move(Genesys_Device* dev, SANE_Int distance);
|
|||
*/
|
||||
static void simple_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Settings settings, bool move, bool forward,
|
||||
bool shading, std::vector<uint8_t>& data);
|
||||
bool shading, std::vector<uint8_t>& data, const char* test_identifier);
|
||||
|
||||
/**
|
||||
* Send the stop scan command
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
|
||||
#include "gl841.h"
|
||||
#include "gl841_registers.h"
|
||||
#include "test_settings.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
@ -207,8 +208,6 @@ static void sanei_gl841_setup_sensor(Genesys_Device * dev, const Genesys_Sensor&
|
|||
static void
|
||||
gl841_init_lide80 (Genesys_Device * dev)
|
||||
{
|
||||
uint8_t val;
|
||||
|
||||
INITREG (0x01, 0x82); /* 0x02 = SHDAREA and no CISSET ! */
|
||||
INITREG (0x02, 0x10);
|
||||
INITREG (0x03, 0x50);
|
||||
|
@ -327,29 +326,44 @@ gl841_init_lide80 (Genesys_Device * dev)
|
|||
}
|
||||
|
||||
// specific scanner settings, clock and gpio first
|
||||
val = dev->interface->read_register(REG_0x6B);
|
||||
// FIXME: remove the dummy reads as we don't use the values
|
||||
if (!is_testing_mode()) {
|
||||
dev->interface->read_register(REG_0x6B);
|
||||
}
|
||||
dev->interface->write_register(REG_0x6B, 0x0c);
|
||||
dev->interface->write_register(0x06, 0x10);
|
||||
dev->interface->write_register(REG_0x6E, 0x6d);
|
||||
dev->interface->write_register(REG_0x6F, 0x80);
|
||||
dev->interface->write_register(REG_0x6B, 0x0e);
|
||||
val = dev->interface->read_register(REG_0x6C);
|
||||
if (!is_testing_mode()) {
|
||||
dev->interface->read_register(REG_0x6C);
|
||||
}
|
||||
dev->interface->write_register(REG_0x6C, 0x00);
|
||||
val = dev->interface->read_register(REG_0x6D);
|
||||
if (!is_testing_mode()) {
|
||||
dev->interface->read_register(REG_0x6D);
|
||||
}
|
||||
dev->interface->write_register(REG_0x6D, 0x8f);
|
||||
val = dev->interface->read_register(REG_0x6B);
|
||||
if (!is_testing_mode()) {
|
||||
dev->interface->read_register(REG_0x6B);
|
||||
}
|
||||
dev->interface->write_register(REG_0x6B, 0x0e);
|
||||
val = dev->interface->read_register(REG_0x6B);
|
||||
if (!is_testing_mode()) {
|
||||
dev->interface->read_register(REG_0x6B);
|
||||
}
|
||||
dev->interface->write_register(REG_0x6B, 0x0e);
|
||||
val = dev->interface->read_register(REG_0x6B);
|
||||
if (!is_testing_mode()) {
|
||||
dev->interface->read_register(REG_0x6B);
|
||||
}
|
||||
dev->interface->write_register(REG_0x6B, 0x0a);
|
||||
val = dev->interface->read_register(REG_0x6B);
|
||||
if (!is_testing_mode()) {
|
||||
dev->interface->read_register(REG_0x6B);
|
||||
}
|
||||
dev->interface->write_register(REG_0x6B, 0x02);
|
||||
val = dev->interface->read_register(REG_0x6B);
|
||||
if (!is_testing_mode()) {
|
||||
dev->interface->read_register(REG_0x6B);
|
||||
}
|
||||
dev->interface->write_register(REG_0x6B, 0x06);
|
||||
|
||||
(void) val; // FIXME: we don't use the information read from registers
|
||||
|
||||
dev->interface->write_0x8c(0x10, 0x94);
|
||||
dev->interface->write_register(0x09, 0x10);
|
||||
|
||||
|
@ -1878,6 +1892,10 @@ static void gl841_stop_action(Genesys_Device* dev)
|
|||
gl841_init_motor_regs_off(&local_reg,0);
|
||||
dev->interface->write_registers(local_reg);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* looks like writing the right registers to zero is enough to get the chip
|
||||
out of scan mode into command mode, actually triggering(writing to
|
||||
register 0x0f) seems to be unnecessary */
|
||||
|
@ -1953,6 +1971,12 @@ void CommandSetGl841::eject_document(Genesys_Device* dev) const
|
|||
throw;
|
||||
}
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("eject_document");
|
||||
gl841_stop_action(dev);
|
||||
return;
|
||||
}
|
||||
|
||||
if (gl841_get_paper_sensor(dev)) {
|
||||
DBG(DBG_info, "%s: paper still loaded\n", __func__);
|
||||
/* force document TRUE, because it is definitely present */
|
||||
|
@ -2185,6 +2209,12 @@ static void gl841_feed(Genesys_Device* dev, int steps)
|
|||
throw;
|
||||
}
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("feed");
|
||||
gl841_stop_action(dev);
|
||||
return;
|
||||
}
|
||||
|
||||
loop = 0;
|
||||
while (loop < 300) /* do not wait longer then 30 seconds */
|
||||
{
|
||||
|
@ -2295,6 +2325,11 @@ void CommandSetGl841::slow_back_home(Genesys_Device* dev, bool wait_until_home)
|
|||
throw;
|
||||
}
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("slow_back_home");
|
||||
return;
|
||||
}
|
||||
|
||||
if (wait_until_home)
|
||||
{
|
||||
while (loop < 300) /* do not wait longer then 30 seconds */
|
||||
|
@ -2369,6 +2404,13 @@ void CommandSetGl841::search_start_position(Genesys_Device* dev) const
|
|||
|
||||
dev->cmd_set->begin_scan(dev, sensor, &local_reg, true);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("search_start_position");
|
||||
dev->cmd_set->end_scan(dev, &local_reg, true);
|
||||
dev->reg = local_reg;
|
||||
return;
|
||||
}
|
||||
|
||||
wait_until_buffer_non_empty(dev);
|
||||
|
||||
// now we're on target, we can read data
|
||||
|
@ -2710,6 +2752,13 @@ SensorExposure CommandSetGl841::led_calibration(Genesys_Device* dev, const Genes
|
|||
|
||||
DBG(DBG_info, "%s: starting line reading\n", __func__);
|
||||
dev->cmd_set->begin_scan(dev, calib_sensor, ®s, true);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("led_calibration");
|
||||
slow_back_home(dev, true);
|
||||
return { 0, 0, 0 };
|
||||
}
|
||||
|
||||
sanei_genesys_read_data_from_scanner(dev, line.data(), total_size);
|
||||
|
||||
if (DBG_LEVEL >= DBG_data) {
|
||||
|
@ -2893,6 +2942,13 @@ static void ad_fe_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
|
|||
dev->interface->write_registers(regs);
|
||||
dev->cmd_set->set_fe(dev, calib_sensor, AFE_SET);
|
||||
dev->cmd_set->begin_scan(dev, calib_sensor, ®s, true);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("ad_fe_offset_calibration");
|
||||
gl841_stop_action(dev);
|
||||
return;
|
||||
}
|
||||
|
||||
sanei_genesys_read_data_from_scanner(dev, line.data(), total_size);
|
||||
gl841_stop_action (dev);
|
||||
if (DBG_LEVEL >= DBG_data) {
|
||||
|
@ -3042,6 +3098,11 @@ void CommandSetGl841::offset_calibration(Genesys_Device* dev, const Genesys_Sens
|
|||
DBG(DBG_info, "%s: starting first line reading\n", __func__);
|
||||
dev->cmd_set->begin_scan(dev, calib_sensor, ®s, true);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("offset_calibration");
|
||||
return;
|
||||
}
|
||||
|
||||
sanei_genesys_read_data_from_scanner(dev, first_line.data(), total_size);
|
||||
|
||||
if (DBG_LEVEL >= DBG_data) {
|
||||
|
@ -3364,6 +3425,14 @@ void CommandSetGl841::coarse_gain_calibration(Genesys_Device* dev, const Genesys
|
|||
std::vector<uint8_t> line(total_size);
|
||||
|
||||
dev->cmd_set->begin_scan(dev, calib_sensor, ®s, true);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("coarse_gain_calibration");
|
||||
gl841_stop_action(dev);
|
||||
slow_back_home(dev, true);
|
||||
return;
|
||||
}
|
||||
|
||||
sanei_genesys_read_data_from_scanner(dev, line.data(), total_size);
|
||||
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
|
@ -3632,8 +3701,13 @@ void CommandSetGl841::init(Genesys_Device* dev) const
|
|||
|
||||
sanei_usb_set_timeout(1000);/* 1 second*/
|
||||
|
||||
// ignore errors. next read will succeed
|
||||
sanei_genesys_read_data_from_scanner(dev, line.data(), size);
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("init");
|
||||
} else {
|
||||
// ignore errors. next read will succeed
|
||||
catch_all_exceptions(__func__,
|
||||
[&](){ sanei_genesys_read_data_from_scanner(dev, line.data(), size); });
|
||||
}
|
||||
|
||||
sanei_usb_set_timeout(30 * 1000);/* 30 seconds*/
|
||||
|
||||
|
@ -3758,6 +3832,12 @@ void CommandSetGl841::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
|
|||
|
||||
dev->cmd_set->begin_scan(dev, sensor, &local_reg, true);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("search_strip");
|
||||
gl841_stop_action(dev);
|
||||
return;
|
||||
}
|
||||
|
||||
// waits for valid data
|
||||
wait_until_buffer_non_empty(dev);
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
|
||||
#include "gl843_registers.h"
|
||||
#include "gl843.h"
|
||||
#include "test_settings.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
@ -1363,6 +1364,10 @@ static void gl843_stop_action(Genesys_Device* dev)
|
|||
|
||||
dev->interface->sleep_ms(100);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
loop = 10;
|
||||
while (loop > 0)
|
||||
{
|
||||
|
@ -1893,6 +1898,11 @@ void CommandSetGl843::slow_back_home(Genesys_Device* dev, bool wait_until_home)
|
|||
throw;
|
||||
}
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("slow_back_home");
|
||||
return;
|
||||
}
|
||||
|
||||
if (wait_until_home)
|
||||
{
|
||||
|
||||
|
@ -1968,6 +1978,13 @@ void CommandSetGl843::search_start_position(Genesys_Device* dev) const
|
|||
|
||||
dev->cmd_set->begin_scan(dev, sensor, &local_reg, true);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("search_start_position");
|
||||
end_scan(dev, &local_reg, true);
|
||||
dev->reg = local_reg;
|
||||
return;
|
||||
}
|
||||
|
||||
wait_until_buffer_non_empty(dev);
|
||||
|
||||
// now we're on target, we can read data
|
||||
|
@ -2097,6 +2114,12 @@ static void gl843_feed(Genesys_Device* dev, unsigned int steps)
|
|||
throw;
|
||||
}
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("feed");
|
||||
// FIXME: other chips call *_stop_action()
|
||||
return;
|
||||
}
|
||||
|
||||
// wait until feed count reaches the required value, but do not exceed 30s
|
||||
do {
|
||||
val = sanei_genesys_get_status(dev);
|
||||
|
@ -2388,6 +2411,13 @@ SensorExposure CommandSetGl843::led_calibration(Genesys_Device* dev, const Genes
|
|||
|
||||
DBG(DBG_info, "%s: starting first line reading\n", __func__);
|
||||
dev->cmd_set->begin_scan(dev, calib_sensor, ®s, true);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("led_calibration");
|
||||
slow_back_home(dev, true);
|
||||
return { 0, 0, 0 };
|
||||
}
|
||||
|
||||
auto image = read_unshuffled_image_from_scanner(dev, session,
|
||||
session.output_total_bytes_raw);
|
||||
gl843_stop_action_no_move(dev, ®s);
|
||||
|
@ -2593,6 +2623,13 @@ void CommandSetGl843::offset_calibration(Genesys_Device* dev, const Genesys_Sens
|
|||
DBG(DBG_info, "%s: starting first line reading\n", __func__);
|
||||
|
||||
dev->cmd_set->begin_scan(dev, calib_sensor, ®s, true);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("offset_calibration");
|
||||
gl843_stop_action_no_move(dev, ®s);
|
||||
return;
|
||||
}
|
||||
|
||||
auto first_line = read_unshuffled_image_from_scanner(dev, session,
|
||||
session.output_total_bytes_raw);
|
||||
gl843_stop_action_no_move(dev, ®s);
|
||||
|
@ -2799,6 +2836,14 @@ void CommandSetGl843::coarse_gain_calibration(Genesys_Device* dev, const Genesys
|
|||
|
||||
dev->cmd_set->set_fe(dev, calib_sensor, AFE_SET);
|
||||
dev->cmd_set->begin_scan(dev, calib_sensor, ®s, true);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("coarse_gain_calibration");
|
||||
gl843_stop_action(dev);
|
||||
slow_back_home(dev, true);
|
||||
return;
|
||||
}
|
||||
|
||||
auto line = read_unshuffled_image_from_scanner(dev, session, session.output_total_bytes_raw);
|
||||
gl843_stop_action_no_move(dev, ®s);
|
||||
|
||||
|
@ -3154,6 +3199,12 @@ void CommandSetGl843::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
|
|||
|
||||
dev->cmd_set->begin_scan(dev, calib_sensor, &local_reg, true);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("search_strip");
|
||||
gl843_stop_action(dev);
|
||||
return;
|
||||
}
|
||||
|
||||
wait_until_buffer_non_empty(dev);
|
||||
|
||||
// now we're on target, we can read data
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
|
||||
#include "gl846.h"
|
||||
#include "gl846_registers.h"
|
||||
#include "test_settings.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
@ -899,6 +900,10 @@ static void gl846_stop_action(Genesys_Device* dev)
|
|||
dev->interface->write_register(REG_0x01, val);
|
||||
dev->interface->sleep_ms(100);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
loop = 10;
|
||||
while (loop > 0)
|
||||
{
|
||||
|
@ -1064,6 +1069,11 @@ void CommandSetGl846::slow_back_home(Genesys_Device* dev, bool wait_until_home)
|
|||
// post scan gpio : without that HOMSNR is unreliable
|
||||
gl846_homsnr_gpio(dev);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("slow_back_home");
|
||||
return;
|
||||
}
|
||||
|
||||
if (wait_until_home)
|
||||
{
|
||||
while (loop < 300) /* do not wait longer then 30 seconds */
|
||||
|
@ -1138,6 +1148,13 @@ void CommandSetGl846::search_start_position(Genesys_Device* dev) const
|
|||
|
||||
begin_scan(dev, sensor, &local_reg, true);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("search_start_position");
|
||||
end_scan(dev, &local_reg, true);
|
||||
dev->reg = local_reg;
|
||||
return;
|
||||
}
|
||||
|
||||
wait_until_buffer_non_empty(dev);
|
||||
|
||||
// now we're on target, we can read data
|
||||
|
@ -1263,6 +1280,12 @@ static void gl846_feed(Genesys_Device* dev, unsigned int steps)
|
|||
throw;
|
||||
}
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("feed");
|
||||
gl846_stop_action(dev);
|
||||
return;
|
||||
}
|
||||
|
||||
// wait until feed count reaches the required value, but do not exceed 30s
|
||||
do {
|
||||
val = sanei_genesys_get_status(dev);
|
||||
|
@ -1568,6 +1591,14 @@ SensorExposure CommandSetGl846::led_calibration(Genesys_Device* dev, const Genes
|
|||
|
||||
DBG(DBG_info, "%s: starting line reading\n", __func__);
|
||||
begin_scan(dev, sensor, ®s, true);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("led_calibration");
|
||||
gl846_stop_action(dev);
|
||||
slow_back_home(dev, true);
|
||||
return { 0, 0, 0 };
|
||||
}
|
||||
|
||||
sanei_genesys_read_data_from_scanner(dev, line.data(), total_size);
|
||||
|
||||
// stop scanning
|
||||
|
@ -1873,6 +1904,12 @@ void CommandSetGl846::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
|
|||
|
||||
begin_scan(dev, sensor, &local_reg, true);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("search_strip");
|
||||
gl846_stop_action(dev);
|
||||
return;
|
||||
}
|
||||
|
||||
wait_until_buffer_non_empty(dev);
|
||||
|
||||
// now we're on target, we can read data
|
||||
|
@ -2103,6 +2140,12 @@ void CommandSetGl846::offset_calibration(Genesys_Device* dev, const Genesys_Sens
|
|||
dev->interface->write_registers(regs);
|
||||
DBG(DBG_info, "%s: starting first line reading\n", __func__);
|
||||
begin_scan(dev, sensor, ®s, true);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("offset_calibration");
|
||||
return;
|
||||
}
|
||||
|
||||
sanei_genesys_read_data_from_scanner(dev, first_line.data(), total_size);
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
|
@ -2244,6 +2287,14 @@ void CommandSetGl846::coarse_gain_calibration(Genesys_Device* dev, const Genesys
|
|||
|
||||
set_fe(dev, sensor, AFE_SET);
|
||||
begin_scan(dev, sensor, ®s, true);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("coarse_gain_calibration");
|
||||
gl846_stop_action(dev);
|
||||
slow_back_home(dev, true);
|
||||
return;
|
||||
}
|
||||
|
||||
sanei_genesys_read_data_from_scanner(dev, line.data(), total_size);
|
||||
|
||||
if (DBG_LEVEL >= DBG_data) {
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
|
||||
#include "gl847.h"
|
||||
#include "gl847_registers.h"
|
||||
#include "test_settings.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
@ -906,6 +907,10 @@ static void gl847_stop_action(Genesys_Device* dev)
|
|||
|
||||
dev->interface->sleep_ms(100);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
loop = 10;
|
||||
while (loop > 0)
|
||||
{
|
||||
|
@ -1108,6 +1113,11 @@ void CommandSetGl847::slow_back_home(Genesys_Device* dev, bool wait_until_home)
|
|||
// post scan gpio : without that HOMSNR is unreliable
|
||||
gl847_homsnr_gpio(dev);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("slow_back_home");
|
||||
return;
|
||||
}
|
||||
|
||||
if (wait_until_home)
|
||||
{
|
||||
while (loop < 300) /* do not wait longer then 30 seconds */
|
||||
|
@ -1182,6 +1192,13 @@ void CommandSetGl847::search_start_position(Genesys_Device* dev) const
|
|||
|
||||
begin_scan(dev, sensor, &local_reg, true);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("search_start_position");
|
||||
end_scan(dev, &local_reg, true);
|
||||
dev->reg = local_reg;
|
||||
return;
|
||||
}
|
||||
|
||||
wait_until_buffer_non_empty(dev);
|
||||
|
||||
// now we're on target, we can read data
|
||||
|
@ -1305,6 +1322,12 @@ static void gl847_feed(Genesys_Device* dev, unsigned int steps)
|
|||
throw;
|
||||
}
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("feed");
|
||||
gl847_stop_action(dev);
|
||||
return;
|
||||
}
|
||||
|
||||
// wait until feed count reaches the required value, but do not exceed 30s
|
||||
do {
|
||||
val = sanei_genesys_get_status(dev);
|
||||
|
@ -1602,6 +1625,14 @@ SensorExposure CommandSetGl847::led_calibration(Genesys_Device* dev, const Genes
|
|||
|
||||
DBG(DBG_info, "%s: starting line reading\n", __func__);
|
||||
begin_scan(dev, sensor, ®s, true);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("led_calibration");
|
||||
gl847_stop_action(dev);
|
||||
slow_back_home(dev, true);
|
||||
return { 0, 0, 0 };
|
||||
}
|
||||
|
||||
sanei_genesys_read_data_from_scanner(dev, line.data(), total_size);
|
||||
|
||||
// stop scanning
|
||||
|
@ -1938,6 +1969,12 @@ void CommandSetGl847::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
|
|||
|
||||
begin_scan(dev, sensor, &local_reg, true);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("search_strip");
|
||||
gl847_stop_action(dev);
|
||||
return;
|
||||
}
|
||||
|
||||
wait_until_buffer_non_empty(dev);
|
||||
|
||||
// now we're on target, we can read data
|
||||
|
@ -2170,6 +2207,12 @@ void CommandSetGl847::offset_calibration(Genesys_Device* dev, const Genesys_Sens
|
|||
dev->interface->write_registers(regs);
|
||||
DBG(DBG_info, "%s: starting first line reading\n", __func__);
|
||||
begin_scan(dev, sensor, ®s, true);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("offset_calibration");
|
||||
return;
|
||||
}
|
||||
|
||||
sanei_genesys_read_data_from_scanner(dev, first_line.data(), total_size);
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
|
@ -2309,6 +2352,14 @@ void CommandSetGl847::coarse_gain_calibration(Genesys_Device* dev, const Genesys
|
|||
|
||||
set_fe(dev, sensor, AFE_SET);
|
||||
begin_scan(dev, sensor, ®s, true);
|
||||
|
||||
if (is_testing_mode()) {
|
||||
dev->interface->test_checkpoint("coarse_gain_calibration");
|
||||
gl847_stop_action(dev);
|
||||
slow_back_home(dev, true);
|
||||
return;
|
||||
}
|
||||
|
||||
sanei_genesys_read_data_from_scanner(dev, line.data(), total_size);
|
||||
|
||||
if (DBG_LEVEL >= DBG_data) {
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
|
||||
#include "low.h"
|
||||
#include "assert.h"
|
||||
#include "test_settings.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cmath>
|
||||
|
@ -1500,8 +1501,10 @@ void sanei_genesys_asic_init(Genesys_Device* dev, bool /*max_regs*/)
|
|||
check PWRBIT, if reset scanner has been freshly powered up. This bit will be set to later
|
||||
so that following reads can detect power down/up cycle
|
||||
*/
|
||||
if (dev->interface->read_register(0x06) & 0x10) {
|
||||
cold = false;
|
||||
if (!is_testing_mode()) {
|
||||
if (dev->interface->read_register(0x06) & 0x10) {
|
||||
cold = false;
|
||||
}
|
||||
}
|
||||
DBG (DBG_info, "%s: device is %s\n", __func__, cold ? "cold" : "warm");
|
||||
|
||||
|
@ -1586,6 +1589,10 @@ void sanei_genesys_wait_for_home(Genesys_Device* dev)
|
|||
/* clear the parking status whatever the outcome of the function */
|
||||
dev->parking = false;
|
||||
|
||||
if (is_testing_mode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 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
|
||||
val = sanei_genesys_get_status(dev);
|
||||
|
|
Ładowanie…
Reference in New Issue