feat: add jtag boundary scan
This commit is contained in:
		@@ -41,7 +41,7 @@ namespace Common
 | 
			
		||||
            0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
 | 
			
		||||
            0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
 | 
			
		||||
        };
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 整数转成二进制字节数组
 | 
			
		||||
        /// </summary>
 | 
			
		||||
@@ -167,6 +167,26 @@ namespace Common
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// [TODO:description]
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="uintArray">[TODO:parameter]</param>
 | 
			
		||||
        /// <returns>[TODO:return]</returns>
 | 
			
		||||
        public static Result<byte[]> 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);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 比特合并成二进制字节
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,4 @@
 | 
			
		||||
using System.Collections;
 | 
			
		||||
using System.Net;
 | 
			
		||||
using DotNext;
 | 
			
		||||
using Newtonsoft.Json;
 | 
			
		||||
@@ -368,21 +369,6 @@ public class JtagStatusReg
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// [TODO:description]
 | 
			
		||||
/// </summary>
 | 
			
		||||
public class JtagBoundaryRegister
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// [TODO:description]
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public int PortNum { get; set; }
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// [TODO:description]
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public UInt32[] PortStatus { get; set; } = new UInt32[] { };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Jtag控制器
 | 
			
		||||
/// </summary>
 | 
			
		||||
@@ -945,7 +931,7 @@ public class Jtag
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    /// <param name="portNum">[TODO:parameter]</param>
 | 
			
		||||
    /// <returns>[TODO:return]</returns>
 | 
			
		||||
    public async ValueTask<Result<JtagBoundaryRegister>> BoundaryScan(int portNum)
 | 
			
		||||
    public async ValueTask<Result<BitArray>> 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);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user