CSoft.Parser
11.0.3
.NET 8.0
This package targets .NET 8.0. The package is compatible with this framework or higher.
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
dotnet add package CSoft.Parser --version 11.0.3
NuGet\Install-Package CSoft.Parser -Version 11.0.3
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CSoft.Parser" Version="11.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CSoft.Parser" Version="11.0.3" />
<PackageReference Include="CSoft.Parser" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CSoft.Parser --version 11.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CSoft.Parser, 11.0.3"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CSoft.Parser@11.0.3
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CSoft.Parser&version=11.0.3
#tool nuget:?package=CSoft.Parser&version=11.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
CSoft.Parser
把串口、TCP 等来源的连续字节拆成协议帧,通过 OnReceiveParsedData 交付 byte[]。可从 PipeReader 连续读取,也可直接提交字节块。
安装
dotnet add package CSoft.Parser --version 11.0.3
包含 .NET 8、.NET 9、.NET 10、.NET 11 和 .NET Standard 2.0 目标。.NET Framework 4.8 使用 .NET Standard 2.0 资产。
选择分帧方式
| 类型 | 适用边界 |
|---|---|
HeadFootParser |
固定帧头和帧尾,输出包含两者。 |
FootParser |
仅用分隔符或帧尾结束,输出包含帧尾。 |
HeadLengthParser |
根据长度回调确定一帧长度,可有固定帧头。 |
TimeParser |
接收空闲超过指定毫秒数时输出一帧,默认 20 毫秒。使用后调用 Dispose()。 |
NoParser |
原样交付非空数据块,块边界取决于输入或底层读取。 |
最小示例
将以下代码放入 .NET 8 或更新版本的控制台项目。两次输入组成一帧,输出 AA-01-BB。
using System;
using System.Threading.Tasks;
using Parser.Parsers;
var parser = new HeadFootParser(
new byte[] { 0xAA }, new byte[] { 0xBB }, useChannel: false);
parser.OnReceiveParsedData += frame =>
{
Console.WriteLine(BitConverter.ToString(frame));
return Task.CompletedTask;
};
await parser.ReceiveOriginalDataAsync(new byte[] { 0xAA, 0x01 });
await parser.ReceiveOriginalDataAsync(new byte[] { 0xBB });
接入真实数据流
- 使用
RunAsync(reader, cancellationToken)从PipeReader持续分帧。内置解析器退出时会完成读取器。每条独立字节流使用自己的解析器实例,以免混用半帧或回调。 HeadFootParser、FootParser和HeadLengthParser默认用有界队列分发。提交数据后,回调可能仍在后台处理。需要等待当次分帧回调时,可用useChannel: false。- 带帧头的
HeadLengthParser默认让长度回调看到含帧头的候选数据,成功时Length为整帧字节数。使用haveHeadOfData: false时,回调看到帧头之后的数据,Length也按帧头之后的字节数计算。长度字段还未收齐时返回StateCode.LengthNotEnough。 - 需要自定义边界时,可继承
BaseParser并实现帧头、帧尾定位,或直接实现Parser.Interfaces.IParser。
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. net11.0 is compatible. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- CSoft.LogInterface (>= 11.0.0)
- CSoft.Utils (>= 11.0.1)
- System.IO.Pipelines (>= 11.0.0)
- System.Memory (>= 4.6.3)
- System.Threading.Channels (>= 11.0.0)
-
net10.0
- CSoft.LogInterface (>= 11.0.0)
- CSoft.Utils (>= 11.0.1)
-
net11.0
- CSoft.LogInterface (>= 11.0.0)
- CSoft.Utils (>= 11.0.1)
-
net8.0
- CSoft.LogInterface (>= 11.0.0)
- CSoft.Utils (>= 11.0.1)
- System.IO.Pipelines (>= 10.0.15)
-
net9.0
- CSoft.LogInterface (>= 11.0.0)
- CSoft.Utils (>= 11.0.1)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on CSoft.Parser:
| Package | Downloads |
|---|---|
|
CSoft.TopPortLib
通信口使用类库 |
|
|
CSoft.Communication
通信物理口封装 |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 11.0.3 | 104 | 11/13/2026 |
| 11.0.2 | 47 | 11/13/2026 |
| 11.0.1 | 146 | 11/12/2026 |
| 11.0.0 | 97 | 11/12/2026 |
| 10.6.2 | 2,236 | 5/28/2026 |
| 10.6.1 | 391 | 5/28/2026 |
| 10.6.0 | 528 | 5/27/2026 |
| 10.5.1 | 481 | 5/25/2026 |
| 10.5.0 | 483 | 5/25/2026 |
| 10.4.10 | 580 | 5/19/2026 |
| 10.4.9 | 480 | 5/19/2026 |
| 10.4.8 | 384 | 5/18/2026 |
| 10.4.7 | 356 | 5/18/2026 |
| 10.4.6 | 407 | 5/15/2026 |
| 10.4.5 | 410 | 5/14/2026 |
| 10.4.3 | 345 | 5/14/2026 |
| 10.4.1 | 441 | 5/11/2026 |
| 10.4.0 | 351 | 5/11/2026 |
| 10.3.1 | 351 | 5/7/2026 |
| 10.3.0 | 389 | 5/7/2026 |
Loading failed
与 Communication 11.0.3 同步发包,继续提供 .NET 8、9、10、11 和 .NET Standard 2.0 目标。