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
<PackageReference Include="Oakrey.Acroname.Devices" Version="3.0.3" />
<PackageVersion Include="Oakrey.Acroname.Devices" Version="3.0.3" />
<PackageReference Include="Oakrey.Acroname.Devices" />
paket add Oakrey.Acroname.Devices --version 3.0.3
#r "nuget: Oakrey.Acroname.Devices, 3.0.3"
#:package Oakrey.Acroname.Devices@3.0.3
#addin nuget:?package=Oakrey.Acroname.Devices&version=3.0.3
#tool nuget:?package=Oakrey.Acroname.Devices&version=3.0.3
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 byOakrey.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
ArgumentOutOfRangeExceptionbefore 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.AcronameNuGet 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.
Programmable4PortUSBSwitchForUSBCdoes not implementIDisposablebecause the underlyingUSBCSwitchconnects and disconnects per-call. No persistent connection is held.
License
MIT - Copyright (c) Oakrey 2016-present
| 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
- Oakrey.Acroname (>= 2.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.