feat: 修改后端apiclient生成逻辑
fix: 修复debugger获取flag失败的问题 refactor: 重新编写debugger前后端逻辑
This commit is contained in:
@@ -119,18 +119,18 @@ public class DebuggerClient
|
||||
/// <summary>
|
||||
/// 设置信号捕获模式
|
||||
/// </summary>
|
||||
/// <param name="channelNum">要设置的通道</param>
|
||||
/// <param name="wireNum">要设置的线</param>
|
||||
/// <param name="mode">要设置的捕获模式</param>
|
||||
/// <returns>操作结果,成功返回true,失败返回错误信息</returns>
|
||||
public async ValueTask<Result<bool>> SetMode(byte channelNum, CaptureMode mode)
|
||||
public async ValueTask<Result<bool>> SetMode(UInt32 wireNum, CaptureMode mode)
|
||||
{
|
||||
if (channelNum > 0x0F)
|
||||
if (wireNum > 512)
|
||||
{
|
||||
return new(new ArgumentException($"Channel Num can't be over 16, but receive num: {channelNum}"));
|
||||
return new(new ArgumentException($"Wire Num can't be over 512, but receive num: {wireNum}"));
|
||||
}
|
||||
|
||||
UInt32 data = ((UInt32)mode);
|
||||
var ret = await UDPClientPool.WriteAddr(this.ep, this.taskID, DebuggerAddr.Mode + channelNum, data, this.timeout);
|
||||
var ret = await UDPClientPool.WriteAddr(this.ep, this.taskID, DebuggerAddr.Mode + wireNum, data, this.timeout);
|
||||
if (!ret.IsSuccessful)
|
||||
{
|
||||
logger.Error($"Failed to set mode: {ret.Error}");
|
||||
@@ -181,7 +181,7 @@ public class DebuggerClient
|
||||
logger.Error("ReadAddr returned invalid data for flag");
|
||||
return new(new Exception("Failed to read flag"));
|
||||
}
|
||||
return ret.Value.Options.Data[0];
|
||||
return ret.Value.Options.Data[3];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -207,30 +207,26 @@ public class DebuggerClient
|
||||
/// <summary>
|
||||
/// 从指定偏移地址读取捕获的数据
|
||||
/// </summary>
|
||||
/// <param name="offset">数据读取的偏移地址</param>
|
||||
/// <returns>操作结果,成功返回32KB的捕获数据,失败返回错误信息</returns>
|
||||
public async ValueTask<Result<byte[]>> ReadData(UInt16 offset)
|
||||
/// <param name="portNum">Port数量</param>
|
||||
/// <returns>操作结果,成功返回捕获数据,失败返回错误信息</returns>
|
||||
public async ValueTask<Result<byte[]>> ReadData(UInt32 portNum)
|
||||
{
|
||||
var captureData = new byte[1024 * 32];
|
||||
var captureData = new byte[1024 * 4 * portNum];
|
||||
{
|
||||
var ret = await UDPClientPool.ReadAddr4BytesAsync(this.ep, this.taskID, this.captureDataAddr + offset, 512, this.timeout);
|
||||
var ret = await UDPClientPool.ReadAddr4BytesAsync(this.ep, this.taskID, this.captureDataAddr, captureData.Length, this.timeout);
|
||||
if (!ret.IsSuccessful)
|
||||
{
|
||||
logger.Error($"Failed to read data: {ret.Error}");
|
||||
return new(ret.Error);
|
||||
}
|
||||
|
||||
Buffer.BlockCopy(ret.Value, 0, captureData, 0, 512 * 4);
|
||||
}
|
||||
{
|
||||
var ret = await UDPClientPool.ReadAddr4BytesAsync(this.ep, this.taskID, this.captureDataAddr + offset + 512, 512, this.timeout);
|
||||
if (!ret.IsSuccessful)
|
||||
if (ret.Value.Length != captureData.Length)
|
||||
{
|
||||
logger.Error($"Failed to read data: {ret.Error}");
|
||||
return new(ret.Error);
|
||||
logger.Error($"Receive capture data length should be {captureData.Length} instead of {ret.Value.Length}");
|
||||
return new(new Exception($"Receive capture data length should be {captureData.Length} instead of {ret.Value.Length}"));
|
||||
}
|
||||
|
||||
Buffer.BlockCopy(ret.Value, 0, captureData, 512 * 4, 512 * 4);
|
||||
Buffer.BlockCopy(ret.Value, 0, captureData, 0, captureData.Length);
|
||||
}
|
||||
|
||||
return captureData;
|
||||
|
||||
Reference in New Issue
Block a user