feat: readwithwait函数增加了新参数;camera有更多分辨率选择。
This commit is contained in:
@@ -306,10 +306,11 @@ public class UDPClientPool
|
||||
/// <param name="devAddr">设备地址</param>
|
||||
/// <param name="result">期望的结果值</param>
|
||||
/// <param name="resultMask">结果掩码,用于位校验</param>
|
||||
/// <param name="waittime">等待间隔时间(毫秒)</param>
|
||||
/// <param name="timeout">超时时间(毫秒)</param>
|
||||
/// <returns>校验结果,true表示在超时前数据匹配期望值</returns>
|
||||
public static async ValueTask<Result<bool>> ReadAddrWithWait(
|
||||
IPEndPoint endPoint, int taskID, uint devAddr, UInt32 result, UInt32 resultMask, int timeout = 1000)
|
||||
IPEndPoint endPoint, int taskID, uint devAddr, UInt32 result, UInt32 resultMask, int waittime = 100, int timeout = 1000)
|
||||
{
|
||||
var address = endPoint.Address.ToString();
|
||||
|
||||
@@ -319,7 +320,7 @@ public class UDPClientPool
|
||||
var elapsed = DateTime.Now - startTime;
|
||||
if (elapsed >= TimeSpan.FromMilliseconds(timeout)) break;
|
||||
var timeleft = TimeSpan.FromMilliseconds(timeout) - elapsed;
|
||||
|
||||
await Task.Delay(waittime);
|
||||
try
|
||||
{
|
||||
var ret = await ReadAddr(endPoint, taskID, devAddr, Convert.ToInt32(timeleft.TotalMilliseconds));
|
||||
@@ -637,21 +638,23 @@ public class UDPClientPool
|
||||
IsWrite = true,
|
||||
};
|
||||
|
||||
var max4BytesPerRead = 128; // 1024 bytes per read
|
||||
|
||||
// Check Msg Bus
|
||||
if (!MsgBus.IsRunning)
|
||||
return new(new Exception("Message bus not working!"));
|
||||
|
||||
var hasRest = dataArray.Length % (256 * (32 / 8)) != 0;
|
||||
var hasRest = dataArray.Length % (max4BytesPerRead * (32 / 8)) != 0;
|
||||
var writeTimes = hasRest ?
|
||||
dataArray.Length / (256 * (32 / 8)) + 1 :
|
||||
dataArray.Length / (256 * (32 / 8));
|
||||
dataArray.Length / (max4BytesPerRead * (32 / 8)) + 1 :
|
||||
dataArray.Length / (max4BytesPerRead * (32 / 8));
|
||||
for (var i = 0; i < writeTimes; i++)
|
||||
{
|
||||
// Sperate Data Array
|
||||
var isLastData = i == writeTimes - 1;
|
||||
var sendDataArray = isLastData ?
|
||||
dataArray[(i * (256 * (32 / 8)))..] :
|
||||
dataArray[(i * (256 * (32 / 8)))..((i + 1) * (256 * (32 / 8)))];
|
||||
dataArray[(i * (max4BytesPerRead * (32 / 8)))..] :
|
||||
dataArray[(i * (max4BytesPerRead * (32 / 8)))..((i + 1) * (max4BytesPerRead * (32 / 8)))];
|
||||
|
||||
// Calculate BurstLength
|
||||
opts.BurstLength = ((byte)(
|
||||
|
||||
Reference in New Issue
Block a user