We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1f8ad3f commit 0f43203Copy full SHA for 0f43203
1 file changed
src/extensions/BootstrapBlazor.Socket/Utility/ModbusCrc16.cs
@@ -95,15 +95,15 @@ public static ReadOnlySpan<byte> Append(ReadOnlySpan<byte> data)
95
/// </summary>
96
/// <param name="dataWithCrc">包含 CRC 校验码的数据</param>
97
/// <returns>验证结果</returns>
98
- public static bool ValidateChecksum(byte[] dataWithCrc)
+ public static bool Validate(ReadOnlySpan<byte> dataWithCrc)
99
{
100
if (dataWithCrc.Length < 2)
101
102
return false;
103
}
104
105
ushort receivedCrc = (ushort)(dataWithCrc[^1] << 8 | dataWithCrc[^2]);
106
- ushort calculatedCrc = Compute(dataWithCrc.AsSpan()[..^2]);
+ ushort calculatedCrc = Compute(dataWithCrc[..^2]);
107
return receivedCrc == calculatedCrc;
108
109
0 commit comments