Skip to content

Fix PeakCAN listen-only mode with native PCAN-Basic configuration - #2

Closed
RMBmd wants to merge 1 commit into
masterfrom
fix/peakcan-native-listen-only
Closed

Fix PeakCAN listen-only mode with native PCAN-Basic configuration#2
RMBmd wants to merge 1 commit into
masterfrom
fix/peakcan-native-listen-only

Conversation

@RMBmd

@RMBmd RMBmd commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Problem

SavvyCAN currently represents listen-only mode as bit 0 of QCanBusDevice::UserKey. Qt's peakcan backend does not consume that key; it supports bitrate/CAN-FD configuration but rejects the custom UserKey. Consequently, checking Listen Only in SavvyCAN can still initialize a PEAK interface in active mode, where it may acknowledge frames or emit active error flags.

This is observable during sensitive diagnostic transitions such as UDS programming-session entry: PCAN-View in native listen-only mode is non-intrusive, while SavvyCAN with the same UI option can alter bus behavior.

Fix

This change:

  • Detects the Qt peakcan backend.
  • Maps Qt PeakCAN interface names (usb0-usb15, pci0-pci15) to PCAN-Basic channel handles.
  • Dynamically resolves PCAN-Basic rather than introducing a link-time dependency.
  • Calls CAN_SetValue(..., PCAN_LISTEN_ONLY, ...) before QCanBusDevice::connectDevice() initializes the channel.
  • Reads the parameter back after initialization and disconnects if requested listen-only mode cannot be verified.
  • Refuses to open a PeakCAN channel when listen-only was requested but native configuration fails, so the application fails closed rather than silently joining the bus actively.
  • Prevents SavvyCAN frame transmission while a bus is configured as listen-only.
  • Preserves the existing UserKey behavior for non-Peak Qt SerialBus backends.
  • Avoids reporting a failed/rejected connection as connected during the reconnect loop.

PCAN-Basic is already the runtime API used by Qt's PeakCAN plugin, so this does not add a new external runtime requirement for users of that backend.

Validation

The exact production commit was compiled successfully with:

  • Linux x64, Qt 5/qmake
  • Windows x64, MSVC 2022, Qt 5/qmake

The validation branch used a temporary same-repository workflow; this submitted branch contains only the production source change.

Hardware acceptance criteria for a PEAK interface are:

  1. SavvyCAN connects with Listen Only selected.
  2. PCAN-Basic reports PCAN_LISTEN_ONLY=ON after initialization.
  3. The PEAK interface produces no ACK bits, active error flags, or application transmissions.
  4. A diagnostic/programming sequence behaves identically to the PCAN-View listen-only baseline.

Reference

PEAK documents PCAN_LISTEN_ONLY as the controller's passive monitoring mode and permits it to be configured before channel initialization:

https://www.peak-system.com/produktcd/Develop/PC%20interfaces/Windows/PCAN-Basic%20API/PCAN-Parameter_Documentation.pdf

RMBmd commented Jul 10, 2026

Copy link
Copy Markdown
Owner Author

Upstream submission

The production branch is based directly on collin80/SavvyCAN:master and contains one commit affecting one file. Open the upstream comparison and select Create pull request:

https://github.com/collin80/SavvyCAN/compare/master...RMBmd:fix/peakcan-native-listen-only?expand=1

The connected GitHub App can write to this fork but is not installed with write permission on collin80/SavvyCAN, so GitHub rejected automated creation of the cross-fork PR with HTTP 403.

Validated build

The exact commit 011062fd19dd9cb6bfd3f39311b007f72a290cfb compiled successfully in temporary CI on:

  • Linux x64 with Qt 5/qmake
  • Windows x64 with Visual Studio 2022 and Qt 5/qmake

The temporary validation PR was closed after both jobs passed. The production branch contains no temporary workflow files.

@RMBmd

RMBmd commented Jul 10, 2026

Copy link
Copy Markdown
Owner Author

Superseded by upstream SavvyCAN PR collin80#1104:

collin80#1104

The exact submitted commit compiled successfully and has passed physical
PCAN-USB Pro listen-only validation.

@RMBmd RMBmd closed this Jul 10, 2026
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.

1 participant