Pamoja.Can 0.1.17

dotnet add package Pamoja.Can --version 0.1.17
                    
NuGet\Install-Package Pamoja.Can -Version 0.1.17
                    
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="Pamoja.Can" Version="0.1.17" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Pamoja.Can" Version="0.1.17" />
                    
Directory.Packages.props
<PackageReference Include="Pamoja.Can" />
                    
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 Pamoja.Can --version 0.1.17
                    
#r "nuget: Pamoja.Can, 0.1.17"
                    
#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 Pamoja.Can@0.1.17
                    
#: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=Pamoja.Can&version=0.1.17
                    
Install as a Cake Addin
#tool nuget:?package=Pamoja.Can&version=0.1.17
                    
Install as a Cake Tool

Pamoja.Can

CAN 2.0 and CAN-FD frames with 11- and 29-bit identifiers, plus J1939 decode and compose. One capability of pamoja, one memory-safe Rust core with bindings for TypeScript, Python, and C#.

API reference read the guide documentation

Install

dotnet add package Pamoja.Can
using Pamoja.Can;

This pulls in Pamoja.Native, the compiled engine. dotnet add package Pamoja is the whole framework in one package.

Example

The guide project's example, spliced here as it ran in CI.

From bindings/dotnet/samples/Pamoja.Guides/CanGuide.cs:

// The nodes on this bus, by the address each answers to, and the two parameter
// groups in play. J1939 publishes both, so naming them makes the traffic readable.
const byte Engine = 0;
const byte Gateway = 1;
const byte Gearbox = 33;
const uint EngineController1 = 61_444; // carries engine speed
const uint Request = 59_904; // asks another node for a parameter group

// Where engine speed sits inside that group, and the scale the standard fixes for
// it. Naming both is what stops a sender and a receiver disagreeing about either.
const int EngineSpeedAt = 3;
const double RpmPerBit = 0.125;

// J1939 keeps its addressing inside the CAN identifier: a priority, the parameter
// group, and the address of whatever sent it. A broadcast has no destination, so
// it is its own constructor rather than a magic address a caller has to know.
uint speedId = Can.BroadcastJ1939(J1939Priority.Control, EngineController1, Engine);
J1939Message speed = Can.DecodeJ1939(speedId)!;
Console.WriteLine($"broadcast pgn {speed.Pgn} at priority {speed.Priority}");

// A parameter group below the PDU1 limit is addressed rather than broadcast, so
// those eight identifier bits carry a destination instead of extending the group.
uint requestId = Can.ComposeJ1939((byte)J1939Priority.Normal, Request, Gateway, Gearbox);
Console.WriteLine($"request   pgn {Request} addressed to node {Gearbox}");

// Reading one back off the bus is the same thing in reverse, so a receiver never
// unpacks 29 bits by hand.
J1939Message heard = Can.DecodeJ1939(requestId)!;
Console.WriteLine($"heard     from node {heard.Source} for node {heard.Destination}");

// The payload. Every signal starts marked not available, and this controller
// reports only engine speed, so that is the only one it writes.
Signals reported = Signals.New();
reported.SetU16(EngineSpeedAt, (ushort)(1000 / RpmPerBit));
CanFrame eec1 = Can.Frame(speedId, reported.ToArray(), extended: true);

// The receiving node reads the same offset back, so neither end slices the payload.
double rpm = Signals.From(eec1.Data).U16(EngineSpeedAt)!.Value * RpmPerBit;
Console.WriteLine($"engine    {rpm} rpm, carried in {eec1.Dlc} bytes");

// Above eight bytes CAN-FD encodes the length in steps rather than exactly, and a
// classic frame still refuses a ninth byte.
CanFrame wide = Can.FdFrame(speedId, new byte[32], extended: true);
Console.WriteLine($"32 bytes carries length code {wide.Dlc}");
try
{
    Can.Frame(speedId, new byte[9], extended: true);
    Console.WriteLine("a classic frame took nine bytes, which should never happen");
}
catch (PamojaException error)
{
    Console.WriteLine($"classic   refused nine bytes: {error.Message}");
}

// J1939 never rides an 11-bit identifier, so a standard frame is not one of its
// messages however its bits happen to line up.
Console.WriteLine($"an 11-bit identifier is J1939: {Can.DecodeJ1939(291, false) is not null}");

The same capability in every language

Language Package Reference
Rust pamoja-can reference, docs.rs, install
TypeScript @pamoja/can reference, install
Python pamoja-can reference, install
C# Pamoja.Can reference, install

Documentation

License

MIT

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.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Pamoja.Can:

Package Downloads
Pamoja

The whole pamoja framework in one package: every capability of one memory-safe Rust core, behind an idiomatic C# facade, for IoT, robotics, and drones.

Pamoja.FieldIo

Field I/O: The wires a gateway actually has: framed serial packets, an RS485 request and the reply it draws, a CAN frame, and the address a chip answers on.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.17 94 9/6/2026
0.1.16 93 9/5/2026
0.1.15 86 9/5/2026