diff --git a/server/src/Common.cs b/server/src/Common.cs index 37abf92..edf3245 100644 --- a/server/src/Common.cs +++ b/server/src/Common.cs @@ -41,7 +41,7 @@ namespace Common 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff }; - + /// /// 整数转成二进制字节数组 /// @@ -167,6 +167,26 @@ namespace Common } + /// + /// [TODO:description] + /// + /// [TODO:parameter] + /// [TODO:return] + public static Result UInt32ArrayToBytes(UInt32[] uintArray) + { + byte[] byteArray = new byte[uintArray.Length * 4]; + try + { + Buffer.BlockCopy(uintArray, 0, byteArray, 0, uintArray.Length * 4); + return byteArray; + } + catch (Exception error) + { + return new(error); + } + } + + /// /// 比特合并成二进制字节 diff --git a/server/src/JtagClient.cs b/server/src/JtagClient.cs index afb5de6..2153ec3 100644 --- a/server/src/JtagClient.cs +++ b/server/src/JtagClient.cs @@ -1,3 +1,4 @@ +using System.Collections; using System.Net; using DotNext; using Newtonsoft.Json; @@ -368,21 +369,6 @@ public class JtagStatusReg } } -/// -/// [TODO:description] -/// -public class JtagBoundaryRegister -{ - /// - /// [TODO:description] - /// - public int PortNum { get; set; } - /// - /// [TODO:description] - /// - public UInt32[] PortStatus { get; set; } = new UInt32[] { }; -} - /// /// Jtag控制器 /// @@ -945,7 +931,7 @@ public class Jtag /// /// [TODO:parameter] /// [TODO:return] - public async ValueTask> BoundaryScan(int portNum) + public async ValueTask> BoundaryScan(int portNum) { if (portNum <= 0) return new(new ArgumentException("The number of port couldn't be negative", nameof(portNum))); @@ -979,6 +965,8 @@ public class Jtag if (!ret.IsSuccessful) return new(ret.Error); else if (!ret.Value) return new(new Exception("Jtag Close Test Failed")); - return new JtagBoundaryRegister() { PortNum = portNum, PortStatus = retData.Value }; + var byteArray = Common.Number.UInt32ArrayToBytes(retData.Value); + if (!byteArray.IsSuccessful) return new(byteArray.Error); + return new BitArray(byteArray.Value); } }