Z21 7.1.6

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

Z21

A small, event-driven .NET client for the ROCO/Fleischmann Z21 digital command station. It speaks the Z21 LAN protocol (V1.13) over UDP, so you can drive locomotives, throw turnouts, switch track power, read CVs and query system state — and get typed events back whenever something changes on the layout.

station.LocoInfoReceived += (_, loco) =>
    Console.WriteLine($"loco {loco.LocoAddress} now at speed {loco.LocoSpeed}");

await station.ConnectAsync();
await station.TrackPowerOnAsync();
await station.DriveAsync(3, DccSpeedMode.Steps128, DrivingDirection.Forward, 40);

You get an IZ21CommandStation from the DI container. To wire it up, add one of the companion packages: Z21.DependencyInjection (Microsoft.Extensions.DependencyInjection) or Z21.Autofac (Autofac). Both expose a single AddZ21(...) call.

The full command/response support matrix and protocol notes live on the project page. Licensed under GPL-3.0.

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.  net8.0-windows7.0 is compatible.  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 (3)

Showing the top 3 NuGet packages that depend on Z21:

Package Downloads
Z21.DependencyInjection

Package Description

Z21.Autofac

Package Description

OpenSpeed.Adapter

OpenSpeed hardware adapters: REST speed-sensor client and Z21 DCC controller. Implements OpenSpeed.Core interfaces.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
7.1.6 90 6/5/2026
7.1.3 91 6/5/2026
7.1.2 92 6/5/2026
7.0.8 88 6/5/2026
7.0.6 87 6/5/2026
7.0.5 87 6/5/2026
7.0.2-g7efc542658 92 6/5/2026
6.0.3 155 5/16/2026
6.0.2 111 5/16/2026
5.0.9 116 5/16/2026
5.0.8 113 5/16/2026
5.0.6 206 1/25/2026
5.0.3 190 1/25/2026
5.0.2 198 1/25/2026
5.0.1 212 1/25/2026
5.0.0-beta.16 185 10/6/2025
5.0.0-beta.15 155 10/6/2025
5.0.0-beta.14 155 10/6/2025
4.0.0 542 5/3/2024
Loading failed