Suucha.Can.Core 0.1.0

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

Suucha.Can

NuGet License: MIT .NET Documentation

โš ๏ธ Preview Release: This is a 0.x version, indicating active development. The API is functional and tested, but may evolve based on user feedback. See CHANGELOG for details.

๐Ÿš€ Modern, type-safe, and high-performance .NET wrapper for CAN devices

Suucha.Can is a production-grade open-source library that provides a clean, object-oriented API for CAN/CANFD devices. Built with modern .NET best practices, it replaces raw P/Invoke calls with safe, easy-to-use abstractions.

๐Ÿ“– Complete Documentation | ๐Ÿš€ Quick Start | ๐Ÿ“š API Reference

๐Ÿ”Œ Supported Manufacturers

  • ZLG (Zhiyuan Electronics) - Full support for all ZLG CAN device families
  • More manufacturers coming soon - Extensible architecture ready for additional vendors

โœจ Features

  • ๐ŸŽฏ Type-Safe API - No more IntPtr and manual marshaling
  • ๐Ÿ”’ Resource Management - Automatic disposal with IDisposable pattern
  • ๐Ÿš€ High Performance - Zero-allocation receive paths
  • ๐Ÿ“ฆ Multi-Device Support - Extensible architecture for all ZLG device families
  • ๐Ÿงช Well Tested - Comprehensive unit and integration tests
  • ๐Ÿ”„ Async/Await - Modern asynchronous programming support
  • ๐Ÿ’ป Multi-Architecture - Supports both x86 (32-bit) and x64 (64-bit)

โœ… Platform Support

Great News: This library supports both x86 and x64 architectures!

  • โœ… x86 (32-bit) - Full support
  • โœ… x64 (64-bit) - Full support
  • โœ… AnyCPU - Automatically selects correct native DLLs at runtime

Your application can use any platform configuration:


<PropertyGroup>
  <PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>


<PropertyGroup>
  <PlatformTarget>x64</PlatformTarget>
</PropertyGroup>

๐Ÿ“‹ Prerequisites

System Requirements

  • Operating System: Windows 10/11 (x86 or x64)
  • .NET Runtime: .NET 8.0 or later

Required Software

1. ZLG Device Drivers (Required)

You must install ZLG device drivers before using this library.

๐Ÿ“ฅ Download Links:

Installation Steps:

  1. Download the driver package for your specific device model
  2. Extract and run the installer
  3. Connect your ZLG device
  4. Verify installation in Windows Device Manager (look for "ZLG USBCAN" or similar)
  5. You may need to restart your computer after installation

Note: Different ZLG device families may require different driver packages:

  • USBCAN series โ†’ USBCAN driver
  • CANFDNET series โ†’ CANFDNET driver
  • CANET series โ†’ CANET driver

Check ZLG's documentation for your specific device model.

2. Visual C++ Redistributable (Required)

Required for native DLL dependencies

Note: ZLG's native DLLs are compiled with Visual Studio 2005-2013. Most Windows systems already have these runtimes installed. If you encounter a DllNotFoundException or missing DLL error, install VC++ 2013 Redistributable first, then try older versions if needed.

Quick Install (PowerShell)

Run this script to automatically check and install all prerequisites (VC++ only, ZLG drivers must be installed manually):

# Run from the project root
.\scripts\Install-Prerequisites.ps1

Important: This script only installs VC++ redistributables. You must download and install ZLG device drivers separately from ZLG's website.

Hardware Requirements

  • ZLG CAN hardware device (USBCAN-II, CANET, USBCAN-E-U, etc.)
  • ZLG device drivers installed - Download from:

Important: You must install the official ZLG device drivers before using this library. The driver package includes necessary kernel drivers and configuration tools for your specific device model.

๐Ÿ“ฆ Packages

Package Description NuGet
Suucha.Can.Core Core abstractions and interfaces NuGet
Suucha.Can.Zlg.Native ZLG native runtime libraries (x86 & x64) NuGet
Suucha.Can.Zlg.Devices Implementation for all ZLG devices NuGet

Note: Suucha.Can.Zlg.Devices is the unified package that supports all ZLG device types (USBCAN, CANET, USBCAN-E-U, CANFDNET, etc.) through a single API. Device selection is done via the DeviceType parameter.

๐Ÿš€ Quick Start

Installation Checklist

Before you begin, make sure you have:

  • โœ… Windows 10/11 (x86 or x64)
  • โœ… .NET 8.0 SDK or Runtime installed
  • โœ… ZLG device drivers installed (Download here)
  • โœ… Visual C++ 2013 Redistributable installed (x64 / x86)
  • โœ… ZLG CAN device connected and recognized in Device Manager

Installation

dotnet add package Suucha.Can.Zlg.Devices

This automatically includes the required dependencies:

  • Suucha.Can.Core - Core abstractions
  • Suucha.Can.Zlg.Native - Native DLLs (x86 + x64)

Basic Usage

using Suucha.Can.Core.Models;
using Suucha.Can.Zlg.Devices;

// Open device (supports all ZLG device types)
using var device = new ZlgCanDevice(DeviceType.USBCAN2, deviceIndex: 0);
device.Open();

// Configure and open channel
var config = ChannelConfig.Standard250K(); // 250 kbps preset
using var channel = device.OpenChannel(channelIndex: 0, config);

// Start receiving (event-driven)
channel.MessageReceived += (sender, frame) =>
{
    Console.WriteLine($"Received: ID=0x{frame.Id:X3}, Data={BitConverter.ToString(frame.Data)}");
};

channel.ErrorOccurred += (sender, e) =>
{
    Console.WriteLine($"Error: {e.ErrorInfo}");
};

channel.Start();

// Send a message
var message = new CanFrame
{
    Id = 0x123,
    Data = new byte[] { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88 },
    IsExtended = false
};

await channel.SendAsync(message);

Multiple Device Support

The same API works for all ZLG device types:

// USBCAN-II
var usbcan = new ZlgCanDevice(DeviceType.USBCAN2, 0);

// CANET-TCP
var canet = new ZlgCanDevice(DeviceType.CANETTCP, 0);

// USBCAN-E-U
var usbcan_e = new ZlgCanDevice(DeviceType.USBCAN_E_U, 0);

// CANFDNET-800U
var canfdnet = new ZlgCanDevice(DeviceType.CANFDNET_800U_TCP, 0);

// All use the same ICanDevice interface!

๐ŸŽฏ Supported Devices

All ZLG CAN device types are supported through the unified ZlgCanDevice class:

โœ… Fully Supported (85+ device types)

  • USBCAN Series - USBCAN-I, USBCAN-II (Classic USB devices)
  • USBCANFD Series - 100U, 200U, 400U, 800U (USB CANFD devices)
  • CANET Series - CANET-TCP, CANET-UDP (Ethernet devices)
  • CANFDNET Series - 200U-TCP, 400U-TCP, 800U-TCP (Ethernet CANFD)
  • USBCAN-E-U Series - Enhanced USB devices
  • PCI/PCIe Series - PCI-9840I, PCI-9820I, PCIE-9120I, PCIE-9110I, PCIE-9140I
  • And 75+ more device types!

๐Ÿ”ง How It Works

All devices use the same ZLG native API (zlgcan.dll). The only difference is the DeviceType parameter:

// Select your device type from the DeviceType enum
public enum DeviceType : uint
{
    ZCAN_USBCAN1 = 3,
    ZCAN_USBCAN2 = 4,
    ZCAN_CANETTCP = 17,
    ZCAN_USBCAN_E_U = 20,
    ZCAN_CANFDNET_800U_TCP = 42,
    // ... 80+ more types
}

See the DeviceType enum in the source code for the complete list of supported device types.

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚         Your Application                โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
               โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚      Suucha.Can.Core (Abstractions)     โ”‚
โ”‚   ICanDevice, ICanChannel, CanFrame     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
               โ”‚
     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
     โ”‚                   โ”‚            โ”‚
โ”Œโ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ–ผโ”€โ”€โ”€โ”
โ”‚ Zlg.Devices      โ”‚ โ”‚ Other   โ”‚  โ”‚ ...  โ”‚
โ”‚(All ZLG types)   โ”‚ โ”‚ Vendors โ”‚  โ”‚      โ”‚
โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
     โ”‚                   
โ”Œโ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Suucha.Can.Zlg.Native (Runtime DLLs)    โ”‚
โ”‚  x86: zlgcan.dll + kernel DLLs           โ”‚
โ”‚  x64: zlgcan.dll + kernel DLLs           โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Key Design Decisions:

  1. Vendor-Agnostic Core - Suucha.Can.Core provides common CAN abstractions (interfaces, CanFrame) that work across all manufacturers
  2. Single Device Implementation Per Vendor - Suucha.Can.Zlg.Devices supports all 85+ ZLG device types through one unified API
  3. Device Selection via Enum - Choose device type with DeviceType parameter (no separate packages per device)
  4. Native Package Separation - Suucha.Can.Zlg.Native contains only runtime DLLs (x86 + x64), no managed code
  5. Runtime Architecture Selection - Correct native DLLs automatically selected based on process architecture
  6. Extensible for Other Vendors - Easy to add support for other CAN manufacturers (Kvaser, PEAK, Vector, etc.)

๐Ÿค Contributing

We welcome contributions! Please see our Contributing Guide.

Development Setup

git clone https://github.com/suucha/Suucha.Can.git
cd Suucha.Can
dotnet restore
dotnet build

๐Ÿ“„ License

This project is dual-licensed:

  • Suucha.Can Wrapper Code: MIT License - Our C# wrapper code
  • ZLG Native Libraries (v20260414): Proprietary - ZLG's native DLLs

What This Means

โœ… You CAN:

  • Use commercially
  • Modify and redistribute the wrapper code
  • Use in closed-source projects
  • Use with proper hardware

โš ๏ธ You MUST:

  • Include the license file when distributing
  • Keep copyright notices intact
  • Have valid hardware from respective manufacturers

โŒ You CANNOT:

  • Claim manufacturers endorse your product
  • Remove copyright notices
  • Hold us liable for issues

See LICENSE for full details, or LICENSE.zh-CN.md for Chinese version.

Note: The native DLLs (such as ZLG's zlgcan.dll) are proprietary software owned by their respective manufacturers. You need proper licensing to use their hardware and drivers.

๐Ÿ™ Acknowledgments

๐Ÿ“ž Support

๐Ÿ”ง Troubleshooting

Common Issues

"Unable to load DLL 'zlgcan.dll'" or DllNotFoundException

Cause: Missing Visual C++ Redistributable runtime (2005-2013).

Solution:

  1. Install VC++ 2013 Redistributable (most common):
  2. If the issue persists, try installing older versions:
  3. Restart your application after installation
  4. Or use the automated installer: .\scripts\Install-Prerequisites.ps1

Tip: If you're unsure which version to install, install all three (2008, 2010, 2013) for both x86 and x64.

Device Not Found

Cause: ZLG device drivers not installed or device not connected.

Solution:

  1. Download and install official ZLG drivers:
  2. Install the driver package for your specific device model
  3. Connect your ZLG device via USB or network
  4. Verify the device appears in Windows Device Manager (should show as "ZLG USBCAN" or similar)
  5. Check the device index and type in your code matches your hardware

Tip: Different device models may require different driver packages. Make sure you download the driver that matches your hardware (e.g., USBCAN-II driver, CANFDNET driver, etc.).

"BadImageFormatException"

Cause: Architecture mismatch between your application and the native DLL.

Solution:

  • If using AnyCPU, ensure "Prefer 32-bit" is unchecked
  • Verify your platform target matches your system architecture
  • Rebuild your application after changing platform settings

Made with โค๏ธ by Suucha

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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.
  • net8.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Suucha.Can.Core:

Package Downloads
Suucha.Can.Zlg.Devices

ZLG CAN device implementation for Suucha.Can. Supports all ZLG device types (USBCAN, CANET, USBCAN-E-U, CANFDNET, etc.) on both x86 and x64 platforms.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0 128 8/13/2026
0.0.0-ci 114 8/13/2026

IMPORTANT: This package includes ZLG native libraries (version 20260414) which are licensed under BSD-3-Clause.
     You must comply with both MIT (wrapper code) and BSD-3-Clause (native DLLs) licenses.
     See LICENSE file for details.