Oakrey.Acroname
2.0.2
dotnet add package Oakrey.Acroname --version 2.0.2
NuGet\Install-Package Oakrey.Acroname -Version 2.0.2
<PackageReference Include="Oakrey.Acroname" Version="2.0.2" />
<PackageVersion Include="Oakrey.Acroname" Version="2.0.2" />
<PackageReference Include="Oakrey.Acroname" />
paket add Oakrey.Acroname --version 2.0.2
#r "nuget: Oakrey.Acroname, 2.0.2"
#:package Oakrey.Acroname@2.0.2
#addin nuget:?package=Oakrey.Acroname&version=2.0.2
#tool nuget:?package=Oakrey.Acroname&version=2.0.2
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
AcronameExceptionwith a numeric BrainStem2 error code. - Bundled native binaries �
BrainStem2.dll,Ijwhost.dll, andOakrey.Acroname.Wrapper.dllare 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.dllis the IJW (It Just Works) hosting shim required by .NET Core for mixed-mode C++/CLI assemblies. It must be present alongsideOakrey.Acroname.Wrapper.dllat runtime.- All three native DLLs are included in the NuGet package under
lib\net10.0and are configured withPackageCopyToOutput="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 | Versions 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. |
-
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.