API ReferenceveextensionstechCANBus
CAN Bus (PCAN)
Interface to PEAK-System PCAN hardware for real CAN bus communication. Enables BeamNG to send and receive CAN frames through physical CAN adapters for hardware-in-the-loop testing.
Interface to PEAK-System PCAN hardware for real CAN bus communication. Enables BeamNG to send and receive CAN frames through physical CAN adapters for hardware-in-the-loop (HIL) testing with real automotive ECUs and instrument clusters.
Public API
| Variable | Type | Description |
|---|---|---|
canBusAPI | userdata | Handle to the native PCAN API library. |
PCANHandles | table | Map of available PCAN channel handles (USB, PCI, etc.). |
baudrates | table | Supported CAN baud rates (125k, 250k, 500k, 1M). |
errorCodes | table | PCAN error code definitions. |
messageType | table | CAN message type flags (standard, extended, RTR). |
CANType | table | CAN protocol type identifiers. |
errorCodeLookup | table | Reverse lookup for error code names. |
isConnected | boolean | Whether a PCAN adapter is currently connected and initialized. |
Hooks
| Hook | Description |
|---|---|
onExtensionLoaded | Loads the PCAN DLL and attempts to initialize the configured CAN channel. |
Usage Example
-- Load the CAN bus extension
extensions.load("tech/CANBus/CANBusPeak")
-- Check connection status
if extensions.tech_CANBus_CANBusPeak.isConnected then
log("I", "CAN", "PCAN adapter connected")
endSee Also
- Button Box — CAN-connected button box controller
- Project Bavaria Controller — BMW E39 CAN controller
- Project Bavaria Kombi — BMW E39 instrument cluster
- Racing Display — CAN-connected racing display
- LIN Bus (PCAN) — LIN bus via PCAN hardware
CAN Button Box
Reads button inputs from a CAN-connected button box controller. Maps physical button presses to vehicle actions via CAN frames.
Project Bavaria Controller
CAN bus integration for a BMW E39 body controller. Reads and writes CAN frames to control real BMW hardware (windows, locks, mirrors) from BeamNG.