Oakrey.Acroname 2.0.2

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

Oakrey.Acroname

Managed .NET wrapper around the Acroname BrainStem2 native SDK. Enables .NET 10 applications to control the Acroname USBCSwitch over USB � port switching, mux selection, and real-time voltage and current measurement � without writing any native or C++/CLI code directly.

Main features

  • Control the USB-C port on the Acroname USBCSwitch (enable / disable).
  • Enable, disable, and select any of the four USB-C mux channels (Ch0-Ch3).
  • Query which mux channel is currently active.
  • Read port voltage and current (returned in volts / amperes).
  • Read per-channel voltage.
  • Connect to a specific device by serial number or to the first discovered device.
  • Structured error reporting via AcronameException with a numeric BrainStem2 error code.
  • Bundled native binaries � BrainStem2.dll, Ijwhost.dll, and Oakrey.Acroname.Wrapper.dll are copied to the output directory automatically; no manual deployment step required.

Architecture

graph TD
    A[Consumer .NET application] --> B[Oakrey.Acroname<br>net10.0 managed library]
    B --> C[Oakrey.Acroname.Wrapper.dll <br> C++/CLI mixed-mode assembly]
    C --> D[BrainStem2.dll <br> Acroname native SDK]
    C --> E[Ijwhost.dll <br> IJW hosting shim]

Each operation follows an implicit connect / call / disconnect cycle inside the C++/CLI layer. The USBCSwitch class is IDisposable; disposing it disconnects from the device.

Key types

Type Assembly Description
USBCSwitch Oakrey.Acroname.Wrapper.dll C++/CLI ref class; low-level device operations
Channel Oakrey.Acroname.Wrapper.dll Enum Ch0-Ch3 for mux channel selection
AcronameException Oakrey.Acroname.Wrapper.dll Exception with ErrorCode (BrainStem2 aErr)

The Oakrey.Acroname.Devices package builds a higher-level abstraction on top of this library.

Requirements

  • .NET 10 or higher
  • Windows x64 (native DLLs are x64-only)
  • No additional runtime installation required; native binaries are bundled in the NuGet package

Installation

.NET CLI

dotnet add package Oakrey.Acroname

Package Manager Console

Install-Package Oakrey.Acroname

NuGet Package Manager

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

Example usage

using Oakrey.Acroname.Wrapper;

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

// Enable the USB-C port and select mux channel 2
sw.PortEnable();
sw.MuxEnable();
sw.MuxSelect(Channel.Ch2);

// Read telemetry
double voltage = sw.GetPortVoltage();   // volts
double current = sw.GetPortCurrent();   // amperes
double ch2Voltage = sw.GetChannelVoltage(Channel.Ch2);

Console.WriteLine($"Port: {voltage:F3} V  {current:F3} A");
Console.WriteLine($"Ch2:  {ch2Voltage:F3} V");

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

Error handling

All BrainStem2 errors are translated to AcronameException. The ErrorCode property contains the raw aErr integer from the native SDK.

try
{
    sw.MuxSelect(Channel.Ch0);
}
catch (AcronameException ex)
{
    Console.WriteLine($"BrainStem2 error {ex.ErrorCode}: {ex.Message}");
}

Common error codes:

Code Meaning
3 Device not found
5 Resource busy
18 Timeout
25 Connection error

Development notes

  • The C++/CLI wrapper (Acroname.Wrapper\main.cpp) connects, executes a single command, and disconnects on every call. This is intentional � the Acroname SDK is stateless between calls.
  • Ijwhost.dll is the IJW (It Just Works) hosting shim required by .NET Core for mixed-mode C++/CLI assemblies. It must be present alongside Oakrey.Acroname.Wrapper.dll at runtime.
  • All three native DLLs are included in the NuGet package under lib\net10.0 and are configured with PackageCopyToOutput="true" so they land in the consuming project's output directory without any manual configuration.

License

MIT - Copyright (c) Oakrey 2016-present

License

This project is licensed under the MIT License. See the LICENSE file for details.

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.
  • net10.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Oakrey.Acroname:

Package Downloads
Oakrey.Acroname.Devices

Higher-level .NET device abstraction for the Acroname USBCSwitch. Wraps Oakrey.Acroname to expose port enable/disable, 4-channel USB-C mux selection, and per-port voltage and current measurement via IProgrammable4PortUSBSwitchForUSBC.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.2 113 5/14/2026
2.0.1 139 2/2/2026
2.0.0 306 11/14/2025
1.0.1 378 5/27/2025
1.0.0 277 4/17/2025