调整按键流程 升级更新流程

This commit is contained in:
modehua 2023-11-03 18:38:17 -07:00
parent f7b0f58022
commit db83aee8bc
11 changed files with 112 additions and 55 deletions

View File

@ -77,7 +77,7 @@ union CamZ_Reg_A_New
unsigned int psen: 1; //使能相移 写低写高 unsigned int psen: 1; //使能相移 写低写高
unsigned int psincdec : 1; //相移动反向 unsigned int psincdec : 1; //相移动反向
unsigned int clr_psedon : 1;//清除相完成 写低写高 unsigned int clr_psedon : 1;//清除相完成 写低写高
unsigned int dpi: 1;//bit 12 //1: 300DPI 0: 600DPI unsigned int dpi: 2;//bit 12 //1: 300DPI 0: 600DPI
unsigned int dpi_200: 1; //dpi=1的时候 dpi_200=1 200dpi dpi=1的时候 dpi_200=0 300dpi dpi=0的时候 dpi_200=0 600dpi unsigned int dpi_200: 1; //dpi=1的时候 dpi_200=1 200dpi dpi=1的时候 dpi_200=0 300dpi dpi=0的时候 dpi_200=0 600dpi
}; };
}; };

View File

@ -71,10 +71,8 @@ void CuoZhiMotor::reset()
mspCuozhiBackward.offset, mspCuozhiBackward.finalDelay); mspCuozhiBackward.offset, mspCuozhiBackward.finalDelay);
setDirection(0); setDirection(0);
Motor::start(delays_backward, mspCuozhiBackward); Motor::start(delays_backward, mspCuozhiBackward);
if(smbtype==SMBType::MB_DRV_8825)
std::this_thread::sleep_for(std::chrono::milliseconds(30)); std::this_thread::sleep_for(std::chrono::milliseconds(150));
else
std::this_thread::sleep_for(std::chrono::milliseconds(150));
stop(); stop();
speedRecover(); speedRecover();

View File

@ -114,7 +114,7 @@ HCamDevice::HCamDevice()
HtCamSetdivder(true); HtCamSetdivder(true);
HtCamSetPeriod(0.2); HtCamSetPeriod(20);
HtCamWriteFpgaRegs(17, 0x04ce99ff); //扫描传感器阈值 HtCamWriteFpgaRegs(17, 0x04ce99ff); //扫描传感器阈值
@ -294,6 +294,7 @@ void HCamDevice::HtCamSetdivder(bool is_enble)
// scan.bit.scan_pwm_enble_o = 1; // scan.bit.scan_pwm_enble_o = 1;
// scan.bit.scan_pwm_input_clear = 0; // scan.bit.scan_pwm_input_clear = 0;
// scan.bit.scan_pwm_reset =0; // scan.bit.scan_pwm_reset =0;
printf("rgb.NShort[0]:%d\r\n",rgb.NShort[0]);
uint32_t r = 0x0001001e; uint32_t r = 0x0001001e;
if (!is_enble) if (!is_enble)
r=0x0001001F; r=0x0001001F;
@ -304,9 +305,9 @@ void HCamDevice::HtCamSetdivder(bool is_enble)
} }
void HCamDevice::HtCamSetPeriod(double reg_value) void HCamDevice::HtCamSetPeriod(double reg_value)
{ {
reg_value /= 10; reg_value /= 100;
printf("reg_value:%f\r\n",reg_value); printf("reg_value:%f\r\n",reg_value);
double pr = reg_value == 0 || reg_value > 10 ? 0x183C/2 :reg_value * 0x183C / 1; double pr = reg_value == 0 ? 0x183C/2 :reg_value * 0x183C / 1;
printf("\r\n"); printf("\r\n");

View File

@ -137,7 +137,7 @@ namespace huagao
if (n == sizeof(input_event)) if (n == sizeof(input_event))
{ {
memcpy((void *)(&input_ev), buffer, sizeof(input_event)); memcpy((void *)(&input_ev), buffer, sizeof(input_event));
if (input_ev.type == 0) // 非按键不响应 if (input_ev.type != 1) // 非按键不响应
{ {
n = 0; n = 0;
continue; continue;

View File

@ -37,9 +37,11 @@ MultiFrameCapture::MultiFrameCapture(ScannerGlue glue) :
paper_size_((unsigned int)PaperSize::G400_AUTO), paper_size_((unsigned int)PaperSize::G400_AUTO),
color_mode_(GRAY), color_mode_(GRAY),
is_correct_(0), is_correct_(0),
is_double_paper_(0) is_double_paper_(0),
is_remove_morr_(0)
{ {
video.reset(new HCamDevice); video.reset(new HCamDevice);
video->HtCamSetdivder(true);
m_snap_thread.reset(new std::thread(&MultiFrameCapture::snaprun, this)); m_snap_thread.reset(new std::thread(&MultiFrameCapture::snaprun, this));
m_imgproc_thread.reset(new std::thread(&MultiFrameCapture::procimage, this)); m_imgproc_thread.reset(new std::thread(&MultiFrameCapture::procimage, this));
@ -69,6 +71,7 @@ MultiFrameCapture::~MultiFrameCapture()
void MultiFrameCapture::SetParent(void *scanner) void MultiFrameCapture::SetParent(void *scanner)
{ {
video->HtCamSetdivder(true);
} }
void MultiFrameCapture::open() void MultiFrameCapture::open()
@ -187,11 +190,12 @@ void MultiFrameCapture::UpdateScanParam(HG_ScanConfiguration config)
is_correct_ = config.params.isCorrect; is_correct_ = config.params.isCorrect;
paper_size_ = config.params.pageSize; paper_size_ = config.params.pageSize;
is_double_paper_ = config.params.doubleFeeded; is_double_paper_ = config.params.doubleFeeded;
is_remove_morr_ = config.params.slow_moire;
//width_ = paper_size_ == PaperSize::G400_MAXSIZE || paper_size_ ==PaperSize::G400_MAXAUTO && //width_ = paper_size_ == PaperSize::G400_MAXSIZE || paper_size_ ==PaperSize::G400_MAXAUTO &&
printf("config.params.dc%d\r\n",config.params.dc); printf("config.params.dc%d\r\n",config.params.dc);
video->HtCamSetPeriod(config.params.dc < 0 || config.params.dc > 10 ? 5 : config.params.dc); video->HtCamSetPeriod(config.params.dc);
//int height = resolution_ == DPI_600 ? 342 : 900; //int height = resolution_ == DPI_600 ? 342 : 900;
int height = config.params.dpi == 3 ? 900 :(config.params.dpi == 2?999:300); int height = config.params.dpi == 3 ? 900 :(config.params.dpi == 2?999:300);
@ -229,11 +233,12 @@ void MultiFrameCapture::UpdateScanParam(HG_ScanConfiguration config)
printf("彩色sp = %d\r\n",sp * 3); printf("彩色sp = %d\r\n",sp * 3);
} }
if (paper_size_ == (unsigned int)PaperSize::G400_MAXSIZE && !config.params.slow_moire) //长文稿模式选择使用 600 dpi走纸速度 //长文稿模式选择使用 600 dpi走纸速度
if (paper_size_ == (unsigned int)PaperSize::G400_MAXSIZE && !config.params.slow_moire)
{ {
int sp = 0; int sp = 0;
if (color_mode_ == GRAY) if (color_mode_ == GRAY)
sp = resolution_ == 1 ? 22950 : 9000; //长文稿模式 这几组数据是在600dpi的走纸速度调测的 sptime sp = resolution_ == 1 ? 22950 : 15450; //长文稿模式 这几组数据是在600dpi的走纸速度调测的 sptime
else else
sp = resolution_ == 1 ? 7800 : 5210; sp = resolution_ == 1 ? 7800 : 5210;
@ -450,6 +455,13 @@ void MultiFrameCapture::snaprun()
int color_mode = video->HtCamGetColorMode(); int color_mode = video->HtCamGetColorMode();
int func_sig = 0; int func_sig = 0;
int time_out = resolution_ == DPI_600 ? 2000 : 600; ///这个时间是根据每帧的数据量来进行调测的 int time_out = resolution_ == DPI_600 ? 2000 : 600; ///这个时间是根据每帧的数据量来进行调测的
if (is_remove_morr_)
{
time_out = 2000;
}
int time_out_cnt = 0; int time_out_cnt = 0;
if (color_mode_) if (color_mode_)

View File

@ -89,6 +89,7 @@ private:
unsigned int color_mode_; // 颜色模式 unsigned int color_mode_; // 颜色模式
unsigned int is_correct_; // 是否校正 unsigned int is_correct_; // 是否校正
unsigned int is_double_paper_; // 是否启动双张检测 unsigned int is_double_paper_; // 是否启动双张检测
unsigned int is_remove_morr_; // 去除摩尔纹
cv::Mat lut; cv::Mat lut;

View File

@ -29,6 +29,7 @@ Scanner::Scanner(ScannerGlue glue)
capturer.reset(new MultiFrameCapture(m_glue)); capturer.reset(new MultiFrameCapture(m_glue));
capturer->SetParent(this); capturer->SetParent(this);
this_thread::sleep_for(std::chrono::milliseconds(50));
//固件版本 //固件版本
int version=7010; int version=7010;
@ -289,7 +290,7 @@ void Scanner::runScan()
m_jamPaper = true; m_jamPaper = true;
put(S_EVT_JAM_OUT); put(S_EVT_JAM_OUT);
m_scaninfo.JamOutNum++; m_scaninfo.JamOutNum++;
LOG("paper 卡纸了。。。。。\n"); printf("paper 卡纸了。。。。。\n");
} }
else else
{ {

View File

@ -78,7 +78,7 @@ public:
motorCuozhi.reset(); motorCuozhi.reset();
isRested = true; isRested = true;
isPaperInit = false; isPaperInit = false;
LOG("Scanner->motorCuozhi is reseted \n"); printf("Scanner->motorCuozhi is reseted \n");
} }
} }
void paperReady() void paperReady()

View File

@ -158,14 +158,29 @@ void Sensor::monitor()
} }
if (pfd.revents & POLLPRI) if (pfd.revents & POLLPRI)
{ {
if(sw.elapsed_ms() < 10)
{
printf("扫描传感器消抖。。。\r\n");
sw.reset();
ret = poll(&pfd, 1, 1);
if (ret > 0)
{
lseek(pfd.fd, 0, SEEK_SET);
num = read(pfd.fd, buf, 8);
buf[num - 1] = '\0';
ret = atoi(buf);
}
continue;
}
lseek(pfd.fd, 0, SEEK_SET); lseek(pfd.fd, 0, SEEK_SET);
num = read(pfd.fd, buf, 8); num = read(pfd.fd, buf, 8);
buf[num - 1] = '\0'; buf[num - 1] = '\0';
ret = atoi(buf); ret = atoi(buf);
//ftt.append_log(ret?"in":"out"); bool b = false;
if (ret) if (ret)
{ {
b = true;
printf("检测纸张进入 time%f\r\n",sw2.elapsed_ms()); printf("检测纸张进入 time%f\r\n",sw2.elapsed_ms());
sw1.reset(); sw1.reset();
} }
@ -173,19 +188,12 @@ void Sensor::monitor()
{ {
printf("检测纸张出去 time%f\r\n",sw1.elapsed_ms()); printf("检测纸张出去 time%f\r\n",sw1.elapsed_ms());
sw2.reset(); sw2.reset();
if (!b) //理论上来说
continue;
} }
edges[ret]->notify_all(); edges[ret]->notify_all();
while(sw.elapsed_ms() < 10) sw.reset();
{
ret = poll(&pfd, 1, 1);
if (ret > 0)
{
num = read(pfd.fd, buf, 8);
buf[num - 1] = '\0';
ret = atoi(buf);
}
}
} }
} }

View File

@ -497,7 +497,7 @@ int main(int argc, char *argv[])
// break; // break;
case USBCommand::PRE_UPGRADE: case USBCommand::PRE_UPGRADE:
{ {
printf("start PRE_UPGRADE \n"); printf("正在准备升级中... \n");
updatePkg.open("/home/root/update.zip", ios::out | ios::binary); updatePkg.open("/home/root/update.zip", ios::out | ios::binary);
m_scanner->SetLEDStatus(LedStatus::Updating); m_scanner->SetLEDStatus(LedStatus::Updating);
total_length = usbcb.Length; total_length = usbcb.Length;
@ -505,35 +505,69 @@ int main(int argc, char *argv[])
break; break;
case USBCommand::START_UPGRADE: case USBCommand::START_UPGRADE:
{ {
LOG("\n-----------START_UPGRADE----------------\n %d %d %d ", usbcb.Command, usbcb.Data, usbcb.Length); if (!updatePkg.is_open())
USBCB tmpUpdate = {(unsigned int)(USBCommand::START_UPGRADE), 0, 0};
if (usbcb.Length != 0)
{ {
LOG("\n-----------read_bulk----------------"); printf("准备升级文件失败...\r\n");
uint ntoReadn = usbcb.Length; break;
char *bufferData = (char *)malloc(ntoReadn * sizeof(char));
if (bufferData)
{
m_scanner->read_bulk(bufferData, ntoReadn);
updatePkg.write(bufferData, ntoReadn);
tmpUpdate.Length = ntoReadn;
free(bufferData);
}
} }
printf("开始进行升级包下载...\r\n");
int total = usbcb.Length,
block = 0,
indx = 0;
char *bufferData = (char *)malloc(total * sizeof(char));
while (total > 0)
{
block = 1024 * 1024;
if (total < block)
block = total;
m_scanner->read_bulk(bufferData + indx, block);
total -= block;
indx += block;
}
updatePkg.write(bufferData, indx);//或者放上面分段写也是一样的,数据量太大的话
USBCB tmpUpdate = {(unsigned int)(USBCommand::START_UPGRADE), 0, 0};
tmpUpdate.Data = updatePkg.bad() ? 10 : 100;
m_scanner->write_bulk(&tmpUpdate, sizeof(tmpUpdate)); m_scanner->write_bulk(&tmpUpdate, sizeof(tmpUpdate));
if (bufferData)
{
free(bufferData);
}
printf("升级包下载:%s...\r\n",tmpUpdate.Data == 10 ? "失败":"成功");
// LOG("\n-----------START_UPGRADE----------------\n %d %d %d ", usbcb.Command, usbcb.Data, usbcb.Length);
// USBCB tmpUpdate = {(unsigned int)(USBCommand::START_UPGRADE), 0, 0};
// if (usbcb.Length != 0)
// {
// LOG("\n-----------read_bulk----------------");
// uint ntoReadn = usbcb.Length;
// char *bufferData = (char *)malloc(ntoReadn * sizeof(char));
// if (bufferData)
// {
// m_scanner->read_bulk(bufferData, ntoReadn);
// updatePkg.write(bufferData, ntoReadn);
// tmpUpdate.Length = ntoReadn;
// free(bufferData);
// }
// }
// m_scanner->write_bulk(&tmpUpdate, sizeof(tmpUpdate));
} }
break; break;
case USBCommand::UPDATE_FINISHED: case USBCommand::UPDATE_FINISHED:
{ {
printf("开始进行升级... \n");
printf("PRE_UPGRADE finished \n");
if (total_length < (1024 * 1024 * 5))
this_thread::sleep_for(std::chrono::seconds(10));
m_scanner->SetLEDStatus(LedStatus::UpdateDone); m_scanner->SetLEDStatus(LedStatus::UpdateDone);
updatePkg.close(); updatePkg.close();
//system("sh /mnt/flash-disk/upgrade_firmware.sh &"); system("sh /mnt/flash-disk/upgrade_firmware.sh &");
printf("PRE_UPGRADE finished exit!!!!!!!!!!!!! \n");
} }
break; break;
case USBCommand::REBOOT: case USBCommand::REBOOT:
@ -592,9 +626,8 @@ int main(int argc, char *argv[])
case USBCommand::GET_UPDATE_RESULT: case USBCommand::GET_UPDATE_RESULT:
{ {
int ret = get_devs_status("/mnt/flash-disk/update_status.txt"); int ret = get_devs_status("/mnt/flash-disk/update_status.txt");
printf("GET_UPDATE_RESULT !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r\n"); printf("获取升级状态:%d\r\n",ret);
printf("ret:%d\r\n",ret);
usbcb.Data = ret; usbcb.Data = ret;
if (ret == -1) if (ret == -1)
{ {
@ -602,8 +635,11 @@ int main(int argc, char *argv[])
} }
m_scanner->write_bulk(&usbcb, sizeof(usbcb)); m_scanner->write_bulk(&usbcb, sizeof(usbcb));
if (usbcb.Data == 0) if (ret == SCANNER_ERR_UPDATE_OK)
system("reboot"); {
printf("升级成功。。。\r\n");
}
//system("reboot");
} }
break; break;
case USBCommand::CLEAR_LOG_FILES: case USBCommand::CLEAR_LOG_FILES:

View File

@ -63,7 +63,7 @@ typedef struct
static std::map<int , sp_COLOR_or_GRAY>mapFradme_SP={ static std::map<int , sp_COLOR_or_GRAY>mapFradme_SP={
{1,{0x08ED1003,0x1ACC1002,CON(G34D,231027)}},//40 ppm {1,{0x08ED1003,0x1ACC1002,CON(G34D,231027)}},//40 ppm
{2,{0x06DB1003,0x14A01002,CON(G35D,231027)}},//50 ppm {2,{0x06DB1003,0x14A01002,CON(G3ZY,231102)}},//50 ppm
{3,{0x05591003,0x100E1002,CON(G36D,231027)}},//60 ppm {3,{0x05591003,0x100E1002,CON(G36D,231027)}},//60 ppm
{4,{0x04421003,0x0CD11002,CON(G37D,231027)}},//70 ppm {4,{0x04421003,0x0CD11002,CON(G37D,231027)}},//70 ppm
{5,{0x036c1003,0x0A421002,CON(G38D,231027)}},//80 ppm {5,{0x036c1003,0x0A421002,CON(G38D,231027)}},//80 ppm
@ -184,10 +184,10 @@ struct
unsigned int enableSizeDetect : 1; unsigned int enableSizeDetect : 1;
unsigned int lutmode : 1 ; unsigned int lutmode : 1 ;
unsigned int slow_moire : 1; unsigned int slow_moire : 1;
unsigned int reversed1 : 3; unsigned int reversed1 : 2;
unsigned int isCorrect : 1; unsigned int isCorrect : 1;
unsigned int dc : 8; unsigned int dc : 7; //0 - 100
unsigned int reversed2 : 6; unsigned int reversed2 : 8;
} params; } params;
unsigned int value; unsigned int value;
}; };