Oakrey.Vector.Wrapper
3.0.3
dotnet add package Oakrey.Vector.Wrapper --version 3.0.3
NuGet\Install-Package Oakrey.Vector.Wrapper -Version 3.0.3
<PackageReference Include="Oakrey.Vector.Wrapper" Version="3.0.3" />
<PackageVersion Include="Oakrey.Vector.Wrapper" Version="3.0.3" />
<PackageReference Include="Oakrey.Vector.Wrapper" />
paket add Oakrey.Vector.Wrapper --version 3.0.3
#r "nuget: Oakrey.Vector.Wrapper, 3.0.3"
#:package Oakrey.Vector.Wrapper@3.0.3
#addin nuget:?package=Oakrey.Vector.Wrapper&version=3.0.3
#tool nuget:?package=Oakrey.Vector.Wrapper&version=3.0.3
Oakrey.Vector.Wrapper
Managed .NET 10 wrapper around the Vector XL Driver API (vxlapi / vxlapi64). Provides a clean, exception-safe interface for CAN, CAN FD, and LIN communication with Vector hardware interfaces.
Main features
- CAN classic - transmit (
CanTransmit) and async receive (CanRead) with acceptance range filtering. - CAN FD - ISO CAN FD transmit (
CanTransmitEx) and async receive (CanFdRead) with separate nominal/data timing configuration. - LIN - master/slave configuration (
ConfigureLin,LinSetSlave), LIN frame request (SendLinRequest), DLC table management, async receive (LinRead). - Channel enumeration -
GetAvailableCanChannels/GetAvailableLinChannelsenumerate physical (non-virtual) hardware channels with fullChannelConfigurationmetadata. - Application config helpers -
VectorExtensions.SetCanAppConfig/SetLinAppConfigregister or retrieve XL application configurations in one call. - Structured error handling - every XL Driver API call is checked and translated to a typed
VectorException. - Bundled native DLLs -
vxlapi.dll,vxlapi64.dll, andvxlapi_NET.dllare included and copied to the output directory automatically.
Architecture
graph TD
subgraph Oakrey.Vector.Wrapper
VectorHandle
VectorExtensions -->|extends| VectorHandle
VectorException
end
subgraph Oakrey.Vector.Wrapper.DataTypes
ChannelConfiguration
CanBusParams
CanFdBusParams
FdConfig
LinConfig
ApplicationConfig
BusType
HardwareType
end
VectorHandle -->|uses| ChannelConfiguration
VectorHandle -->|uses| LinConfig
VectorHandle -->|uses| FdConfig
VectorHandle -->|uses| ApplicationConfig
VectorHandle -->|wraps| vxlapi_NET[vxlapi_NET.dll]
vxlapi_NET -->|delegates to| vxlapi[vxlapi.dll / vxlapi64.dll]
Requirements
- .NET 10 (Windows only)
- Vector XL Driver installed on the host machine (available from Vector Informatik support portal)
Installation
.NET CLI
dotnet add package Oakrey.Vector.Wrapper
Package Manager Console
Install-Package Oakrey.Vector.Wrapper
NuGet Package Manager
Search for Oakrey.Vector.Wrapper in Visual Studio under Tools > NuGet Package Manager > Manage NuGet Packages for Solution.
Usage
Enumerate available CAN channels
using Oakrey.Vector.Wrapper;
List<ChannelConfiguration> channels = VectorHandle.GetAvailableCanChannels();
foreach (ChannelConfiguration ch in channels)
{
Console.WriteLine(ch); // SerialNumber, ChannelIndex, Name, HwType, BusType, AccessMask
}
Open a port and transmit a CAN frame
using Oakrey.Vector.Wrapper;
using Oakrey.Vector.Wrapper.DataTypes;
using VectorHandle handle = new();
ChannelConfiguration channel = VectorHandle.GetAvailableCanChannels()[0];
ulong accessMask = handle.GetAccessMask(channel);
ulong permissionMask = accessMask;
int portHandle = -1;
handle.OpenPort(ref portHandle, "MyApp", accessMask, ref permissionMask, 8192,
InterfaceVersion.V3, BusType.CAN);
handle.CanSetChannelBitrate(portHandle, accessMask, 500_000);
handle.ActivateChannel(portHandle, accessMask, BusType.CAN, ActivateAction.Reset);
handle.SetNotification(portHandle, 1);
// transmit
handle.CanTransmit(portHandle, accessMask, channel.HwChannel, 0x123,
[0x01, 0x02, 0x03, 0x04], extendedIdLimit: 0x7FF);
handle.DeactivateChannel(portHandle, accessMask);
handle.ClosePort(portHandle);
Receive CAN frames asynchronously
using CancellationTokenSource cts = new(TimeSpan.FromSeconds(5));
while (!cts.Token.IsCancellationRequested)
{
await handle.CanRead(portHandle, msg =>
{
Console.WriteLine($"ID=0x{msg.Id:X3} DLC={msg.Dlc}");
}, cts.Token);
}
Configure and receive CAN FD
using Oakrey.Vector.Wrapper.DataTypes;
FdConfig fdConfig = new(
NominalTiming: new Timing(500_000, tseg1: 63, tseg2: 16, sjw: 16),
DataTiming: new Timing(2_000_000, tseg1: 15, tseg2: 4, sjw: 4));
handle.CanFdSetConfiguration(portHandle, accessMask, fdConfig);
await handle.CanFdRead(portHandle, msg =>
{
Console.WriteLine($"FD ID=0x{msg.Id:X} DLC={msg.Dlc}");
}, cancellationToken);
Configure a LIN slave response
using Oakrey.Vector.Wrapper.DataTypes;
LinConfig linConfig = new(LinMode.Slave, LinVersion.LIN_1_3, baudrate: 19200);
handle.ConfigureLin(portHandle, accessMask, linConfig);
handle.LinSetSlave(portHandle, accessMask, id: 0x10,
data: [0xAA, 0xBB, 0xCC, 0xDD], enhancedChecksum: true);
Register an application configuration
// Convenience extension - registers CAN app config if not already present
handle.SetCanAppConfig("MyApplication", channel: 0);
Key DataTypes
| Type | Purpose |
|---|---|
ChannelConfiguration |
Full metadata for a physical hardware channel |
CanBusParams |
Classic CAN bitrate and timing |
CanFdBusParams |
CAN FD nominal and data bitrate |
FdConfig |
Wraps nominal and data Timing for CAN FD port setup |
LinConfig |
LIN mode, version, and baud rate |
ApplicationConfig |
XL application channel registration |
BusType |
CAN, LIN enum for port and channel operations |
HardwareType |
Identifies the physical interface hardware model |
Project information
| Field | Value |
|---|---|
| Author | Oakrey |
| License | MIT |
| Repository | https://dev.azure.com/oakrey/OpenPackages/_git/Drivers |
| Project URL | http://www.oakrey.cz/opkg_drivers_vector |
License
MIT License. See 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.Vector.Wrapper:
| Package | Downloads |
|---|---|
|
Oakrey.Vector.Base
Foundation package for building Vector hardware clients. Provides VectorClientBase and VectorChannelBase abstract types with IObservable message streams (Rx.NET) for CAN and LIN channel implementations built on top of Oakrey.Vector.Wrapper. |
GitHub repositories
This package is not used by any popular GitHub repositories.