kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Add more debug printers
rodzic
38c32ff702
commit
3ac009abe2
|
@ -505,7 +505,7 @@ libgenesys_la_SOURCES = genesys/genesys.cpp genesys/genesys.h \
|
|||
genesys/image_pipeline.h genesys/image_pipeline.cpp \
|
||||
genesys/image_pixel.h genesys/image_pixel.cpp \
|
||||
genesys/image.h genesys/image.cpp \
|
||||
genesys/motor.h \
|
||||
genesys/motor.h genesys/motor.cpp \
|
||||
genesys/register.h \
|
||||
genesys/register_cache.h \
|
||||
genesys/scanner_interface.h genesys/scanner_interface.cpp \
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include "device.h"
|
||||
#include "command_set.h"
|
||||
#include "low.h"
|
||||
#include "utilities.h"
|
||||
|
||||
namespace genesys {
|
||||
|
||||
|
@ -103,6 +104,73 @@ ImagePipelineNodeBytesSource& Genesys_Device::get_pipeline_source()
|
|||
return static_cast<ImagePipelineNodeBytesSource&>(pipeline.front());
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const Genesys_Device& dev)
|
||||
{
|
||||
StreamStateSaver state_saver{out};
|
||||
|
||||
out << "Genesys_Device{\n"
|
||||
<< std::hex
|
||||
<< " vendorId: 0x" << dev.vendorId << '\n'
|
||||
<< " productId: 0x" << dev.productId << '\n'
|
||||
<< std::dec
|
||||
<< " usb_mode: " << dev.usb_mode << '\n'
|
||||
<< " file_name: " << dev.file_name << '\n'
|
||||
<< " calib_file: " << dev.calib_file << '\n'
|
||||
<< " force_calibration: " << dev.force_calibration << '\n'
|
||||
<< " ignore_offsets: " << dev.ignore_offsets << '\n'
|
||||
<< " model: (not printed)\n"
|
||||
<< " reg: " << format_indent_braced_list(4, dev.reg) << '\n'
|
||||
<< " calib_reg: " << format_indent_braced_list(4, dev.calib_reg) << '\n'
|
||||
<< " settings: " << format_indent_braced_list(4, dev.settings) << '\n'
|
||||
<< " frontend: " << format_indent_braced_list(4, dev.frontend) << '\n'
|
||||
<< " frontend_initial: " << format_indent_braced_list(4, dev.frontend_initial) << '\n'
|
||||
<< " frontend_is_init: " << dev.frontend_is_init << '\n'
|
||||
<< " gpo.regs: " << format_indent_braced_list(4, dev.gpo.regs) << '\n'
|
||||
<< " motor: " << format_indent_braced_list(4, dev.motor) << '\n'
|
||||
<< " control[0..6]: " << std::hex
|
||||
<< static_cast<unsigned>(dev.control[0]) << ' '
|
||||
<< static_cast<unsigned>(dev.control[1]) << ' '
|
||||
<< static_cast<unsigned>(dev.control[2]) << ' '
|
||||
<< static_cast<unsigned>(dev.control[3]) << ' '
|
||||
<< static_cast<unsigned>(dev.control[4]) << ' '
|
||||
<< static_cast<unsigned>(dev.control[5]) << '\n' << std::dec
|
||||
<< " average_size: " << dev.average_size << '\n'
|
||||
<< " calib_pixels: " << dev.calib_pixels << '\n'
|
||||
<< " calib_lines: " << dev.calib_lines << '\n'
|
||||
<< " calib_channels: " << dev.calib_channels << '\n'
|
||||
<< " calib_resolution: " << dev.calib_resolution << '\n'
|
||||
<< " calib_total_bytes_to_read: " << dev.calib_total_bytes_to_read << '\n'
|
||||
<< " calib_session: " << format_indent_braced_list(4, dev.calib_session) << '\n'
|
||||
<< " calib_pixels_offset: " << dev.calib_pixels_offset << '\n'
|
||||
<< " gamma_override_tables[0].size(): " << dev.gamma_override_tables[0].size() << '\n'
|
||||
<< " gamma_override_tables[1].size(): " << dev.gamma_override_tables[1].size() << '\n'
|
||||
<< " gamma_override_tables[2].size(): " << dev.gamma_override_tables[2].size() << '\n'
|
||||
<< " white_average_data.size(): " << dev.white_average_data.size() << '\n'
|
||||
<< " dark_average_data.size(): " << dev.dark_average_data.size() << '\n'
|
||||
<< " already_initialized: " << dev.already_initialized << '\n'
|
||||
<< " scanhead_position_in_steps: " << dev.scanhead_position_in_steps << '\n'
|
||||
<< " read_active: " << dev.read_active << '\n'
|
||||
<< " parking: " << dev.parking << '\n'
|
||||
<< " document: " << dev.document << '\n'
|
||||
<< " needs_home_ta: " << dev.needs_home_ta << '\n'
|
||||
<< " read_buffer.size(): " << dev.read_buffer.size() << '\n'
|
||||
<< " binarize_buffer.size(): " << dev.binarize_buffer.size() << '\n'
|
||||
<< " local_buffer.size(): " << dev.local_buffer.size() << '\n'
|
||||
<< " oe_buffer.size(): " << dev.oe_buffer.size() << '\n'
|
||||
<< " total_bytes_read: " << dev.total_bytes_read << '\n'
|
||||
<< " total_bytes_to_read: " << dev.total_bytes_to_read << '\n'
|
||||
<< " session: " << format_indent_braced_list(4, dev.session) << '\n'
|
||||
<< " lineart_lut: (not printed)\n"
|
||||
<< " calibration_cache: (not printed)\n"
|
||||
<< " line_count: " << dev.line_count << '\n'
|
||||
<< " segment_order: "
|
||||
<< format_indent_braced_list(4, format_vector_unsigned(4, dev.segment_order)) << '\n'
|
||||
<< " buffer_image: " << dev.buffer_image << '\n'
|
||||
<< " img_buffer.size(): " << dev.img_buffer.size() << '\n'
|
||||
<< '}';
|
||||
return out;
|
||||
}
|
||||
|
||||
void apply_reg_settings_to_device(Genesys_Device& dev, const GenesysRegisterSettingSet& regs)
|
||||
{
|
||||
for (const auto& reg : regs) {
|
||||
|
|
|
@ -365,6 +365,8 @@ private:
|
|||
friend class ScannerInterfaceUsb;
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const Genesys_Device& dev);
|
||||
|
||||
void apply_reg_settings_to_device(Genesys_Device& dev, const GenesysRegisterSettingSet& regs);
|
||||
|
||||
} // namespace genesys
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
/* sane - Scanner Access Now Easy.
|
||||
|
||||
Copyright (C) 2019 Povilas Kanapickas <povilas@radix.lt>
|
||||
|
||||
This file is part of the SANE package.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
MA 02111-1307, USA.
|
||||
|
||||
As a special exception, the authors of SANE give permission for
|
||||
additional uses of the libraries contained in this release of SANE.
|
||||
|
||||
The exception is that, if you link a SANE library with other files
|
||||
to produce an executable, this does not by itself cause the
|
||||
resulting executable to be covered by the GNU General Public
|
||||
License. Your use of that executable is in no way restricted on
|
||||
account of linking the SANE library code into it.
|
||||
|
||||
This exception does not, however, invalidate any other reasons why
|
||||
the executable file might be covered by the GNU General Public
|
||||
License.
|
||||
|
||||
If you submit changes to SANE to the maintainers to be included in
|
||||
a subsequent release, you agree by submitting the changes that
|
||||
those changes may be distributed with this exception intact.
|
||||
|
||||
If you write modifications of your own for SANE, it is your choice
|
||||
whether to permit this exception to apply to your modifications.
|
||||
If you do not wish that, delete this exception notice.
|
||||
*/
|
||||
|
||||
#define DEBUG_DECLARE_ONLY
|
||||
|
||||
#include "motor.h"
|
||||
#include "utilities.h"
|
||||
|
||||
namespace genesys {
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const Genesys_Motor_Slope& slope)
|
||||
{
|
||||
out << "Genesys_Motor_Slope{\n"
|
||||
<< " maximum_start_speed: " << slope.maximum_start_speed << '\n'
|
||||
<< " maximum_speed: " << slope.maximum_speed << '\n'
|
||||
<< " minimum_steps: " << slope.minimum_steps << '\n'
|
||||
<< " g: " << slope.g << '\n'
|
||||
<< '}';
|
||||
return out;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const Genesys_Motor& motor)
|
||||
{
|
||||
out << "Genesys_Motor{\n"
|
||||
<< " id: " << static_cast<unsigned>(motor.id) << '\n'
|
||||
<< " base_ydpi: " << motor.base_ydpi << '\n'
|
||||
<< " optical_ydpi: " << motor.optical_ydpi << '\n'
|
||||
<< " max_step_type: " << motor.max_step_type << '\n'
|
||||
<< " slopes: "
|
||||
<< format_indent_braced_list(4, format_vector_indent_braced(4, "Genesys_Motor_Slope",
|
||||
motor.slopes))
|
||||
<< '}';
|
||||
return out;
|
||||
}
|
||||
|
||||
} // namespace genesys
|
|
@ -84,6 +84,8 @@ struct Genesys_Motor_Slope
|
|||
// { 9560, 1912, 31, 0.8 },
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const Genesys_Motor_Slope& slope);
|
||||
|
||||
|
||||
struct Genesys_Motor
|
||||
{
|
||||
|
@ -101,6 +103,8 @@ struct Genesys_Motor
|
|||
std::vector<Genesys_Motor_Slope> slopes;
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const Genesys_Motor& motor);
|
||||
|
||||
} // namespace genesys
|
||||
|
||||
#endif // BACKEND_GENESYS_MOTOR_H
|
||||
|
|
|
@ -49,6 +49,75 @@
|
|||
|
||||
namespace genesys {
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const FrontendType& type)
|
||||
{
|
||||
switch (type) {
|
||||
case FrontendType::UNKNOWN: out << "UNKNOWN"; break;
|
||||
case FrontendType::WOLFSON: out << "WOLFSON"; break;
|
||||
case FrontendType::ANALOG_DEVICES: out << "ANALOG_DEVICES"; break;
|
||||
default: out << "(unknown value)";
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const GenesysFrontendLayout& layout)
|
||||
{
|
||||
StreamStateSaver state_saver{out};
|
||||
|
||||
out << "GenesysFrontendLayout{\n"
|
||||
<< " type: " << layout.type << '\n'
|
||||
<< std::hex
|
||||
<< " offset_addr[0]: " << layout.offset_addr[0] << '\n'
|
||||
<< " offset_addr[1]: " << layout.offset_addr[1] << '\n'
|
||||
<< " offset_addr[2]: " << layout.offset_addr[2] << '\n'
|
||||
<< " gain_addr[0]: " << layout.gain_addr[0] << '\n'
|
||||
<< " gain_addr[1]: " << layout.gain_addr[1] << '\n'
|
||||
<< " gain_addr[2]: " << layout.gain_addr[2] << '\n'
|
||||
<< '}';
|
||||
return out;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const Genesys_Frontend& frontend)
|
||||
{
|
||||
StreamStateSaver state_saver{out};
|
||||
|
||||
out << "Genesys_Frontend{\n"
|
||||
<< " id: " << static_cast<unsigned>(frontend.id) << '\n'
|
||||
<< " regs: " << format_indent_braced_list(4, frontend.regs) << '\n'
|
||||
<< std::hex
|
||||
<< " reg2[0]: " << frontend.reg2[0] << '\n'
|
||||
<< " reg2[1]: " << frontend.reg2[1] << '\n'
|
||||
<< " reg2[2]: " << frontend.reg2[2] << '\n'
|
||||
<< " layout: " << format_indent_braced_list(4, frontend.layout) << '\n'
|
||||
<< '}';
|
||||
return out;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const SensorExposure& exposure)
|
||||
{
|
||||
out << "SensorExposure{\n"
|
||||
<< " red: " << exposure.red << '\n'
|
||||
<< " green: " << exposure.green << '\n'
|
||||
<< " blue: " << exposure.blue << '\n'
|
||||
<< '}';
|
||||
return out;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const SensorProfile& profile)
|
||||
{
|
||||
out << "SensorProfile{\n"
|
||||
<< " dpi: " << profile.dpi << '\n'
|
||||
<< " ccd_size_divisor: " << profile.ccd_size_divisor << '\n'
|
||||
<< " exposure_lperiod: " << profile.exposure_lperiod << '\n'
|
||||
<< " exposure: " << format_indent_braced_list(4, profile.exposure) << '\n'
|
||||
<< " segment_size: " << profile.segment_size << '\n'
|
||||
<< " segment_order: "
|
||||
<< format_indent_braced_list(4, format_vector_unsigned(4, profile.segment_order)) << '\n'
|
||||
<< " custom_regs: " << format_indent_braced_list(4, profile.custom_regs) << '\n'
|
||||
<< '}';
|
||||
return out;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const Genesys_Sensor& sensor)
|
||||
{
|
||||
out << "Genesys_Sensor{\n"
|
||||
|
@ -63,20 +132,30 @@ std::ostream& operator<<(std::ostream& out, const Genesys_Sensor& sensor)
|
|||
}
|
||||
out << " }\n";
|
||||
}
|
||||
out << " method: " << sensor.method << '\n'
|
||||
out << " channels: " << format_vector_unsigned(4, sensor.channels) << '\n'
|
||||
<< " method: " << sensor.method << '\n'
|
||||
<< " register_dpihw_override: " << sensor.register_dpihw_override << '\n'
|
||||
<< " logical_dpihw_override: " << sensor.logical_dpihw_override << '\n'
|
||||
<< " dpiset_override: " << sensor.dpiset_override << '\n'
|
||||
<< " ccd_size_divisor: " << sensor.ccd_size_divisor << '\n'
|
||||
<< " pixel_count_multiplier: " << sensor.pixel_count_multiplier << '\n'
|
||||
<< " black_pixels: " << sensor.black_pixels << '\n'
|
||||
<< " dummy_pixel: " << sensor.dummy_pixel << '\n'
|
||||
<< " ccd_start_xoffset: " << sensor.ccd_start_xoffset << '\n'
|
||||
<< " sensor_pixels: " << sensor.sensor_pixels << '\n'
|
||||
<< " fau_gain_white_ref: " << sensor.fau_gain_white_ref << '\n'
|
||||
<< " gain_white_ref: " << sensor.gain_white_ref << '\n'
|
||||
<< " exposure.red: " << sensor.exposure.red << '\n'
|
||||
<< " exposure.green: " << sensor.exposure.green << '\n'
|
||||
<< " exposure.blue: " << sensor.exposure.blue << '\n'
|
||||
<< " exposure: " << format_indent_braced_list(4, sensor.exposure) << '\n'
|
||||
<< " exposure_lperiod: " << sensor.exposure_lperiod << '\n'
|
||||
<< " segment_size: " << sensor.segment_size << '\n'
|
||||
<< " segment_order: "
|
||||
<< format_indent_braced_list(4, format_vector_unsigned(4, sensor.segment_order)) << '\n'
|
||||
<< " custom_base_regs: " << format_indent_braced_list(4, sensor.custom_base_regs) << '\n'
|
||||
<< " custom_regs: " << format_indent_braced_list(4, sensor.custom_regs) << '\n'
|
||||
<< " custom_fe_regs: " << format_indent_braced_list(4, sensor.custom_fe_regs) << '\n'
|
||||
<< " sensor.sensor_profiles: "
|
||||
<< format_indent_braced_list(4, format_vector_indent_braced(4, "SensorProfile",
|
||||
sensor.sensor_profiles))
|
||||
<< " gamma.red: " << sensor.gamma[0] << '\n'
|
||||
<< " gamma.green: " << sensor.gamma[1] << '\n'
|
||||
<< " gamma.blue: " << sensor.gamma[2] << '\n'
|
||||
|
|
|
@ -74,7 +74,6 @@ enum class FrontendType : unsigned
|
|||
ANALOG_DEVICES
|
||||
};
|
||||
|
||||
|
||||
inline void serialize(std::istream& str, FrontendType& x)
|
||||
{
|
||||
unsigned value;
|
||||
|
@ -88,6 +87,8 @@ inline void serialize(std::ostream& str, FrontendType& x)
|
|||
serialize(str, value);
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const FrontendType& type);
|
||||
|
||||
struct GenesysFrontendLayout
|
||||
{
|
||||
FrontendType type = FrontendType::UNKNOWN;
|
||||
|
@ -112,6 +113,7 @@ void serialize(Stream& str, GenesysFrontendLayout& x)
|
|||
serialize(str, x.gain_addr);
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const GenesysFrontendLayout& layout);
|
||||
|
||||
/** @brief Data structure to set up analog frontend.
|
||||
The analog frontend converts analog value from image sensor to digital value. It has its own
|
||||
|
@ -162,6 +164,8 @@ struct Genesys_Frontend
|
|||
}
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const Genesys_Frontend& frontend);
|
||||
|
||||
template<class Stream>
|
||||
void serialize(Stream& str, Genesys_Frontend& x)
|
||||
{
|
||||
|
@ -190,6 +194,8 @@ struct SensorExposure {
|
|||
}
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const SensorExposure& exposure);
|
||||
|
||||
struct SensorProfile
|
||||
{
|
||||
unsigned dpi = 0;
|
||||
|
@ -222,6 +228,8 @@ struct SensorProfile
|
|||
}
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const SensorProfile& profile);
|
||||
|
||||
template<class Stream>
|
||||
void serialize(Stream& str, SensorProfile& x)
|
||||
{
|
||||
|
|
|
@ -144,6 +144,37 @@ std::string format_indent_braced_list(unsigned indent, const T& x)
|
|||
return out_str;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
std::string format_vector_unsigned(unsigned indent, const std::vector<T>& arg)
|
||||
{
|
||||
std::ostringstream out;
|
||||
std::string indent_str(indent, ' ');
|
||||
|
||||
out << "std::vector<T>{ ";
|
||||
for (const auto& el : arg) {
|
||||
out << indent_str << static_cast<unsigned>(el) << "\n";
|
||||
}
|
||||
out << "}";
|
||||
return out.str();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
std::string format_vector_indent_braced(unsigned indent, const char* type,
|
||||
const std::vector<T>& arg)
|
||||
{
|
||||
if (arg.empty()) {
|
||||
return "{}";
|
||||
}
|
||||
std::string indent_str(indent, ' ');
|
||||
std::stringstream out;
|
||||
out << "std::vector<" << type << ">{\n";
|
||||
for (const auto& item : arg) {
|
||||
out << indent_str << format_indent_braced_list(indent, item) << '\n';
|
||||
}
|
||||
out << "}";
|
||||
return out.str();
|
||||
}
|
||||
|
||||
} // namespace genesys
|
||||
|
||||
#endif // BACKEND_GENESYS_UTILITIES_H
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#define SANE_TESTSUITE_BACKEND_GENESYS_TESTS_PRINTERS_H
|
||||
|
||||
#include "../../../backend/genesys/image_pixel.h"
|
||||
#include "../../../backend/genesys/utilities.h"
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <vector>
|
||||
|
@ -31,11 +32,7 @@
|
|||
template<class T>
|
||||
std::ostream& operator<<(std::ostream& str, const std::vector<T>& arg)
|
||||
{
|
||||
str << "{ ";
|
||||
for (const auto& el : arg) {
|
||||
str << static_cast<unsigned>(el) << ", ";
|
||||
}
|
||||
str << "}\n";
|
||||
str << genesys::format_vector_unsigned(4, arg) << '\n';
|
||||
return str;
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue