Skip to content

Latest commit

 

History

History
57 lines (42 loc) · 2.08 KB

File metadata and controls

57 lines (42 loc) · 2.08 KB

SharpMeter

A modern, high-performance .NET library for smart meter communication supporting both ANSI C12.18/C12.19 PSEM and DLMS/COSEM (IEC 62056) protocols.

Features

  • Dual protocol: ANSI PSEM and DLMS/COSEM in a single library
  • Fully async with CancellationToken support
  • Zero-allocation hot paths with Span<T>, ArrayPool<T>, System.IO.Pipelines
  • Pluggable ITransport interface (serial, TCP, loopback, custom)
  • Table deserialization: fluent builder, attribute mapping, or JSON schema
  • Built-in PSEM meter emulator with configurable tables and security
  • Result<T> discriminated union — no exceptions for control flow
  • IAsyncEnumerable for streaming large table reads
  • Source-generated ILogger<T> integration
  • Multi-target: net9.0 and net10.0

Packages

Package Description
SharpMeter.Core Protocol types, CRC-16, Result<T>, enums, table definitions and deserializer
SharpMeter.Transport ITransport interface, serial, TCP, and loopback transports
SharpMeter.Client PSEM client — session, table, and procedure services
SharpMeter.Dlms DLMS/COSEM — HDLC framing, OBIS codes, A-XDR codec, GET/SET/ACTION
SharpMeter.Emulator Full PSEM meter emulator with in-memory table store

Quick Start

using SharpMeter.Client;
using SharpMeter.Core.Tables;
using SharpMeter.Transport;

await using var transport = new SerialTransport(
    new TransportOptions { PortName = "COM3" },
    NullLogger<SerialTransport>.Instance);

await using var client = new PsemClient(transport, NullLogger<PsemClient>.Instance);
await client.ConnectAsync();

// Read and deserialize a table
var table = await client.ReadTableAsync(1);
var registry = new TableRegistry();
var parsed = registry.Deserialize(1, table.Value.Data);
Console.WriteLine(parsed.Value.GetValue("MANUFACTURER"));

await client.DisconnectAsync();

Documentation

Full docs at jacobwi.github.io/SharpMeter

License

MIT — See GitHub for source and documentation.