From e3b7cc4f63ce710387a9b3d9d9329ccf9dc8575b Mon Sep 17 00:00:00 2001 From: SikongJueluo <1822250894@qq.com> Date: Thu, 21 Aug 2025 19:19:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=94=B1=E4=BA=8E?= =?UTF-8?q?=E5=9F=BA=E6=9C=AC=E7=9A=84=E9=80=9A=E4=BF=A1=E5=8D=8F=E8=AE=AE?= =?UTF-8?q?=E6=9B=B4=E6=94=B9=E4=B8=8D=E5=AE=8C=E5=85=A8=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E7=9A=84=E6=97=A0=E6=B3=95=E6=8E=A7=E5=88=B6=E7=94=B5=E6=BA=90?= =?UTF-8?q?=E4=B8=8Ejtag=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/Controllers/JtagController.cs | 2 +- server/src/Peripherals/JtagClient.cs | 4 +-- server/src/UdpServer.cs | 2 +- server/src/WebProtocol.cs | 31 ++++++++++++------------ 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/server/src/Controllers/JtagController.cs b/server/src/Controllers/JtagController.cs index b1a86b8..7b6bf86 100644 --- a/server/src/Controllers/JtagController.cs +++ b/server/src/Controllers/JtagController.cs @@ -183,7 +183,7 @@ public class JtagController : ControllerBase logger.Info($"User {username} processing bitstream file of size: {fileBytes.Length} bytes"); // 定义进度跟踪 - var taskId = _tracker.CreateTask(10000); + var taskId = _tracker.CreateTask(8000); _tracker.AdvanceProgress(taskId, 10); _ = Task.Run(async () => diff --git a/server/src/Peripherals/JtagClient.cs b/server/src/Peripherals/JtagClient.cs index 4181701..249d120 100644 --- a/server/src/Peripherals/JtagClient.cs +++ b/server/src/Peripherals/JtagClient.cs @@ -756,7 +756,7 @@ public class Jtag logger.Trace("Jtag ready to write bitstream"); - ret = await IdleDelay(100000); + ret = await IdleDelay(1000); if (!ret.IsSuccessful) return new(ret.Error); else if (!ret.Value) return new(new Exception("Jtag IDLE Delay Failed")); _progressTracker.AdvanceProgress(progressId, 10); @@ -784,7 +784,7 @@ public class Jtag logger.Trace("Jtag reset device"); - ret = await IdleDelay(10000); + ret = await IdleDelay(1000); if (!ret.IsSuccessful) return new(ret.Error); else if (!ret.Value) return new(new Exception("Jtag IDLE Delay Failed")); _progressTracker.AdvanceProgress(progressId, 10); diff --git a/server/src/UdpServer.cs b/server/src/UdpServer.cs index e396120..f8502c9 100644 --- a/server/src/UdpServer.cs +++ b/server/src/UdpServer.cs @@ -436,7 +436,7 @@ public class UDPServer } var udpDataObj = await RecordUDPData(data, endPoint, time, Convert.ToInt32(data[1 + 4])); - // PrintData(udpDataObj); + PrintData(udpDataObj); } catch (Exception e) { diff --git a/server/src/WebProtocol.cs b/server/src/WebProtocol.cs index 55467b1..cb3978c 100644 --- a/server/src/WebProtocol.cs +++ b/server/src/WebProtocol.cs @@ -131,7 +131,7 @@ namespace WebProtocol readonly byte sign = (byte)PackSign.SendAddr; readonly byte commandType; readonly byte burstLength; - readonly byte _reserved = 0; + readonly byte commandID; readonly UInt32 address; /// @@ -140,10 +140,10 @@ namespace WebProtocol /// 地址包选项 public SendAddrPackage(SendAddrPackOptions opts) { - byte byteBurstType = Convert.ToByte((byte)opts.BurstType << 6); - byte byteCommandID = Convert.ToByte((opts.CommandID & 0x03) << 4); + byte byteBurstType = Convert.ToByte((byte)opts.BurstType << 4); byte byteIsWrite = (opts.IsWrite ? (byte)0x01 : (byte)0x00); - this.commandType = Convert.ToByte(byteBurstType | byteCommandID | byteIsWrite); + this.commandType = Convert.ToByte(byteBurstType | byteIsWrite); + this.commandID = opts.CommandID; this.burstLength = opts.BurstLength; this.address = opts.Address; } @@ -158,10 +158,10 @@ namespace WebProtocol /// 设备地址 public SendAddrPackage(BurstType burstType, byte commandID, bool isWrite, byte burstLength, UInt32 address) { - byte byteBurstType = Convert.ToByte((byte)burstType << 6); - byte byteCommandID = Convert.ToByte((commandID & 0x03) << 4); + byte byteBurstType = Convert.ToByte((byte)burstType << 4); byte byteIsWrite = (isWrite ? (byte)0x01 : (byte)0x00); - this.commandType = Convert.ToByte(byteBurstType | byteCommandID | byteIsWrite); + this.commandType = Convert.ToByte(byteBurstType | byteIsWrite); + this.commandID = commandID; this.burstLength = burstLength; this.address = address; } @@ -172,9 +172,10 @@ namespace WebProtocol /// 二进制命令类型 /// 突发长度 /// 写入或读取的地址 - public SendAddrPackage(byte commandType, byte burstLength, UInt32 address) + public SendAddrPackage(byte commandType, byte burstLength, byte commandID, UInt32 address) { this.commandType = commandType; + this.commandID = commandID; this.burstLength = burstLength; this.address = address; } @@ -190,8 +191,8 @@ namespace WebProtocol { Address = this.address, BurstLength = this.burstLength, - BurstType = (BurstType)(this.commandType >> 6), - CommandID = Convert.ToByte((this.commandType >> 4) & 0b11), + BurstType = (BurstType)(this.commandType >> 4), + CommandID = this.commandID, IsWrite = Convert.ToBoolean(this.commandType & 1) }; } @@ -207,7 +208,7 @@ namespace WebProtocol arr[0] = sign; arr[1] = commandType; arr[2] = burstLength; - arr[3] = _reserved; + arr[3] = commandID; var bytesAddr = Common.Number.NumberToBytes(address, 4).Value; Array.Copy(bytesAddr, 0, arr, 4, bytesAddr.Length); @@ -223,8 +224,8 @@ namespace WebProtocol { var opts = new SendAddrPackOptions() { - BurstType = (BurstType)(commandType >> 6), - CommandID = Convert.ToByte((commandType >> 4) & 0b0011), + BurstType = (BurstType)(commandType >> 4), + CommandID = this.commandID, IsWrite = Convert.ToBoolean(commandType & 0x01), BurstLength = burstLength, Address = address, @@ -258,7 +259,7 @@ namespace WebProtocol } var address = Common.Number.BytesToUInt64(bytes[4..]).Value; - return new SendAddrPackage(bytes[1], bytes[2], Convert.ToUInt32(address)); + return new SendAddrPackage(bytes[1], bytes[2], bytes[3], Convert.ToUInt32(address)); } } @@ -316,7 +317,7 @@ namespace WebProtocol readonly byte[] bodyData; /// - /// FPGA->Server 读响应包 + /// FPGA->Server 读响应包 /// 构造函数 /// /// 时间戳