peak-can-sys 0.2.0

FFI bindings for the API by PEAK-System Technik GmbH
Documentation

Peak CAN Sys

peak-can-sys provides Rust FFI bindings to the PEAK-System PCAN-Basic API, enabling interaction with PEAK CAN interfaces in Rust applications.

Features

  • Low-level FFI bindings to the PCAN-Basic API
  • Compatible with Windows and Linux systems
  • Supports various PEAK CAN hardware

Installation

To use peak-can-sys, ensure that you have the PCAN-Basic library installed on your system.

Windows

  1. Download and install the PEAK PCAN-Basic package from PEAK-System Drivers.
  2. Ensure that PCANBasic.dll is available in your system path.

Linux

  1. Install libpcanbasic.so from PEAK-System's official drivers.
  2. Verify that the shared library is accessible in your system.

Usage

Add peak-can-sys to your Cargo.toml:

[dependencies]

peak-can-sys = "0.1"

Include it in your Rust code:

use peak_can_sys::*;

Generating the bindings

bindgen src/binding/PCANBasic.h \

-o src/bindings.rs \

--no-layout-tests \

--dynamic-loading Pcan \

--allowlist-function "^CAN_.*" \

--allowlist-type "^TPCAN.*" \

--allowlist-var "^PCAN_.*" \

--allowlist-var "^LOG_.*" \

--allowlist-var "^TRACE_.*" \

--allowlist-var "^FEATURE_.*" \

--allowlist-var "^SERVICE_.*" \

--allowlist-var "^MAX_LENGTH_.*" \

--allowlist-var "^LOOKUP_.*"

The following additional flags must be provided if generating on Linux

-- --target=x86_64-pc-windows-gnu -I/usr/x86_64-w64-mingw32/include

Finally, run the following command to rename identifiers to be license compliant.

sed -i 's/PCAN/PEAK/g' src/bindings.rs

License & Legal Notice

This project is not affiliated with PEAK-System. The PCAN-Basic API is owned and maintained by PEAK-System.

For support related to this Rust binding, please contact the maintainer of this repository, not PEAK-System.