fix: 调整Camera的taskID,使其能够正常接受数据
This commit is contained in:
parent
e84a784517
commit
287c416247
|
@ -42,14 +42,14 @@ class Camera
|
||||||
public async ValueTask<Result<byte[]>> ReadFrame()
|
public async ValueTask<Result<byte[]>> ReadFrame()
|
||||||
{
|
{
|
||||||
// 清除UDP服务器接收缓冲区
|
// 清除UDP服务器接收缓冲区
|
||||||
await MsgBus.UDPServer.ClearUDPData(this.address, 3);
|
await MsgBus.UDPServer.ClearUDPData(this.address, 2);
|
||||||
|
|
||||||
logger.Trace($"Clear up udp server {this.address} receive data");
|
logger.Trace($"Clear up udp server {this.address} receive data");
|
||||||
|
|
||||||
// 使用UDPClientPool读取图像帧数据
|
// 使用UDPClientPool读取图像帧数据
|
||||||
var result = await UDPClientPool.ReadAddrBytes(
|
var result = await UDPClientPool.ReadAddrBytes(
|
||||||
this.ep,
|
this.ep,
|
||||||
3, // taskID
|
2, // taskID
|
||||||
CameraAddr.Base,
|
CameraAddr.Base,
|
||||||
(int)CameraAddr.FrameLength,
|
(int)CameraAddr.FrameLength,
|
||||||
this.timeout);
|
this.timeout);
|
||||||
|
|
|
@ -323,7 +323,6 @@ public class UDPClientPool
|
||||||
|
|
||||||
opts.BurstType = BurstType.FixedBurst;
|
opts.BurstType = BurstType.FixedBurst;
|
||||||
opts.CommandID = Convert.ToByte(taskID);
|
opts.CommandID = Convert.ToByte(taskID);
|
||||||
opts.Address = devAddr;
|
|
||||||
opts.IsWrite = false;
|
opts.IsWrite = false;
|
||||||
|
|
||||||
// Check Msg Bus
|
// Check Msg Bus
|
||||||
|
@ -332,8 +331,8 @@ public class UDPClientPool
|
||||||
|
|
||||||
// Calculate read times and segments
|
// Calculate read times and segments
|
||||||
var maxBytesPerRead = 256 * (32 / 8); // 1024 bytes per read
|
var maxBytesPerRead = 256 * (32 / 8); // 1024 bytes per read
|
||||||
var hasRest = dataLength % maxBytesPerRead != 0;
|
var restBytes = dataLength % maxBytesPerRead;
|
||||||
var readTimes = hasRest ?
|
var readTimes = restBytes != 0 ?
|
||||||
dataLength / maxBytesPerRead + 1 :
|
dataLength / maxBytesPerRead + 1 :
|
||||||
dataLength / maxBytesPerRead;
|
dataLength / maxBytesPerRead;
|
||||||
|
|
||||||
|
@ -341,9 +340,7 @@ public class UDPClientPool
|
||||||
{
|
{
|
||||||
// Calculate current segment size
|
// Calculate current segment size
|
||||||
var isLastSegment = i == readTimes - 1;
|
var isLastSegment = i == readTimes - 1;
|
||||||
var currentSegmentSize = isLastSegment && hasRest ?
|
var currentSegmentSize = isLastSegment ? restBytes : maxBytesPerRead;
|
||||||
dataLength % maxBytesPerRead :
|
|
||||||
maxBytesPerRead;
|
|
||||||
|
|
||||||
// Set burst length (in 32-bit words)
|
// Set burst length (in 32-bit words)
|
||||||
opts.BurstLength = (byte)(currentSegmentSize / 4 - 1);
|
opts.BurstLength = (byte)(currentSegmentSize / 4 - 1);
|
||||||
|
|
Loading…
Reference in New Issue