Skip to content

feat: Add Kvaser CANlib Windows plugin for virtual and physical CAN devices#631

Open
arcostasi wants to merge 3 commits intoOpen-Agriculture:mainfrom
arcostasi:feature/kvaser-canlib-windows-plugin
Open

feat: Add Kvaser CANlib Windows plugin for virtual and physical CAN devices#631
arcostasi wants to merge 3 commits intoOpen-Agriculture:mainfrom
arcostasi:feature/kvaser-canlib-windows-plugin

Conversation

@arcostasi
Copy link

Summary

This PR adds support for Kvaser CANlib devices on Windows, including virtual CAN channels which are useful for development and testing without physical hardware.

Changes

  • Added CANLibWindowsPlugin class implementing the CANHardwarePlugin interface.
  • Included Kvaser CANlib header files:
    • canlib.h
    • canstat.h
    • canevt.h
    • predef.h
    • obsolete.h
  • Added Windows binaries for Kvaser CANlib:
    • canlib32.lib
    • canlib32.dll
      (supports both x86 and x64)

Build System

  • Updated CMakeLists.txt to support the new WindowsCANlib driver.

Driver Registration

  • Registered the driver in available_can_drivers.hpp.

Usage

cmake -B build -DCAN_DRIVER=WindowsCANlib -G "Visual Studio 17 2022" -A x64
cmake --build build --config Release

arcostasi pushed a commit to arcostasi/AgIsoStack-plus-plus that referenced this pull request Dec 10, 2025
…ders

- Rename CAN_DRIVER option from WindowsCANlib to WindowsKvaserCANlib for clarity
- Remove obsolete.h header file (not needed)
- Remove obsolete.h include from canlib.h
- Apply clang-format to all modified files
- Keep only essential headers: canlib.h, canstat.h, canevt.h, predef.h

Addresses review feedback from PR Open-Agriculture#631
arcostasi pushed a commit to arcostasi/AgIsoStack-plus-plus that referenced this pull request Dec 10, 2025
…ders

- Rename CAN_DRIVER option from WindowsCANlib to WindowsKvaserCANlib for clarity
- Remove obsolete.h header file (not needed)
- Remove obsolete.h include from canlib.h
- Apply clang-format to all modified files
- Keep only essential headers: canlib.h, canstat.h, canevt.h, predef.h

Addresses review feedback from PR Open-Agriculture#631
@arcostasi arcostasi force-pushed the feature/kvaser-canlib-windows-plugin branch from 3014f5c to 102bc3c Compare December 10, 2025 23:28
…ders

- Rename CAN_DRIVER option from WindowsCANlib to WindowsKvaserCANlib for clarity
- Remove obsolete.h header file (not needed)
- Remove obsolete.h include from canlib.h
- Apply clang-format to all modified files
- Keep only essential headers: canlib.h, canstat.h, canevt.h, predef.h

Addresses review feedback from PR Open-Agriculture#631
@arcostasi arcostasi force-pushed the feature/kvaser-canlib-windows-plugin branch from 102bc3c to 6abd804 Compare December 10, 2025 23:31
@arcostasi
Copy link
Author

Hi @martonmiklos, thank you for the review feedback!

I've made all the requested changes:

✅ Removed obsolete.h file completely
✅ Removed the #include "obsolete.h" from canlib.h
✅ Renamed WindowsCANlib to WindowsKvaserCANlib for better clarity
✅ Applied clang-format to all modified files
✅ Excluded Kvaser headers from Doxygen to fix the linting check (they are third-party files with their own documentation)

Please let me know if there's anything else that needs to be adjusted.

@GwnDaan
Copy link
Member

GwnDaan commented Dec 23, 2025

Hi @arcostasi, thanks for your PR. Really nice to see Kvaser support being added! I have used their controllers in the past and liked it.

However, we should be careful with including their header files, especially since they are not MIT licensed! See here. Hence I think we should try to link the headers dynamically when the SDK is installed, like we do with NTCAN here:

if(DEFINED ENV{CanSdkDir})
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" OR CMAKE_SYSTEM_PROCESSOR
STREQUAL "x64")
message(STATUS "Detected x64, linking to NTCAN x64 library")
target_link_libraries(HardwareIntegration
PRIVATE $ENV{CanSdkDir}/lib/VC/amd64/ntcan.lib)
target_include_directories(HardwareIntegration
PUBLIC $ENV{CanSdkDir}/include)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments