From bf151014eac7afcfd0106b18ff931d4560e6e4e9 Mon Sep 17 00:00:00 2001 From: gb <741021719@qq.com> Date: Mon, 18 Mar 2024 11:42:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96UART=E8=AF=BB=E5=8F=96?= =?UTF-8?q?=E9=80=9F=E5=BA=A6=EF=BC=9B=E6=81=A2=E5=A4=8D=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=80=BC=E6=97=B6=E5=BF=BD=E7=95=A5button&group=E5=B1=9E?= =?UTF-8?q?=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hardware/uart/serialib.cpp | 36 +++++++++++++++++++++++--------- hardware/uart/uartregsaccess.cpp | 13 ++++++++---- sdk/sane_opt_json/device_opt.cpp | 6 +++++- xmake.lua | 4 ++-- 4 files changed, 42 insertions(+), 17 deletions(-) diff --git a/hardware/uart/serialib.cpp b/hardware/uart/serialib.cpp index 0cb5aa9..9b1abbb 100644 --- a/hardware/uart/serialib.cpp +++ b/hardware/uart/serialib.cpp @@ -489,18 +489,34 @@ int serialib::Read (void *Buffer,unsigned int MaxNbBytes,unsigned int TimeOut_ms #ifdef __linux__ TimeOut Timer; // Timer used for timeout Timer.InitTimer(); // Initialise the timer - unsigned int NbByteRead=0; - while (Timer.ElapsedTime_ms()0) { // One or several byte(s) has been read on the device + // NbByteRead+=Ret; // Increase the number of read bytes + // if (NbByteRead>=MaxNbBytes) // Success : bytes has been read + // return 1; + // } + // } + unsigned char* ptr = (unsigned char*)Buffer; + unsigned int rd = 0; + + do { - unsigned char* Ptr=(unsigned char*)Buffer+NbByteRead; // Compute the position of the current byte - int Ret=read(fd,(void*)Ptr,MaxNbBytes-NbByteRead); // Try to read a byte on the device - if (Ret==-1) return -2; // Error while reading - if (Ret>0) { // One or several byte(s) has been read on the device - NbByteRead+=Ret; // Increase the number of read bytes - if (NbByteRead>=MaxNbBytes) // Success : bytes has been read - return 1; + int ret = read(fd, (void*)ptr, MaxNbBytes); // Try to read a byte on the device + if(ret >= MaxNbBytes) + return 1; + if(ret > 0) + { + ptr += ret; + MaxNbBytes -= ret; } - } + else if(ret < 0) + return -2; + }while (Timer.ElapsedTime_ms() < TimeOut_ms || TimeOut_ms==0); // While Timeout is not reached return 0; // Timeout reached, return 0 #endif } diff --git a/hardware/uart/uartregsaccess.cpp b/hardware/uart/uartregsaccess.cpp index 6765ff3..35fa616 100644 --- a/hardware/uart/uartregsaccess.cpp +++ b/hardware/uart/uartregsaccess.cpp @@ -15,8 +15,10 @@ bool UartRegsAccess::write(unsigned int addr, unsigned int val) unsigned int valt = val; unsigned char* idata = (unsigned char*)&val; unsigned char *idatat = (unsigned char *)&valt; - for(int i = 0; i < 4; i++) - idata[3 - i] = idatat[i]; + idata[0] = idatat[3]; + idata[1] = idatat[2]; + idata[2] = idatat[1]; + idata[3] = idatat[0]; return UartRegsAccessB::write(addr, val); } @@ -28,8 +30,11 @@ bool UartRegsAccess::read(unsigned int addr, unsigned int& val) { unsigned char *idata = (unsigned char *)&val; unsigned char *idatat = (unsigned char *)&valt; - for (int i = 0; i < 4; i++) - idata[3 - i] = idatat[i]; + idata[0] = idatat[3]; + idata[1] = idatat[2]; + idata[2] = idatat[1]; + idata[3] = idatat[0]; + return true; } return false; diff --git a/sdk/sane_opt_json/device_opt.cpp b/sdk/sane_opt_json/device_opt.cpp index b5d019f..b8c6ae6 100644 --- a/sdk/sane_opt_json/device_opt.cpp +++ b/sdk/sane_opt_json/device_opt.cpp @@ -2157,7 +2157,11 @@ int device_option::restore(sane_opt_provider* holder) child = cur->first_child(); while (child) { - if ((!holder || src_.count(child->key()) && src_[child->key()] == holder) + std::string type(""); + + child->get_value("type", type); + if (type != JSON_SANE_TYPE_GROUP && type != JSON_SANE_TYPE_BUTTON + && (!holder || src_.count(child->key()) && src_[child->key()] == holder) // && is_auto_restore_default(child) ) { diff --git a/xmake.lua b/xmake.lua index 949afa0..5b2a860 100644 --- a/xmake.lua +++ b/xmake.lua @@ -60,8 +60,8 @@ add_packagedirs("sdk") add_defines("BUILD_AS_DEVICE") add_defines("VER_MAIN=2") add_defines("VER_FAMILY=200") -add_defines("VER_DATE=20240315") -add_defines("VER_BUILD=3") +add_defines("VER_DATE=20240318") +add_defines("VER_BUILD=15") target("conf") set_kind("phony")