Oakrey.Acroname.Devices 3.0.3

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

Oakrey.Acroname.Devices

Higher-level .NET 10 device abstraction for the Acroname USBCSwitch. Sits on top of Oakrey.Acroname and exposes a clean interface (IProgrammable4PortUSBSwitchForUSBC) for port switching, 4-channel USB-C mux control, and real-time voltage and current measurement. Intended for use in application code or as a dependency-injection-friendly testable abstraction.

Main features

  • IProgrammable4PortUSBSwitchForUSBC � interface suitable for DI registration and mocking.
  • Programmable4PortUSBSwitchForUSBC � concrete implementation backed by Oakrey.Acroname.
  • Port enable / disable on the common USB-C port.
  • Mux enable / disable and channel selection across channels 0-3.
  • Query the currently active mux channel.
  • Read port voltage and current (volts / amperes).
  • Read per-channel voltage.
  • Channel index validated at the managed layer � throws ArgumentOutOfRangeException before reaching the native SDK when the value is outside 0-3.

Architecture

graph TD
    A[Consumer application] --> B[IProgrammable4PortUSBSwitchForUSBC]
    B --> C[Programmable4PortUSBSwitchForUSBC<br>Oakrey.Acroname.Devices]
    C --> D[USBCSwitch<br>Oakrey.Acroname wrapper]
    D --> E[BrainStem2.dll <br> Acroname native SDK]

Key types

Type Role
IProgrammable4PortUSBSwitchForUSBC Public contract; use this type in application code
Programmable4PortUSBSwitchForUSBC Concrete implementation; register against the interface in DI

Requirements

  • .NET 10 or higher
  • Windows x64
  • Oakrey.Acroname NuGet package (pulled in automatically as a transitive dependency)
  • No additional runtime installation � native DLLs are bundled inside Oakrey.Acroname

Installation

.NET CLI

dotnet add package Oakrey.Acroname.Devices

Package Manager Console

Install-Package Oakrey.Acroname.Devices

NuGet Package Manager

Search for Oakrey.Acroname.Devices in Tools > NuGet Package Manager > Manage NuGet Packages for Solution.

Example usage

using Oakrey.Acroname.Devices;

// Connect to the first discovered USBCSwitch
IProgrammable4PortUSBSwitchForUSBC sw = new Programmable4PortUSBSwitchForUSBC();

// Connect to a specific device by serial number
IProgrammable4PortUSBSwitchForUSBC swById = new Programmable4PortUSBSwitchForUSBC(0x12345678);

// Port and mux control
sw.PortEnable();
sw.MuxEnable();
sw.MuxSelect(2);              // channels 0-3

int active = sw.GetSelectedMux();
bool enabled = sw.IsMuxEnabled(2);

// Telemetry
double voltage = sw.GetPortVoltage();        // volts
double current = sw.GetPortCurrent();        // amperes
double ch2V    = sw.GetChannelVoltage(2);    // volts

// Tear down
sw.PortDisable();
sw.MuxDisable();

Dependency injection

// Registration (e.g. in a host builder)
services.AddSingleton<IProgrammable4PortUSBSwitchForUSBC>(
    _ => new Programmable4PortUSBSwitchForUSBC());

// Consumer
public class MyService(IProgrammable4PortUSBSwitchForUSBC sw)
{
    public void Run() => sw.PortEnable();
}

API reference

Method Description
PortEnable() Enable the common USB-C port
PortDisable() Disable the common USB-C port
MuxEnable() Enable the mux
MuxDisable() Disable the mux
MuxSelect(int channel) Select active mux channel (0-3)
IsMuxEnabled(int channel) Returns true if the given channel is enabled
GetSelectedMux() Returns the currently selected mux channel index
GetPortVoltage() Port voltage in volts
GetPortCurrent() Port current in amperes
GetChannelVoltage(int channel) Per-channel voltage in volts (0-3)

Error handling

Channel range is validated before touching the device. Any BrainStem2 hardware error surfaces as AcronameException (defined in Oakrey.Acroname).

try
{
    sw.MuxSelect(5); // throws ArgumentOutOfRangeException immediately
}
catch (ArgumentOutOfRangeException ex)
{
    Console.WriteLine(ex.Message);
}

try
{
    sw.PortEnable();
}
catch (Oakrey.Acroname.Wrapper.AcronameException ex)
{
    Console.WriteLine($"BrainStem2 error {ex.ErrorCode}: {ex.Message}");
}

Development notes

  • This package is a thin managed shim. All device I/O is delegated to Oakrey.Acroname; there is no direct native interop in this assembly.
  • The interface is designed to be mockable for unit testing without physical hardware.
  • Programmable4PortUSBSwitchForUSBC does not implement IDisposable because the underlying USBCSwitch connects and disconnects per-call. No persistent connection is held.

License

MIT - Copyright (c) Oakrey 2016-present

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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

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
3.0.3 91 5/15/2026
3.0.2 92 5/14/2026
3.0.1 130 2/2/2026
3.0.0 286 11/14/2025
2.0.0 254 6/4/2025
1.1.0 237 5/28/2025
1.0.0 226 5/28/2025