Pamoja.Modbus
0.1.17
dotnet add package Pamoja.Modbus --version 0.1.17
NuGet\Install-Package Pamoja.Modbus -Version 0.1.17
<PackageReference Include="Pamoja.Modbus" Version="0.1.17" />
<PackageVersion Include="Pamoja.Modbus" Version="0.1.17" />
<PackageReference Include="Pamoja.Modbus" />
paket add Pamoja.Modbus --version 0.1.17
#r "nuget: Pamoja.Modbus, 0.1.17"
#:package Pamoja.Modbus@0.1.17
#addin nuget:?package=Pamoja.Modbus&version=0.1.17
#tool nuget:?package=Pamoja.Modbus&version=0.1.17
Pamoja.Modbus
Modbus RTU requests and replies with CRC-16/MODBUS for RS485 field devices. One capability of pamoja, one memory-safe Rust core with bindings for TypeScript, Python, and C#.
Install
dotnet add package Pamoja.Modbus
using Pamoja.Modbus;
This pulls in Pamoja.Native, the compiled engine, and Pamoja.Codec. 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/ModbusGuide.cs:
// The device this gateway polls: a power meter at unit 17, whose manual says the
// three registers holding voltage, current and a fault word start at address 107.
const byte Meter = 17;
const ushort FirstRegister = 107;
// Ask it for those three registers. The frame is complete, checksum included,
// exactly as it goes out on the wire.
byte[] request = Modbus.ReadHoldingRegisters(Meter, FirstRegister, 3);
Console.WriteLine($"polling unit {Meter}, {request.Length} bytes out");
// A stand-in for the meter. On a running gateway this frame arrives over RS485;
// here the library builds what a meter reporting those values would send back.
byte[] fromTheMeter = Modbus.ReadHoldingRegistersReply(Meter, [2301, 418, 0]);
// Everything below is the gateway's own code. A reply carries its own checksum,
// so the frame is validated before any value is read out of it.
ModbusFrame reply = Modbus.ParseFrame(fromTheMeter);
ushort[] registers = reply.Registers();
Console.WriteLine($"voltage {registers[0] / 10.0:F1} V");
Console.WriteLine($"current {registers[1] / 100.0:F2} A");
Console.WriteLine($"faults {registers[2]}");
// One flipped bit anywhere in the frame fails the checksum, which is the whole
// point of carrying one over a long RS485 run.
byte[] mangled = [.. fromTheMeter];
mangled[2] ^= 0xFF;
try
{
Modbus.ParseFrame(mangled);
Console.WriteLine("mangled frame accepted, which should never happen");
}
catch (PamojaException error)
{
Console.WriteLine($"mangled frame rejected: {error.Message}");
}
The same capability in every language
| Language | Package | Reference |
|---|---|---|
| Rust | pamoja-modbus |
reference, docs.rs, install |
| TypeScript | @pamoja/modbus |
reference, install |
| Python | pamoja-modbus |
reference, install |
| C# | Pamoja.Modbus |
reference, install |
Documentation
Pamoja.Modbusreference, every type in this namespace.- The Modbus RTU guide, with the same example in Rust, TypeScript, and Python.
- Every capability, and the install page.
License
MIT
| Product | Versions 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. |
-
net8.0
- Pamoja.Codec (>= 0.1.17)
- Pamoja.Native (>= 0.1.17)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Pamoja.Modbus:
| 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.