fix: 修复由于基本的通信协议更改不完全导致的无法控制电源与jtag的问题

This commit is contained in:
SikongJueluo 2025-08-21 19:19:56 +08:00
parent 8ab55f411d
commit e3b7cc4f63
4 changed files with 20 additions and 19 deletions

View File

@ -183,7 +183,7 @@ public class JtagController : ControllerBase
logger.Info($"User {username} processing bitstream file of size: {fileBytes.Length} bytes"); 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); _tracker.AdvanceProgress(taskId, 10);
_ = Task.Run(async () => _ = Task.Run(async () =>

View File

@ -756,7 +756,7 @@ public class Jtag
logger.Trace("Jtag ready to write bitstream"); logger.Trace("Jtag ready to write bitstream");
ret = await IdleDelay(100000); ret = await IdleDelay(1000);
if (!ret.IsSuccessful) return new(ret.Error); if (!ret.IsSuccessful) return new(ret.Error);
else if (!ret.Value) return new(new Exception("Jtag IDLE Delay Failed")); else if (!ret.Value) return new(new Exception("Jtag IDLE Delay Failed"));
_progressTracker.AdvanceProgress(progressId, 10); _progressTracker.AdvanceProgress(progressId, 10);
@ -784,7 +784,7 @@ public class Jtag
logger.Trace("Jtag reset device"); logger.Trace("Jtag reset device");
ret = await IdleDelay(10000); ret = await IdleDelay(1000);
if (!ret.IsSuccessful) return new(ret.Error); if (!ret.IsSuccessful) return new(ret.Error);
else if (!ret.Value) return new(new Exception("Jtag IDLE Delay Failed")); else if (!ret.Value) return new(new Exception("Jtag IDLE Delay Failed"));
_progressTracker.AdvanceProgress(progressId, 10); _progressTracker.AdvanceProgress(progressId, 10);

View File

@ -436,7 +436,7 @@ public class UDPServer
} }
var udpDataObj = await RecordUDPData(data, endPoint, time, Convert.ToInt32(data[1 + 4])); var udpDataObj = await RecordUDPData(data, endPoint, time, Convert.ToInt32(data[1 + 4]));
// PrintData(udpDataObj); PrintData(udpDataObj);
} }
catch (Exception e) catch (Exception e)
{ {

View File

@ -131,7 +131,7 @@ namespace WebProtocol
readonly byte sign = (byte)PackSign.SendAddr; readonly byte sign = (byte)PackSign.SendAddr;
readonly byte commandType; readonly byte commandType;
readonly byte burstLength; readonly byte burstLength;
readonly byte _reserved = 0; readonly byte commandID;
readonly UInt32 address; readonly UInt32 address;
/// <summary> /// <summary>
@ -140,10 +140,10 @@ namespace WebProtocol
/// <param name="opts"> 地址包选项 </param> /// <param name="opts"> 地址包选项 </param>
public SendAddrPackage(SendAddrPackOptions opts) public SendAddrPackage(SendAddrPackOptions opts)
{ {
byte byteBurstType = Convert.ToByte((byte)opts.BurstType << 6); byte byteBurstType = Convert.ToByte((byte)opts.BurstType << 4);
byte byteCommandID = Convert.ToByte((opts.CommandID & 0x03) << 4);
byte byteIsWrite = (opts.IsWrite ? (byte)0x01 : (byte)0x00); 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.burstLength = opts.BurstLength;
this.address = opts.Address; this.address = opts.Address;
} }
@ -158,10 +158,10 @@ namespace WebProtocol
/// <param name="address"> 设备地址 </param> /// <param name="address"> 设备地址 </param>
public SendAddrPackage(BurstType burstType, byte commandID, bool isWrite, byte burstLength, UInt32 address) public SendAddrPackage(BurstType burstType, byte commandID, bool isWrite, byte burstLength, UInt32 address)
{ {
byte byteBurstType = Convert.ToByte((byte)burstType << 6); byte byteBurstType = Convert.ToByte((byte)burstType << 4);
byte byteCommandID = Convert.ToByte((commandID & 0x03) << 4);
byte byteIsWrite = (isWrite ? (byte)0x01 : (byte)0x00); 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.burstLength = burstLength;
this.address = address; this.address = address;
} }
@ -172,9 +172,10 @@ namespace WebProtocol
/// <param name="commandType">二进制命令类型</param> /// <param name="commandType">二进制命令类型</param>
/// <param name="burstLength">突发长度</param> /// <param name="burstLength">突发长度</param>
/// <param name="address">写入或读取的地址</param> /// <param name="address">写入或读取的地址</param>
public SendAddrPackage(byte commandType, byte burstLength, UInt32 address) public SendAddrPackage(byte commandType, byte burstLength, byte commandID, UInt32 address)
{ {
this.commandType = commandType; this.commandType = commandType;
this.commandID = commandID;
this.burstLength = burstLength; this.burstLength = burstLength;
this.address = address; this.address = address;
} }
@ -190,8 +191,8 @@ namespace WebProtocol
{ {
Address = this.address, Address = this.address,
BurstLength = this.burstLength, BurstLength = this.burstLength,
BurstType = (BurstType)(this.commandType >> 6), BurstType = (BurstType)(this.commandType >> 4),
CommandID = Convert.ToByte((this.commandType >> 4) & 0b11), CommandID = this.commandID,
IsWrite = Convert.ToBoolean(this.commandType & 1) IsWrite = Convert.ToBoolean(this.commandType & 1)
}; };
} }
@ -207,7 +208,7 @@ namespace WebProtocol
arr[0] = sign; arr[0] = sign;
arr[1] = commandType; arr[1] = commandType;
arr[2] = burstLength; arr[2] = burstLength;
arr[3] = _reserved; arr[3] = commandID;
var bytesAddr = Common.Number.NumberToBytes(address, 4).Value; var bytesAddr = Common.Number.NumberToBytes(address, 4).Value;
Array.Copy(bytesAddr, 0, arr, 4, bytesAddr.Length); Array.Copy(bytesAddr, 0, arr, 4, bytesAddr.Length);
@ -223,8 +224,8 @@ namespace WebProtocol
{ {
var opts = new SendAddrPackOptions() var opts = new SendAddrPackOptions()
{ {
BurstType = (BurstType)(commandType >> 6), BurstType = (BurstType)(commandType >> 4),
CommandID = Convert.ToByte((commandType >> 4) & 0b0011), CommandID = this.commandID,
IsWrite = Convert.ToBoolean(commandType & 0x01), IsWrite = Convert.ToBoolean(commandType & 0x01),
BurstLength = burstLength, BurstLength = burstLength,
Address = address, Address = address,
@ -258,7 +259,7 @@ namespace WebProtocol
} }
var address = Common.Number.BytesToUInt64(bytes[4..]).Value; 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; readonly byte[] bodyData;
/// <summary> /// <summary>
/// FPGA->Server 读响应包 /// FPGA->Server 读响应包
/// 构造函数 /// 构造函数
/// </summary> /// </summary>
/// <param name="timestamp"> 时间戳 </param> /// <param name="timestamp"> 时间戳 </param>