feat: 实现udp多端口

This commit is contained in:
2025-07-14 14:01:08 +08:00
parent 2894ee24be
commit ca906489c2
9 changed files with 53 additions and 92 deletions

View File

@@ -224,7 +224,7 @@ class Camera
// 读取失败时清除缓冲区,为下次读取做准备
try
{
await MsgBus.UDPServer.ClearUDPData(this.address, this.taskID);
MsgBus.UDPServer.ClearUDPData(this.address, this.taskID);
}
catch (Exception ex)
{

View File

@@ -108,7 +108,7 @@ public class DDS
if (waveNum < 0 || waveNum > 3) return new(new ArgumentException(
$"Wave number should be 0 ~ 3 instead of {waveNum}", nameof(waveNum)));
await MsgBus.UDPServer.ClearUDPData(this.address, 1);
MsgBus.UDPServer.ClearUDPData(this.address, 1);
logger.Trace("Clear udp data finished");
var ret = await UDPClientPool.WriteAddr(
@@ -132,7 +132,7 @@ public class DDS
if (waveNum < 0 || waveNum > 3) return new(new ArgumentException(
$"Wave number should be 0 ~ 3 instead of {waveNum}", nameof(waveNum)));
await MsgBus.UDPServer.ClearUDPData(this.address, 1);
MsgBus.UDPServer.ClearUDPData(this.address, 1);
logger.Trace("Clear udp data finished");
var ret = await UDPClientPool.WriteAddr(
@@ -158,7 +158,7 @@ public class DDS
if (phase < 0 || phase > 4096) return new(new ArgumentException(
$"Phase should be 0 ~ 4096 instead of {phase}", nameof(phase)));
await MsgBus.UDPServer.ClearUDPData(this.address, 1);
MsgBus.UDPServer.ClearUDPData(this.address, 1);
logger.Trace("Clear udp data finished");
var ret = await UDPClientPool.WriteAddr(

View File

@@ -82,7 +82,7 @@ public class I2c
/// <param name="taskID">[TODO:parameter]</param>
/// <param name="timeout">[TODO:parameter]</param>
/// <returns>[TODO:return]</returns>
public I2c(string address, int port, int taskID,int timeout = 2000)
public I2c(string address, int port, int taskID, int timeout = 2000)
{
if (timeout < 0)
throw new ArgumentException("Timeout couldn't be negative", nameof(timeout));
@@ -109,7 +109,7 @@ public class I2c
}
// 清除UDP服务器接收缓冲区
await MsgBus.UDPServer.ClearUDPData(this.address, this.taskID);
MsgBus.UDPServer.ClearUDPData(this.address, this.taskID);
logger.Trace($"Clear up udp server {this.address} receive data");
@@ -207,7 +207,7 @@ public class I2c
}
// 清除UDP服务器接收缓冲区
await MsgBus.UDPServer.ClearUDPData(this.address, this.taskID);
MsgBus.UDPServer.ClearUDPData(this.address, this.taskID);
logger.Trace($"Clear up udp server {this.address} receive data");

View File

@@ -627,7 +627,7 @@ public class Jtag
public async ValueTask<Result<uint>> ReadIDCode()
{
// Clear Data
await MsgBus.UDPServer.ClearUDPData(this.address, 0);
MsgBus.UDPServer.ClearUDPData(this.address, 0);
logger.Trace($"Clear up udp server {this.address,0} receive data");
@@ -665,7 +665,7 @@ public class Jtag
public async ValueTask<Result<uint>> ReadStatusReg()
{
// Clear Data
await MsgBus.UDPServer.ClearUDPData(this.address, 0);
MsgBus.UDPServer.ClearUDPData(this.address, 0);
logger.Trace($"Clear up udp server {this.address,0} receive data");
@@ -702,7 +702,7 @@ public class Jtag
public async ValueTask<Result<bool>> DownloadBitstream(byte[] bitstream)
{
// Clear Data
await MsgBus.UDPServer.ClearUDPData(this.address, 0);
MsgBus.UDPServer.ClearUDPData(this.address, 0);
logger.Trace($"Clear up udp server {this.address,0} receive data");
@@ -786,7 +786,7 @@ public class Jtag
logger.Debug($"Get boundar scan registers number: {portNum}");
// Clear Data
await MsgBus.UDPServer.ClearUDPData(this.address, 0);
MsgBus.UDPServer.ClearUDPData(this.address, 0);
logger.Trace($"Clear up udp server {this.address,0} receive data");
@@ -853,7 +853,7 @@ public class Jtag
public async ValueTask<Result<bool>> SetSpeed(UInt32 speed)
{
// Clear Data
await MsgBus.UDPServer.ClearUDPData(this.address, 0);
MsgBus.UDPServer.ClearUDPData(this.address, 0);
logger.Trace($"Clear up udp server {this.address,0} receive data");

View File

@@ -44,7 +44,7 @@ public class MatrixKey
public async ValueTask<Result<bool>> EnableControl()
{
if (MsgBus.IsRunning)
await MsgBus.UDPServer.ClearUDPData(this.address, 1);
MsgBus.UDPServer.ClearUDPData(this.address, 1);
else return new(new Exception("Message Bus not work!"));
var ret = await UDPClientPool.WriteAddr(this.ep, 1, MatrixKeyAddr.KEY_ENABLE, 1, this.timeout);
@@ -59,7 +59,7 @@ public class MatrixKey
public async ValueTask<Result<bool>> DisableControl()
{
if (MsgBus.IsRunning)
await MsgBus.UDPServer.ClearUDPData(this.address, 1);
MsgBus.UDPServer.ClearUDPData(this.address, 1);
else return new(new Exception("Message Bus not work!"));
var ret = await UDPClientPool.WriteAddr(this.ep, 1, MatrixKeyAddr.KEY_ENABLE, 0, this.timeout);
@@ -75,7 +75,7 @@ public class MatrixKey
public async ValueTask<Result<bool>> ControlKey(BitArray keyStates)
{
if (MsgBus.IsRunning)
await MsgBus.UDPServer.ClearUDPData(this.address, 1);
MsgBus.UDPServer.ClearUDPData(this.address, 1);
else return new(new Exception("Message Bus not work!"));
if (keyStates.Length != 16) return new(new ArgumentException(

View File

@@ -45,7 +45,7 @@ public class Power
public async ValueTask<Result<bool>> SetPowerOnOff(bool enable)
{
if (MsgBus.IsRunning)
await MsgBus.UDPServer.ClearUDPData(this.address, 1);
MsgBus.UDPServer.ClearUDPData(this.address, 1);
else return new(new Exception("Message Bus not work!"));
var ret = await UDPClientPool.WriteAddr(this.ep, 1, PowerAddr.PowerCtrl, Convert.ToUInt32(enable), this.timeout);

View File

@@ -382,7 +382,7 @@ public class RemoteUpdater
/// <returns>[TODO:return]</returns>
public async ValueTask<Result<bool>> HotResetBitstream(int bitstreamNum)
{
await MsgBus.UDPServer.ClearUDPData(this.address, 0);
MsgBus.UDPServer.ClearUDPData(this.address, 0);
logger.Trace("Clear udp data finished");
{
@@ -412,7 +412,7 @@ public class RemoteUpdater
byte[]? bitstream2,
byte[]? bitstream3)
{
await MsgBus.UDPServer.ClearUDPData(this.address, 0);
MsgBus.UDPServer.ClearUDPData(this.address, 0);
logger.Trace("Clear udp data finished");
for (int bitstreamNum = 0; bitstreamNum < 4; bitstreamNum++)
@@ -463,7 +463,7 @@ public class RemoteUpdater
$"The length of data should be divided by 4096, bug given {bytesData.Length}", nameof(bytesData)));
var bitstreamBlockNum = bytesData.Length / (4 * 1024);
await MsgBus.UDPServer.ClearUDPData(this.address, 0);
MsgBus.UDPServer.ClearUDPData(this.address, 0);
logger.Trace("Clear udp data finished");
{
@@ -539,7 +539,7 @@ public class RemoteUpdater
/// <returns>[TODO:return]</returns>
public async ValueTask<Result<UInt32>> GetVersion()
{
await MsgBus.UDPServer.ClearUDPData(this.address, 0);
MsgBus.UDPServer.ClearUDPData(this.address, 0);
logger.Trace("Clear udp data finished");
{