fix: 修复Debugger处理数据时,最终转化为字节时出现的转化问题

This commit is contained in:
SikongJueluo 2025-07-31 14:30:30 +08:00
parent d27b5d7737
commit d1f276096b
No known key found for this signature in database
1 changed files with 4 additions and 3 deletions

View File

@ -406,13 +406,14 @@ public class DebuggerController : ControllerBase
return StatusCode(StatusCodes.Status500InternalServerError, "数据越界");
}
var sampleBytes = rawData[sampleOffset..(sampleOffset + 4)];
UInt32 sample = BitConverter.ToUInt32(Common.Number.ReverseBytes(sampleBytes, 4).Value, 0);
UInt32 sample = Common.Number.BytesToUInt32(sampleBytes, true).Value;
// 提取wireWidth位
UInt32 mask = (wireWidth == 32) ? 0xFFFFFFFF : ((1u << wireWidth) - 1u);
channelUintArr[i] = (sample >> wireStart) & mask;
}
logger.Debug($"{channel.name} HexData: {BitConverter.ToString(channelUintArr.SelectMany(BitConverter.GetBytes).ToArray())}");
var base64 = Convert.ToBase64String(channelUintArr.SelectMany(BitConverter.GetBytes).ToArray());
var channelBytes = channelUintArr.SelectMany(x => Common.Number.NumberToBytes(x, 4).Value).ToArray();
logger.Debug($"{channel.name} HexData: {BitConverter.ToString(channelBytes)}");
var base64 = Convert.ToBase64String(channelBytes);
channelDataList.Add(new ChannelCaptureData { name = channel.name, data = base64 });
}