Chdef 0.0.8

There is a newer version of this package available.
See the version list below for details.
dotnet add package Chdef --version 0.0.8
                    
NuGet\Install-Package Chdef -Version 0.0.8
                    
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="Chdef" Version="0.0.8" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Chdef" Version="0.0.8" />
                    
Directory.Packages.props
<PackageReference Include="Chdef" />
                    
Project file
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 Chdef --version 0.0.8
                    
#r "nuget: Chdef, 0.0.8"
                    
#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 Chdef@0.0.8
                    
#: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=Chdef&version=0.0.8
                    
Install as a Cake Addin
#tool nuget:?package=Chdef&version=0.0.8
                    
Install as a Cake Tool

chdef

🌐 English | 日本語

CI License: MIT OR Apache-2.0

Channel definitions (CH) and bit-field definitions (BF) for binary frames: parse the CSVs, compute the layout, convert raw ↔ physical.

⚠ Pre-alpha (0.0.x). The API and the CSV rules are still moving; until 0.1.0 lands, patch releases may break either.


What it is

A CH definition (channel definition CSV) gives every field of a binary frame a meaning; a BF definition (bit-field definition CSV) gives every bit of a BF-typed channel a name. chdef is the one Rust implementation of both, so that every consumer reads the same file the same way.

  • Parse a CH CSV / BF CSV — a column has one canonical name (number,bytes,…) and every other spelling a header may use is a vocabulary you supply, so a header in any language is read by teaching its spellings; a leading BOM is ignored and rows without an integer number are skipped
  • Compute the frame layout (each channel sits at the cumulative bytes, plus the total byte count)
  • Convert raw ↔ physical: value = raw × lsb + offset and back (lsb 0 / empty is 1, SI is signed, endianness selectable, rounding half away from zero, clamped to the channel width)
// The canonical names, with no vocabulary at all.
let channels = chdef::parse_ch_csv(ch_csv_text)?;
let bitfields = chdef::parse_bf_csv(bf_csv_text)?;
let layout = chdef::build_layout(channels, bitfields);
let value = layout.channels[0].raw_to_value(&frame[..4]);
let bytes = layout.channels[0].value_to_bytes(value);

A header in another vocabulary — one chdef ships, or one you build — is read the same way:

let japanese = chdef::ColumnVocabulary::japanese();
let german = chdef::ColumnVocabulary::new()
    .ch("Nummer", chdef::ChColumn::Number)
    .ch("Bytes", chdef::ChColumn::Bytes);

let channels = chdef::parse_ch_csv_with(ch_csv_text, &japanese)?;

The columns of both CSVs, their canonical names, and how each cell is read are specified in docs/spec/format.md.

The specification lives in docs/spec/; design decisions in docs/decisions/.

From C# and C

The same implementation, reached through a C ABI. What crosses it is every rule the specification states, so a consumer in another language never writes one of them a second time (docs/spec/abi.md).

dotnet add package Chdef

The NuGet package carries the native library for linux-x64, win-x64, osx-arm64 and osx-x64, so nothing else is needed.

using var defs = Definitions.Parse(chCsv, bfCsv);
var frame = defs.Encode([Value.Parse("0x0004", 1)], out var issues);
foreach (var reading in defs.Decode(frame))
{
    foreach (var bit in reading.Bits) { /* name and value of each bit */ }
}

using var grid = Grid.Parse(File.ReadAllBytes(path));
grid.SetCell(0, 1, "4");
File.WriteAllBytes(path, grid.ToCsvBytes());

For C, the header is crates/chdef-capi/include/chdef.h and the library is the chdef-capi crate built as a cdylib.

Origin

The CH / BF concept was extracted from chbridge-core of chbridge, an internal telemetry bridge. Definition files themselves (real-device channel tables) belong to each consumer; this repository holds synthetic data only.

License

Licensed under either of

at your option.

Product Compatible and additional computed target framework versions.
.NET 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 was computed.  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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.16 136 8/28/2026
0.0.15 119 8/26/2026
0.0.14 125 8/25/2026
0.0.13 123 8/25/2026
0.0.12 113 8/25/2026
0.0.11 117 8/25/2026
0.0.10 112 8/25/2026
0.0.9 121 8/25/2026
0.0.8 122 8/25/2026
0.0.7 126 8/24/2026
0.0.5 112 8/24/2026
0.0.4 110 8/24/2026
0.0.3 125 8/24/2026