able to get test image :)

This commit is contained in:
gb 2024-01-11 15:23:05 +08:00
parent d02a40e6dd
commit d91363b1fe
9 changed files with 230 additions and 181 deletions

View File

@ -22,7 +22,12 @@ FpgaComm::controller::controller()
status_.reset(new Gpio(PORT_STATUS));
cfg_.reset(new Gpio(PORT_CONFIG));
reload_.reset(new Gpio(PORT_RELOAD));
reset_.reset(new Gpio(PORT_RESET));
reset_.reset(new GpioOut(PORT_RESET));
vdd_3voff_.reset(new GpioOut(PORT_VDD_3VOFF));
vdd_5ven_.reset(new GpioOut(PORT_VDD_5VEN));
init_done_.reset(new Gpio(PORT_INIT_DONE));
img_tx_.reset(new Gpio(PORT_IMAGE_TX));
}
FpgaComm::controller::~controller()
{}
@ -70,6 +75,7 @@ FpgaComm::FpgaComm(int bauds, bool query) : bauds_(bauds)
WR_Reg(AledR);
controller_->reset();
resetADC();
}
}

View File

@ -20,7 +20,7 @@ typedef struct Frame_FPGA
typedef struct Mode_FPGA
{
unsigned short int colorMode : 1;
unsigned short int dpi : 2;
unsigned short int dpi : 2;//0x01 200dpi 0x02 300dpi 0x03 600dpi
unsigned short int led : 1;
unsigned short sample : 9;
unsigned short int adcA : 1;
@ -51,14 +51,14 @@ typedef struct Ad_Gain
typedef struct CIS_AD_Gain
{
unsigned short int ad0_value : 8; //!< 数据位
unsigned short int ad0_reserved : 2; //!< 保留位
unsigned short int ad0_value : 8; //!< æ•°æ<EFBFBD>®ä½?
unsigned short int ad0_reserved : 2; //!< ä¿<EFBFBD>ç•™ä½?
unsigned short int ad0_addr : 5; //!< 寄存器地址
unsigned short int ad0_rw : 1; //!< 读写位 1:读, 0:写
unsigned short int ad1_value : 8; //!< 数据位
unsigned short int ad1_reserved : 2; //!< 保留位
unsigned short int ad0_rw : 1; //!< 读写� 1:读, 0:�
unsigned short int ad1_value : 8; //!< æ•°æ<EFBFBD>®ä½?
unsigned short int ad1_reserved : 2; //!< ä¿<EFBFBD>ç•™ä½?
unsigned short int ad1_addr : 5; //!< 寄存器地址
unsigned short int ad1_rw : 1; //!< 读写位 1:读, 0:写;
unsigned short int ad1_rw : 1; //!< 读写� 1:读, 0:�
} CisAdGain;
typedef struct CIS_LED_RF
@ -127,8 +127,10 @@ enum
};
enum
{
DPI_300 = 0,
DPI_200,
DPI_200 = 1,
DPI_300 = 2,
DPI_600 = 3,
};
class GpioOut;
@ -146,12 +148,20 @@ class FpgaComm : public IRegsAccess
PORT_STATUS = 69,
PORT_RELOAD = 70,
PORT_CONFIG = 71,
PORT_VDD_3VOFF = 96,
PORT_VDD_5VEN = 98,
PORT_INIT_DONE = 99,
PORT_IMAGE_TX = 101,
PORT_RESET = 232,
};
std::unique_ptr<Gpio> status_; // status reader - port 69
std::unique_ptr<Gpio> reload_; // codes reload - port 70
std::unique_ptr<Gpio> cfg_; // configuration reload - port 71
std::unique_ptr<Gpio> reset_; // circuit reset - port Fpga_Reset
std::unique_ptr<Gpio> vdd_3voff_;
std::unique_ptr<Gpio> vdd_5ven_;
std::unique_ptr<Gpio> init_done_;
std::unique_ptr<Gpio> img_tx_;
public:
controller();

View File

@ -141,7 +141,7 @@ void* GVideoISP1::read_frame(int timeout, size_t& size, int& ind) {
size = 0;
ind = -1;
if (!wait(timeout)){
utils::to_log(LOG_LEVEL_FATAL, "read frame time out!!!\n" );
utils::to_log(LOG_LEVEL_FATAL, "GVideoISP1::read_frame time out!!!\n" );
return 0;
}
struct v4l2_plane planes[VIDEO_MAX_PLANES];
@ -165,6 +165,7 @@ void* GVideoISP1::read_frame(int timeout, size_t& size, int& ind) {
// }
ind = buf.index;
size = buffers[ind].length;
utils::to_log(LOG_LEVEL_DEBUG, "\tvideo buf[%d] = %d\n", ind, size);
return buffers[ind].start;
}
@ -196,7 +197,7 @@ void GVideoISP1::start_capturing(void) {
if (ret < 0)
LOG_ERROR(utils::format_string("Unable to queue buffer: %s (%d).\n",strerror(errno), errno));
else
LOG_TRACE(utils::format_string("buf.index = %d VIDIOC_QBUF sucess.\n",i));
LOG_TRACE(utils::format_string("buf.index = %d, length = %d, VIDIOC_QBUF sucess.\n", i, buf_size_));
}
type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
@ -214,7 +215,7 @@ void GVideoISP1::stop_capturing(void) {
type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
if (-1 == ioctl(fd, VIDIOC_STREAMOFF, &type))
LOG_ERROR(utils::format_string("streamo off\n"));
LOG_ERROR(utils::format_string("stream off\n"));
LOG_TRACE(utils::format_string("gVideo stop_capturing\n"));
}

View File

@ -316,11 +316,18 @@ void scanner_hw::thread_image_capture(void)
utils::to_log(LOG_LEVEL_DEBUG, "scanning thread working ...\n");
memset(&img, 0, sizeof(img));
img.bpp = 8;
img.channels = 3;
img.resolution_x = 200;
img.resolution_y = 200;
img.width = 3888;
img.height = 16380;
motor_->clear_error();
camera_->start();
img_controller_->capture();
motor_->start();
mb_events_.take(mbev, true);
if(mb_events_.take(mbev, true))
utils::to_log(LOG_LEVEL_DEBUG, "take first motorboard event: %d - 0x%08x\n", mbev.first, mbev.second);
else
utils::to_log(LOG_LEVEL_FATAL, "Wait Lifter event before scanning failed.\n");
while(scanning_ && mbev.first == MOTOR_BORD_EVENT_LIFTER_READY) // auto scan cycle ...
{
motor_->pick_paper();
@ -330,7 +337,7 @@ void scanner_hw::thread_image_capture(void)
{
size_t size = 0;
int ind = -1;
void* frame = camera_->read_frame(10 * 1000, size, ind);
void* frame = camera_->read_frame(3 * 1000, size, ind);
dyn_mem_shared_ptr mem = nullptr;
if(!frame)
@ -465,6 +472,7 @@ int scanner_hw::set_value(const char* name, void* val)
int scanner_hw::open(std::function<IMAGE_HANDLER_PROTO> image_handler)
{
this->close();
int fh = 16380;
if(!image_handler)
return SCANNER_ERR_INVALID_PARAMETER;
@ -476,9 +484,9 @@ int scanner_hw::open(std::function<IMAGE_HANDLER_PROTO> image_handler)
img_controller_->setColorMode(mode_ == "\345\275\251\350\211\262" ? COLOR_MODE : GRAY_MODE);
img_controller_->setDpi(dpi_ == 200 ? DPI_200 : DPI_300);
img_controller_->setFrameHeight(frame_h_);
img_controller_->setDelayTime(delay_);
img_controller_->setSample(sample_);
// img_controller_->setSp(2520);
void(FpgaComm::* exposure[])(int) = {&FpgaComm::setAExposureB, &FpgaComm::setAExposureG
, &FpgaComm::setAExposureR, &FpgaComm::setBExposureB, &FpgaComm::setBExposureG, &FpgaComm::setBExposureR};
@ -498,9 +506,6 @@ int scanner_hw::open(std::function<IMAGE_HANDLER_PROTO> image_handler)
for(int i = 0; i < FpgaComm::CIS_SECTOR_COUNT; ++i)
img_controller_->setBOffset(i, off_[SIDE_BACK]);
camera_.reset(new GVideoISP1());
camera_->open(cis_length_, 1000);
auto cb = [this](int ev, unsigned int data) -> void
{
mb_events_.save(std::make_pair(ev, data), true);
@ -536,6 +541,31 @@ int scanner_hw::open(std::function<IMAGE_HANDLER_PROTO> image_handler)
else
utils::to_log(LOG_LEVEL_FATAL, "Get motor-board confige failed.\n");
camera_.reset(new GVideoISP1());
camera_->open(3888, fh);
std::this_thread::sleep_for(std::chrono::milliseconds(20));
img_controller_->setFrameHeight(frame_h_);
img_controller_->capture();
size_t size;
int _int;
auto data = camera_->read_frame(100,size,_int);
if(data)
camera_->add_v4l2_memory(_int);
std::this_thread::sleep_for(std::chrono::milliseconds(20));
img_controller_->setFrameHeight(fh / 2 * 3);
if(1)
{
// debug ...
unsigned int vals[] = {0x5ffa, 0x3300c9d, 0x1, 0xaa00aa, 0x340030aa, 0x1380193
, 0x1270131, 0x340030aa, 0x168000c, 0x168017b, 0, 0x0afa3f
, 0x3e8};
for(int i = 0; i < _countof(vals); ++i)
img_controller_->write(i, vals[i]);
img_controller_->update();
}
return SCANNER_ERR_OK;
}
int scanner_hw::start_scan(void)
@ -565,6 +595,7 @@ int scanner_hw::start_scan(void)
return DEV_ERR(NO_PAPER);
scanning_ = true;
mb_events_.clear();
scan_thread_.reset(new std::thread(&scanner_hw::thread_image_capture, this));
return SCANNER_ERR_OK;
@ -572,6 +603,7 @@ int scanner_hw::start_scan(void)
int scanner_hw::stop_scan(void)
{
scanning_ = auto_scan_ = false;
mb_events_.trigger();
if(motor_.get())
{
motor_->set_auto_paper(false, false);
@ -580,6 +612,7 @@ int scanner_hw::stop_scan(void)
if(camera_.get())
camera_->stop();
mb_events_.clear();
return 0;
}

View File

@ -23,6 +23,7 @@
class FpgaComm;
class GVideoISP1;
class gVideo;
class MotorBoard;
class scanner_hw : public sane_opt_provider
@ -31,7 +32,7 @@ class scanner_hw : public sane_opt_provider
volatile bool scanning_ = false;
int time_to_exit_auto_scan_ = 60; // seconds
std::unique_ptr<FpgaComm> img_controller_;
std::unique_ptr<GVideoISP1> camera_;
std::unique_ptr<gVideo> camera_;
std::unique_ptr<MotorBoard> motor_;
std::unique_ptr<std::thread> scan_thread_;
safe_fifo<std::pair<int, int>> mb_events_;
@ -53,7 +54,7 @@ class scanner_hw : public sane_opt_provider
std::string family_ = "G200";
volatile bool auto_scan_ = false;
int scan_count_ = -1;
int cis_length_ = 1632;
int cis_length_ = 3888;
int dpi_ = 300;
int baud_ = 921600;
int delay_ = 1000;
@ -115,7 +116,7 @@ public:
// "resolution": {
// "cat": "none",
// "group": "CIS",
// "title": "分辨率",
// "title": "分辨�,
// "desc": "设置镜头工作的分辨率",
// "type": "int",
// "fix-id": 34840,
@ -130,7 +131,7 @@ public:
// "cat": "base",
// "group": "feeder",
// "title": "待纸扫描",
// "desc": "启用后,文稿放入扫描仪时将自动启动扫描",
// "desc": "å<EFBFBD>¯ç”¨å<EFBFBD>Žï¼Œæ‡ç¨¿æ”¾å…¥æ‰«æ<EFBFBD><EFBFBD>仪时将自动å<EFBFBD>¯åŠ¨æ‰«æ<EFBFBD>?,
// "type": "bool",
// "fix-id": 34873,
// "ui-pos": 12,
@ -142,8 +143,8 @@ public:
// "wait-scan-exit": {
// "cat": "base",
// "group": "feeder",
// "title": "待纸扫描退出时间",
// "desc": "设置结束待纸扫描的时间",
// "title": "待纸扫æ<EFBFBD><EFBFBD>退出时é—?,
// "desc": "设置结æ<EFBFBD>Ÿå¾…纸扫æ<EFBFBD><EFBFBD>çš„æ—¶é—?,
// "type": "string",
// "fix-id": 34920,
// "ui-pos": 13,
@ -158,7 +159,7 @@ public:
// "cat": "base",
// "group": "feeder",
// "title": "扫描张数",
// "desc": "选择指定数量扫描或连续扫描",
// "desc": "选æ©æŒ‡å®šæ•°é‡<EFBFBD>扫æ<EFBFBD><EFBFBD>æˆè¿žç»­æ‰«æ<EFBFBD>?,
// "type": "string",
// "fix-id": 34862,
// "ui-pos": 15,
@ -187,7 +188,7 @@ public:
// "cat": "base",
// "group": "feeder",
// "title": "自动分纸强度",
// "desc": "扫描仪自动修正分纸力度",
// "desc": "扫æ<EFBFBD><EFBFBD>仪自动修正分纸åŠåº?,
// "type": "bool",
// "fix-id": 34876,
// "ui-pos": 27,
@ -199,7 +200,7 @@ public:
// "feed-strength-value": {
// "cat": "base",
// "group": "feeder",
// "title": " 进纸失败率",
// "title": " 进纸失败�,
// "desc": "高于该值时扫描仪将调整分纸力度",
// "type": "float",
// "fix-id": 34877,
@ -225,9 +226,9 @@ public:
// "ui-pos": 30,
// "auth": 0,
// "size": 12,
// "cur": "一般",
// "default": "一般",
// "range": ["弱", "一般", "强"],
// "cur": "一�,
// "default": "一�,
// "range": ["�, "一�, "�],
// "depend": "is-auto-strength!=true"
// },
// "time-to-sleep": {
@ -240,14 +241,14 @@ public:
// "ui-pos": 33,
// "auth": 0,
// "size": 16,
// "cur": "不休眠",
// "default": "不休眠",
// "range": ["不休眠", "五分钟", "十分钟", "半小时", "一小时", "两小时", "四小时"]
// "cur": "ä¸<EFBFBD>ä¼çœ?,
// "default": "ä¸<EFBFBD>ä¼çœ?,
// "range": ["ä¸<EFBFBD>ä¼çœ?, "五分é’?, "å<><C3A5>分é?, "å<>Šå°<C3A5>æ—?, "一å°<C3A5>æ—¶", "两å°<C3A5>æ—?, "åå°<C3A5>æ—?]
// },
// "baud": {
// "cat": "none",
// "group": "CIS",
// "title": "波特率",
// "title": "波特�,
// "desc": "CIS控制通信速率",
// "type": "int",
// "ui-pos": 20,
@ -261,7 +262,7 @@ public:
// "cat": "none",
// "group": "CIS",
// "title": "延迟响应",
// "desc": "采集头接受命令后的动作延迟时间",
// "desc": "采é†å¤´æŽ¥å<EFBFBD>—å½ä»¤å<EFBFBD>Žçš„动作延迟时é—?,
// "type": "int",
// "ui-pos": 21,
// "auth": 0,
@ -273,7 +274,7 @@ public:
// "frame-h": {
// "cat": "none",
// "group": "CIS",
// "title": "帧高度",
// "title": "帧高�,
// "desc": "采集头每一帧的采集高度",
// "type": "int",
// "ui-pos": 22,
@ -297,8 +298,8 @@ public:
// "expo-fb": {
// "cat": "none",
// "group": "CIS",
// "title": "曝光度(正面蓝色通道)",
// "desc": "正面蓝色通道的曝光强度",
// "title": "æ<EFBFBD>光度(正é<EFBFBD>¢è“<EFBFBD>色通é<EFBFBD>“ï¼?,
// "desc": "æ­£é<EFBFBD>¢è“<EFBFBD>色通é<EFBFBD>“çš„æ<EFBFBD>光强åº?,
// "type": "int",
// "ui-pos": 32,
// "auth": 0,
@ -314,8 +315,8 @@ public:
// "expo-fg": {
// "cat": "none",
// "group": "CIS",
// "title": "曝光度(正面绿色通道)",
// "desc": "正面绿色通道的曝光强度",
// "title": "æ<EFBFBD>光度(正é<EFBFBD>¢ç»¿è‰²é€šé<EFBFBD>“ï¼?,
// "desc": "æ­£é<EFBFBD>¢ç»¿è‰²é€šé<EFBFBD>“çš„æ<EFBFBD>光强åº?,
// "type": "int",
// "ui-pos": 31,
// "auth": 0,
@ -331,8 +332,8 @@ public:
// "expo-fr": {
// "cat": "none",
// "group": "CIS",
// "title": "曝光度(正面红色通道)",
// "desc": "正面红色通道的曝光强度",
// "title": "æ<EFBFBD>光度(正é<EFBFBD>¢çº¢è‰²é€šé<EFBFBD>“ï¼?,
// "desc": "æ­£é<EFBFBD>¢çº¢è‰²é€šé<EFBFBD>“çš„æ<EFBFBD>光强åº?,
// "type": "int",
// "ui-pos": 30,
// "auth": 0,
@ -348,8 +349,8 @@ public:
// "expo-bb": {
// "cat": "none",
// "group": "CIS",
// "title": "曝光度(背面蓝色通道)",
// "desc": "背面蓝色通道的曝光强度",
// "title": "æ<EFBFBD>光度(背é<EFBFBD>¢è“<EFBFBD>色通é<EFBFBD>“ï¼?,
// "desc": "背é<EFBFBD>¢è“<EFBFBD>色通é<EFBFBD>“çš„æ<EFBFBD>光强åº?,
// "type": "int",
// "ui-pos": 35,
// "auth": 0,
@ -365,8 +366,8 @@ public:
// "expo-bg": {
// "cat": "none",
// "group": "CIS",
// "title": "曝光度(背面绿色通道)",
// "desc": "背面绿色通道的曝光强度",
// "title": "æ<EFBFBD>光度(背é<EFBFBD>¢ç»¿è‰²é€šé<EFBFBD>“ï¼?,
// "desc": "背é<EFBFBD>¢ç»¿è‰²é€šé<EFBFBD>“çš„æ<EFBFBD>光强åº?,
// "type": "int",
// "ui-pos": 34,
// "auth": 0,
@ -382,8 +383,8 @@ public:
// "expo-br": {
// "cat": "none",
// "group": "CIS",
// "title": "曝光度(背面红色通道)",
// "desc": "背面红色通道的曝光强度",
// "title": "æ<EFBFBD>光度(背é<EFBFBD>¢çº¢è‰²é€šé<EFBFBD>“ï¼?,
// "desc": "背é<EFBFBD>¢çº¢è‰²é€šé<EFBFBD>“çš„æ<EFBFBD>光强åº?,
// "type": "int",
// "ui-pos": 33,
// "auth": 0,
@ -483,21 +484,21 @@ public:
// "double-chk": {
// "cat": "none",
// "group": "feeder",
// "title": "双张检测",
// "title": "å<EFBFBD>Œå¼ æ£€æµ?,
// "desc": "检测是否有两张或者多张纸同时搓进",
// "type": "string",
// "ui-pos": 18,
// "auth": 0,
// "size": 16,
// "cur": "超声波",
// "default": "超声波",
// "range": ["超声波", "禁用"]
// "cur": "超声�,
// "default": "超声�,
// "range": ["超声æ³?, "ç¦<C3A7>用"]
// },
// "is-staple": {
// "cat": "none",
// "group": "feeder",
// "title": "装订检测",
// "desc": "检测是否有订书钉存在",
// "title": "装订检�,
// "desc": "检æµæ˜¯å<EFBFBD>¦æœ‰è®¢ä¹¦é‰å­˜åœ?,
// "type": "bool",
// "fix-id": 34861,
// "ui-pos": 20,
@ -510,7 +511,7 @@ public:
// "cat": "none",
// "group": "feeder",
// "title": "走纸速度",
// "desc": "设置走纸电机的速度,张\/分PPM",
// "desc": "设置走纸电机的速度,张\/分(PPM�,
// "type": "int",
// "ui-pos": 25,
// "auth": 0,
@ -534,8 +535,8 @@ public:
// "is-check-askew": {
// "cat": "none",
// "group": "feeder",
// "title": "歪斜检测",
// "desc": "检测进纸是否歪斜",
// "title": "歪斜检�,
// "desc": "检æµè¿çº¸æ˜¯å<EFBFBD>¦æ­ªæ?,
// "type": "bool",
// "fix-id": 34868,
// "ui-pos": 22,
@ -547,7 +548,7 @@ public:
// "askew-range": {
// "cat": "none",
// "group": "feeder",
// "title": "歪斜容忍度",
// "title": "æ­ªæœå®¹å¿<EFBFBD>åº?,
// "desc": "值越小,能容忍得送入文稿歪斜角度越小",
// "type": "int",
// "fix-id": 34869,
@ -566,8 +567,8 @@ public:
// "cis-len": {
// "cat": "base",
// "group": "关于",
// "title": "镜头长",
// "desc": "图像采集镜头的长度单位为毫米mm",
// "title": "镜头�,
// "desc": "å¾åƒ<EFBFBD>采é†é•œå¤´çš„长度,å<EFBFBD>•ä½<EFBFBD>为毫米(mmï¼?,
// "type": "int",
// "ui-pos": 30,
// "auth": 0,
@ -596,8 +597,8 @@ public:
// "fpga-ver": {
// "cat": "none",
// "group": "关于",
// "title": "CIS控制器版本",
// "desc": "镜头参数控制驱动程序版本号",
// "title": "CIS控制器版�,
// "desc": "镜头å<EFBFBD>数控制驱动ç¨åº<EFBFBD>版本å<EFBFBD>?,
// "type": "string",
// "ui-pos": 17,
// "auth": 0,

View File

@ -81,25 +81,25 @@ bool MotorBoard::en_lifter()
{
unsigned int val;
SMBCONFIG *smbc = (SMBCONFIG *)(&val);
read(0x00, val);
read(MB_PORT_CONFIG, val);
smbc->lifter_en = 1;
write(0x00, val);
write(MB_PORT_CONFIG, val);
smbc->lifter_en = 0;
return write(0x00, val);
return write(MB_PORT_CONFIG, val);
}
void MotorBoard::pick_paper(void)
{
unsigned int val,pick_en;
SMBCONFIG *smbc = (SMBCONFIG *)(&val);
read(0x00, val);
read(MB_PORT_CONFIG, val);
smbc->pick_paper = 0;
write(0x00, val);
write(MB_PORT_CONFIG, val);
std::this_thread::sleep_for(std::chrono::microseconds(400));
smbc->pick_paper = 1;
write(0x00, val);
write(MB_PORT_CONFIG, val);
std::string v_str = std::to_string(m_version);
if(v_str.size()<8)
// if(v_str.size()<8)
return;
uint32_t date = atoi(v_str.substr(2,6).c_str());
#ifdef G100
@ -114,13 +114,13 @@ void MotorBoard::pick_paper(void)
if(!(pick_en&0xffff))
{
smbc->pick_paper = 0;
write(0x00, val);
write(MB_PORT_CONFIG, val);
std::this_thread::sleep_for(std::chrono::microseconds(400));
smbc->pick_paper = 1;
write(0x00, val);
write(MB_PORT_CONFIG, val);
}
// smbc->pick_paper = 0;
// write(0x00, val);
// write(MB_PORT_CONFIG, val);
}
void MotorBoard::clean_paper_road(){
@ -191,11 +191,11 @@ bool MotorBoard::wait_done(int timeout_ms)
int MotorBoard::os_mode()
{
// unsigned int val;
// read(0x02, val);
// read(MB_PORT_MODE, val);
// SMB_MODE *smb_mode = (SMB_MODE *)&val;
// return smb_mode->scan_mode;
unsigned int val;
read(0x06,val);
read(MB_PORT_FUNCTION,val);
SMB_FUNC smb_func = *(SMB_FUNC*)&val;
return smb_func.param.work_mode == 1;
}
@ -203,7 +203,7 @@ int MotorBoard::os_mode()
bool MotorBoard::paper_ready()
{
unsigned int val;
read(0x02, val);
read(MB_PORT_MODE, val);
SMB_MODE *smb_mode = (SMB_MODE *)&val;
return smb_mode->feeding_paper_ready;
}
@ -211,7 +211,7 @@ bool MotorBoard::paper_ready()
bool MotorBoard::is_scanning()
{
unsigned int val;
read(0x02, val);
read(MB_PORT_MODE, val);
SMB_MODE *smb_mode = (SMB_MODE *)&val;
return smb_mode->work_status;
}
@ -219,7 +219,7 @@ bool MotorBoard::is_scanning()
int MotorBoard::paper_counter()
{
unsigned int val;
read(0x02, val);
read(MB_PORT_MODE, val);
SMBMODE *smb_mode = (SMBMODE *)&val;
return smb_mode->scan_num;
}
@ -227,11 +227,11 @@ int MotorBoard::paper_counter()
bool MotorBoard::set_paper_inspect_param(unsigned int value /* = 1000 */)
{
unsigned int val;
if (!read(0x04, val))
if (!read(MB_PORT_CONFIG_EX, val))
return false;
SMBCONFIGEXT *smb_config_ext = (SMBCONFIGEXT *)&val;
smb_config_ext->error_range_set = value;
return write(0x04, val);
return write(MB_PORT_CONFIG_EX, val);
}
bool MotorBoard::get_keeplastpaper(){
@ -241,32 +241,32 @@ bool MotorBoard::get_keeplastpaper(){
bool MotorBoard::set_paper_inpect_info(unsigned int value)
{
unsigned int val;
if (!read(0x04, val))
if (!read(MB_PORT_CONFIG_EX, val))
return false;
SMBCONFIGEXT *smb_config_ext = (SMBCONFIGEXT *)&val;
smb_config_ext->paper_infor = value;
return write(0x04, val);
return write(MB_PORT_CONFIG_EX, val);
}
bool MotorBoard::set_paper_inspect(bool enable /* = true */)
{
unsigned int val;
if (!read(0x04, val))
if (!read(MB_PORT_CONFIG_EX, val))
return false;
SMBCONFIGEXT *smb_config_ext = (SMBCONFIGEXT *)&val;
smb_config_ext->paper_size_check_en = enable;
return write(0x04, val);
return write(MB_PORT_CONFIG_EX, val);
}
bool MotorBoard::set_double_inpect(bool enable)
{
unsigned int val;
if (!read(0x00, val))
if (!read(MB_PORT_CONFIG, val))
return false;
// enable?m_statecontrol->lcdcontrol(4):m_statecontrol->lcdcontrol(5);
SMBCONFIG *smb_config = (SMBCONFIG *)&val;
smb_config->double_paper = enable;
return write(0x00, val);
return write(MB_PORT_CONFIG, val);
}
bool MotorBoard::get_doublle_inpect()
{
@ -275,16 +275,16 @@ bool MotorBoard::get_doublle_inpect()
bool MotorBoard::set_double_out_en(bool enable)
{
unsigned int val;
if (!read(0x00, val))
if (!read(MB_PORT_CONFIG, val))
return false;
SMBCONFIG *smb_config = (SMBCONFIG *)&val;
smb_config->double_out_en = enable;
return write(0x00, val);
return write(MB_PORT_CONFIG, val);
}
bool MotorBoard::get_double_out_en()
{
unsigned int val;
if (!read(0x00, val))
if (!read(MB_PORT_CONFIG, val))
return false;
SMBCONFIG *smb_config = (SMBCONFIG *)&val;
return smb_config->double_out_en;
@ -292,11 +292,11 @@ bool MotorBoard::get_double_out_en()
bool MotorBoard::set_staple_inpect(bool enable)
{
unsigned int val;
if (!read(0x00, val))
if (!read(MB_PORT_CONFIG, val))
return false;
SMBCONFIG *smb_config = (SMBCONFIG *)&val;
smb_config->staple_enable = enable;
return write(0x00, val);
return write(MB_PORT_CONFIG, val);
}
bool MotorBoard::get_staple_inpect()
{
@ -310,35 +310,35 @@ bool MotorBoard::set_cuospeed(int value)
return false;
SMBCONFIGEXT *smb_config = (SMBCONFIGEXT *)&val;
smb_config->cuo_speed = value;
return write(0x04, val);
return write(MB_PORT_CONFIG_EX, val);
}
// bool MotorBoard::set_en600DPI(bool en)
// {
// unsigned int val;
// if (!read(0x00, val))
// if (!read(MB_PORT_CONFIG, val))
// return false;
// SMBCONFIG *smb_config = (SMBCONFIG *)&val;
// smb_config->dpi600 = en?1:0;
// return write(0x00, val);
// return write(MB_PORT_CONFIG, val);
// }
bool MotorBoard::set_color_mode(int mode)
{
unsigned int val;
if (!read(0x00, val))
if (!read(MB_PORT_CONFIG, val))
return false;
SMBCONFIG *smb_config = (SMBCONFIG *)&val;
smb_config->color_mode = mode;
return write(0x00, val);
return write(MB_PORT_CONFIG, val);
}
bool MotorBoard::set_slowmoire(bool en){
unsigned int val;
if (!read(0x00, val))
if (!read(MB_PORT_CONFIG, val))
return false;
SMBCONFIG *smb_config = (SMBCONFIG *)&val;
smb_config->slow_moire = en;
return write(0x00, val);
return write(MB_PORT_CONFIG, val);
}
@ -350,35 +350,35 @@ int MotorBoard::get_color_mode()
bool MotorBoard::set_speed_mode(int mode)
{
unsigned int val;
if (!read(0x00, val))
if (!read(MB_PORT_CONFIG, val))
return false;
SMBCONFIG *smb_config = (SMBCONFIG *)&val;
smb_config->speed_set_enable = 1;
smb_config->v_setting = mode;
write(0x00, val);
write(MB_PORT_CONFIG, val);
smb_config->speed_set_enable = 0;
return write(0x00, val);
return write(MB_PORT_CONFIG, val);
}
bool MotorBoard::set_speed_mode_v_temp(int mode)
{
unsigned int val;
if (!read(0x00, val))
if (!read(MB_PORT_CONFIG, val))
return false;
printf(" set v_tmp = %d \n",mode);
SMBCONFIG *smb_config = (SMBCONFIG *)&val;
smb_config->speed_set_enable = 1;
smb_config->v_temp = mode;
write(0x00, val);
write(MB_PORT_CONFIG, val);
smb_config->speed_set_enable = 0;
return write(0x00, val);
return write(MB_PORT_CONFIG, val);
}
int MotorBoard::get_speed_mode()
{
unsigned int val;
if (!read(0x00, val))
if (!read(MB_PORT_CONFIG, val))
return -1;
SMBCONFIG *smb_config = (SMBCONFIG *)&val;
return smb_config->v_setting;
@ -411,8 +411,6 @@ void MotorBoard::pin_call(unsigned int pinNum)
SMBSTATUS *s = (SMBSTATUS *)&val;
if (!read(MB_PORT_STATUS, val))
utils::to_log(LOG_LEVEL_FATAL, "read motorboard status failed.\n");
else
utils::to_log(LOG_LEVEL_DEBUG, "motorboard status = 0x%08x\n", val);
if(s->keep_last_paper) // (val & 0x800)
{
//printf("\n keep_last_paper ");
@ -467,7 +465,7 @@ void MotorBoard::pin_call(unsigned int pinNum)
{
cv_paper_in.notify_all();
unsigned int papercount = 0;
read(0x02,papercount);
read(MB_PORT_MODE,papercount);
SMBMODE smbmode = *(SMBMODE*)&papercount;
printf("paper in arm count = %d ,motorcount = %d\n",++countindex,smbmode.scan_num);
startcapimage(true);
@ -505,26 +503,26 @@ bool MotorBoard::read(unsigned int addr, unsigned int &val)
bool MotorBoard::set_time_error(int value){
unsigned int val;
if (!read(0x05, val))
if (!read(MB_PORT_TIME, val))
return false;
SMBCONFIGTIME *smb_config = (SMBCONFIGTIME *)&val;
smb_config->error_time_set = value;
return write(0x05, val);
return write(MB_PORT_TIME, val);
}
bool MotorBoard::set_screw_inpect(bool enable)
{
unsigned int val;
if (!read(0x00, val))
if (!read(MB_PORT_CONFIG, val))
return false;
SMBCONFIG *smb_config = (SMBCONFIG *)&val;
smb_config->skew_enable = enable;
return write(0x00, val);
return write(MB_PORT_CONFIG, val);
}
bool MotorBoard::get_screw_inpect()
{
unsigned int val;
read(0x00, val);
read(MB_PORT_CONFIG, val);
SMBCONFIG *smb_mode = (SMBCONFIG *)&val;
return smb_mode->skew_enable;
}
@ -532,37 +530,37 @@ bool MotorBoard::get_screw_inpect()
bool MotorBoard::set_screw_level(int level)
{
unsigned int val;
if (!read(0x00, val))
if (!read(MB_PORT_CONFIG, val))
return false;
SMBCONFIG *smb_config = (SMBCONFIG *)&val;
smb_config->skew_parameter = level;
return write(0x00, val);
return write(MB_PORT_CONFIG, val);
}
bool MotorBoard::set_auto_paper(bool enable,bool enkey){
unsigned int val;
if (!read(0x00, val))
if (!read(MB_PORT_CONFIG, val))
return false;
// m_statecontrol?m_statecontrol->setautopaperflag(enable,enkey):void(0);
SMBCONFIG *smb_config = (SMBCONFIG *)&val;
smb_config->autofeed_mode = enable;
return write(0x00, val);
return write(MB_PORT_CONFIG, val);
}
bool MotorBoard::set_long_paper(bool enable)
{
unsigned int val;
if (!read(0x00, val))
if (!read(MB_PORT_CONFIG, val))
return false;
SMBCONFIG *smb_config = (SMBCONFIG *)&val;
smb_config->paper = enable;
return write(0x00, val);
return write(MB_PORT_CONFIG, val);
}
int MotorBoard::get_screw_level()
{
unsigned int val;
auto ret= read(0x00, val);
auto ret= read(MB_PORT_CONFIG, val);
if(!ret)
return -1;
SMBCONFIG *smb_mode = (SMBCONFIG *)&val;
@ -573,23 +571,23 @@ void MotorBoard::start_countmode()
{
unsigned int regval=0;
read(0x06,regval);
read(MB_PORT_FUNCTION,regval);
utils::to_log(LOG_LEVEL_DEBUG, "func6 regval = 0x%08x\n", regval);
SMBFUNC func = *(SMBFUNC*)&regval;
func.param.work_mode =1;
func.param.func_feed_mid = 1;
func.param.func_clear_count = 1;
utils::to_log(LOG_LEVEL_DEBUG, "func6 value = 0x%08x\n", func.value);
write(0x06,func.value);
write(MB_PORT_FUNCTION,func.value);
func.param.func_encount = 1;
func.param.key_sound = 1;
func.param.func_clear_count = 0;
utils::to_log(LOG_LEVEL_DEBUG, "func6 value = 0x%08x\n", func.value);
write(0x06,func.value);
write(MB_PORT_FUNCTION,func.value);
func.param.func_encount = 0;
func.param.key_sound = 0;
utils::to_log(LOG_LEVEL_DEBUG, "func6 value = 0x%08x\n",func.value);
write(0x06,func.value);
write(MB_PORT_FUNCTION,func.value);
}
@ -602,28 +600,28 @@ void MotorBoard::PutMsg(int type, int value, int clearscreen)
void MotorBoard::errormsg(uint value)
{
// if(value & 0x4)
// PutMsg((int)DisType::Dis_Err_CoverOpen,0,(int)ClearScreen::All);
// else if (value & 0x2)
// PutMsg((int)DisType::Dis_Err_NoPaper,0,(int)ClearScreen::All);
// else if (value & 0x8)
// PutMsg((int)DisType::Dis_Err_FeedError,0,(int)ClearScreen::All);
// // else if (value & 0x10)
// // PutMsg((int)DisType::Dis_Err_JamIn,0,(int)ClearScreen::All);
// else if (value & 0x20)
// PutMsg((int)DisType::Dis_Err_DoubleFeed,0,(int)ClearScreen::All);
// else if (value & 0x40)
// PutMsg((int)DisType::Dis_Err_Stable,0,(int)ClearScreen::All);
// else if (value & 0x80)
// PutMsg((int)DisType::Dis_Err_PaperScrew,0,(int)ClearScreen::All);
// else if (value & 0x00010000)
// PutMsg((int)DisType::Dis_Err_AqrImgTimeout,0,(int)ClearScreen::All);
// else if((value & 0x1000010) == 0x1000010)
// PutMsg((int)DisType::Dis_Err_JamIn,3,(int)ClearScreen::All);
// else if((value & 0x800010) == 0x800010)
// PutMsg((int)DisType::Dis_Err_JamIn,2,(int)ClearScreen::All);
// else if((value & 0x400010) == 0x400010)
// PutMsg((int)DisType::Dis_Err_JamIn,1,(int)ClearScreen::All);
if(value & 0x4)
PutMsg((int)DisType::Dis_Err_CoverOpen,0,(int)ClearScreen::All);
else if (value & 0x2)
PutMsg((int)DisType::Dis_Err_NoPaper,0,(int)ClearScreen::All);
else if (value & 0x8)
PutMsg((int)DisType::Dis_Err_FeedError,0,(int)ClearScreen::All);
// else if (value & 0x10)
// PutMsg((int)DisType::Dis_Err_JamIn,0,(int)ClearScreen::All);
else if (value & 0x20)
PutMsg((int)DisType::Dis_Err_DoubleFeed,0,(int)ClearScreen::All);
else if (value & 0x40)
PutMsg((int)DisType::Dis_Err_Stable,0,(int)ClearScreen::All);
else if (value & 0x80)
PutMsg((int)DisType::Dis_Err_PaperScrew,0,(int)ClearScreen::All);
else if (value & 0x00010000)
PutMsg((int)DisType::Dis_Err_AqrImgTimeout,0,(int)ClearScreen::All);
else if((value & 0x1000010) == 0x1000010)
PutMsg((int)DisType::Dis_Err_JamIn,3,(int)ClearScreen::All);
else if((value & 0x800010) == 0x800010)
PutMsg((int)DisType::Dis_Err_JamIn,2,(int)ClearScreen::All);
else if((value & 0x400010) == 0x400010)
PutMsg((int)DisType::Dis_Err_JamIn,1,(int)ClearScreen::All);
}
void MotorBoard::SetKeyState(bool value)
@ -635,11 +633,11 @@ void MotorBoard::SetKeyState(bool value)
void MotorBoard::set_keystopenable(bool value){
unsigned int regval=0;
read(0x06,regval);
read(MB_PORT_FUNCTION,regval);
utils::to_log(LOG_LEVEL_DEBUG, "func6 regval = 0x%08x\n", regval);
SMBFUNC func = *(SMBFUNC*)&regval;
func.param.key_stop_enable = value;
write(0x06, regval);
write(MB_PORT_FUNCTION, regval);
}
@ -663,14 +661,14 @@ void MotorBoard::set_freq(int motor_choose,int speedmode,int colormode,int dpi)
// {
// int x = 0; // (dpi == 1?(Get_static_jsonconfig().getscannerinfo().chu_motor_speed_200):(dpi == 2?Get_static_jsonconfig().getscannerinfo().chu_motor_speed_300 : Get_static_jsonconfig().getscannerinfo().chu_motor_speed_600));
// unsigned int regval=0;
// read(0x06,regval);
// read(MB_PORT_FUNCTION,regval);
// SMBFUNC func = *(SMBFUNC*)&regval;
// func.param.motor_choose = motor_choose;
// func.param.wr_en = 1;
// write(0x06,func.value);
// write(0x04,x);
// write(MB_PORT_FUNCTION,func.value);
// write(MB_PORT_CONFIG_EX,x);
// //func.param.wr_en = 0;
// //write(0x06,func.value);
// //write(MB_PORT_FUNCTION,func.value);
// return ;
// }
// if(motor_choose == 1)
@ -680,7 +678,7 @@ void MotorBoard::set_freq(int motor_choose,int speedmode,int colormode,int dpi)
// if(motor_choose == 3)
// table = frep_cfg(param.finalPeriod,param.Fmin,param.stepnum,param.a,param.offset,param.finalDelay,param.acceleration_time);
// unsigned int regval=0;
// read(0x06,regval);
// read(MB_PORT_FUNCTION,regval);
// SMBFUNC func = *(SMBFUNC*)&regval;
// int start_addr_cuo = 0;
// #ifdef G200
@ -695,12 +693,12 @@ void MotorBoard::set_freq(int motor_choose,int speedmode,int colormode,int dpi)
// func.param.motor_choose = motor_choose;
// func.param.wr_en = 1;
// func.param.motor_addr =i;
// write(0x06,func.value);
// write(0x04,i<start_addr_cuo?0:table[i-start_addr_cuo]);
// write(MB_PORT_FUNCTION,func.value);
// write(MB_PORT_CONFIG_EX,i<start_addr_cuo?0:table[i-start_addr_cuo]);
// //printf("\nfreq= %x addr =%d ",table[i-start_addr_cuo],i);
// }
// func.param.wr_en = 0;
// write(0x06,func.value);
// write(MB_PORT_FUNCTION,func.value);
}
void MotorBoard::init_statecontrol()
@ -743,13 +741,13 @@ void MotorBoard::startcapimage(bool value)
{
// if(m_config.g200params.is_fixedpaper)
// return;
// FILE *fp = fopen("/sys/class/tty/ttyUSB0/device/huagao_scanner", "w");
// if (fp == NULL)
// perror("startcapimage open filed");
// else{
// fprintf(fp, "%d", value ? 1 : 0);
// fclose(fp);
// }
FILE *fp = fopen("/sys/class/tty/ttyUSB0/device/huagao_scanner", "w");
if (fp == NULL)
perror("startcapimage open filed");
else{
fprintf(fp, "%d", value ? 1 : 0);
fclose(fp);
}
}
bool MotorBoard::set_sensor_pwm_duty(int sensorid,int duty)
@ -757,7 +755,7 @@ bool MotorBoard::set_sensor_pwm_duty(int sensorid,int duty)
//1扫描2开盖3歪斜—14歪斜-25出纸口6有无纸
printf("set_sensor_pwm_duty type = %d duty = %d \n",sensorid,duty);
unsigned int val;
if (!read(0x05, val))
if (!read(MB_PORT_TIME, val))
return false;
if(sensorid< 1 || sensorid >6)
return false;
@ -766,15 +764,15 @@ bool MotorBoard::set_sensor_pwm_duty(int sensorid,int duty)
SMBCONFIGTIME *smb_config_time = (SMBCONFIGTIME *)&val;
smb_config_time->sen_duty_set_sel = sensorid;
smb_config_time->duty_set = duty*8+50;
write(0x05, val);
write(MB_PORT_TIME, val);
smb_config_time->sen_duty_set_sel = 0;
return write(0x05, val);
return write(MB_PORT_TIME, val);
}
bool MotorBoard::enable_sensor_pwm(int sensorid,bool en)
{
std::uint32_t val;
if (!read(0x05, val))
if (!read(MB_PORT_TIME, val))
return false;
if(sensorid< 1 || sensorid >6)
return false;
@ -782,13 +780,13 @@ bool MotorBoard::enable_sensor_pwm(int sensorid,bool en)
bit.set(sensorid+6,en);
val = bit.to_ulong();
printf("enable_sensor_pwm = %d \n",val);
return write(0x05, val);
return write(MB_PORT_TIME, val);
}
bool MotorBoard::set_ultrasonic_param(int type,int value){
//1双张检测周期2有无纸检测周期3双张阈值4单张阈值
unsigned int val;
if (!read(0x07, val))
if (!read(MB_PORT_ULTROSONIC, val))
return false;
if(type< 1 || type >4)
return false;
@ -813,9 +811,9 @@ bool MotorBoard::set_ultrasonic_param(int type,int value){
}
printf("val = %d \n",val);
tmp->param.send_cyc_en = 1;
write(0x07,val);
write(MB_PORT_ULTROSONIC,val);
tmp->param.send_cyc_en = 0;
return write(0x07,val);
return write(MB_PORT_ULTROSONIC,val);
}
void MotorBoard::init_sensor_duty()
@ -837,13 +835,13 @@ void MotorBoard::init_sensor_duty()
std::uint32_t MotorBoard::get_ultrasonic_version(){
unsigned int val;
if (!read(0x07, val))
if (!read(MB_PORT_ULTROSONIC, val))
return 0;
SMB_Ultrasonic_Config *tmp = (SMB_Ultrasonic_Config *)&val;
tmp->param.rd_ver_en = 1;
write(0x07,val);
write(MB_PORT_ULTROSONIC,val);
tmp->param.rd_ver_en = 0;
write(0x07,val);
write(MB_PORT_ULTROSONIC,val);
std::this_thread::sleep_for(std::chrono::milliseconds(10));
read(0x08,val);
return val;
@ -851,7 +849,7 @@ std::uint32_t MotorBoard::get_ultrasonic_version(){
std::string MotorBoard::getmbversion(){
uint32_t value = 0;
read(0x03, value);
read(MB_PORT_VERSION, value);
m_version = value;
printf("mb version: = %s \n", std::to_string(value).c_str());
return std::to_string(value);

View File

@ -71,9 +71,9 @@ void PinMonitor::monitor()
//LOG_TRACE("poll call");
if (call_back)
{
sw.reset();
// sw.reset();
call_back(pin.getPort());
utils::to_log(LOG_LEVEL_DEBUG, utils::format_string("poll call times = %.2f \n",sw.elapse_ms()).c_str());
// utils::to_log(LOG_LEVEL_DEBUG, utils::format_string("= %.2f \n",sw.elapse_ms()).c_str());
}

View File

@ -457,7 +457,7 @@ dyn_mem_ptr async_scanner::handle_scan_start(LPPACK_BASE pack, uint32_t* used, p
FILE* dst = fopen(("/tmp/scan_" + std::to_string(lpinfo->pos.paper_ind) + ".bmp").c_str(), "wb");
if(dst)
{
std::string bih(utils::bitmap_info_header(lpinfo->width, lpinfo->height, lpinfo->bpp, lpinfo->resolution_x, lpinfo->resolution_y)),
std::string bih(utils::bitmap_info_header(lpinfo->width, lpinfo->height, lpinfo->bpp * lpinfo->channels, lpinfo->resolution_x, lpinfo->resolution_y)),
bfh(utils::bitmap_file_header((BITMAPINFOHEADER*)&bih[0]));
fwrite(bfh.c_str(), 1, bfh.length(), dst);
fwrite(bih.c_str(), 1, bih.length(), dst);

View File

@ -60,7 +60,7 @@ add_packagedirs("sdk")
add_defines("BUILD_AS_DEVICE")
add_defines("VER_MAIN=2")
add_defines("VER_FAMILY=300")
add_defines("VER_DATE=20240109")
add_defines("VER_DATE=20240111")
add_defines("VER_BUILD=14")
target("conf")