优化UART读取速度;恢复默认值时忽略button&group属性
This commit is contained in:
parent
9f5cf1d587
commit
bf151014ea
|
@ -489,18 +489,34 @@ int serialib::Read (void *Buffer,unsigned int MaxNbBytes,unsigned int TimeOut_ms
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
TimeOut Timer; // Timer used for timeout
|
TimeOut Timer; // Timer used for timeout
|
||||||
Timer.InitTimer(); // Initialise the timer
|
Timer.InitTimer(); // Initialise the timer
|
||||||
unsigned int NbByteRead=0;
|
// unsigned int NbByteRead=0;
|
||||||
while (Timer.ElapsedTime_ms()<TimeOut_ms || TimeOut_ms==0) // While Timeout is not reached
|
// while (Timer.ElapsedTime_ms()<TimeOut_ms || TimeOut_ms==0) // While Timeout is not reached
|
||||||
|
// {
|
||||||
|
// 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;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
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); // Try to read a byte on the device
|
||||||
int Ret=read(fd,(void*)Ptr,MaxNbBytes-NbByteRead); // Try to read a byte on the device
|
if(ret >= MaxNbBytes)
|
||||||
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;
|
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
|
return 0; // Timeout reached, return 0
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,10 @@ bool UartRegsAccess::write(unsigned int addr, unsigned int val)
|
||||||
unsigned int valt = val;
|
unsigned int valt = val;
|
||||||
unsigned char* idata = (unsigned char*)&val;
|
unsigned char* idata = (unsigned char*)&val;
|
||||||
unsigned char *idatat = (unsigned char *)&valt;
|
unsigned char *idatat = (unsigned char *)&valt;
|
||||||
for(int i = 0; i < 4; i++)
|
idata[0] = idatat[3];
|
||||||
idata[3 - i] = idatat[i];
|
idata[1] = idatat[2];
|
||||||
|
idata[2] = idatat[1];
|
||||||
|
idata[3] = idatat[0];
|
||||||
|
|
||||||
return UartRegsAccessB::write(addr, val);
|
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 *idata = (unsigned char *)&val;
|
||||||
unsigned char *idatat = (unsigned char *)&valt;
|
unsigned char *idatat = (unsigned char *)&valt;
|
||||||
for (int i = 0; i < 4; i++)
|
idata[0] = idatat[3];
|
||||||
idata[3 - i] = idatat[i];
|
idata[1] = idatat[2];
|
||||||
|
idata[2] = idatat[1];
|
||||||
|
idata[3] = idatat[0];
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -2157,7 +2157,11 @@ int device_option::restore(sane_opt_provider* holder)
|
||||||
child = cur->first_child();
|
child = cur->first_child();
|
||||||
while (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)
|
// && is_auto_restore_default(child)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
|
@ -60,8 +60,8 @@ add_packagedirs("sdk")
|
||||||
add_defines("BUILD_AS_DEVICE")
|
add_defines("BUILD_AS_DEVICE")
|
||||||
add_defines("VER_MAIN=2")
|
add_defines("VER_MAIN=2")
|
||||||
add_defines("VER_FAMILY=200")
|
add_defines("VER_FAMILY=200")
|
||||||
add_defines("VER_DATE=20240315")
|
add_defines("VER_DATE=20240318")
|
||||||
add_defines("VER_BUILD=3")
|
add_defines("VER_BUILD=15")
|
||||||
|
|
||||||
target("conf")
|
target("conf")
|
||||||
set_kind("phony")
|
set_kind("phony")
|
||||||
|
|
Loading…
Reference in New Issue