Driver Dev: FMU-v3 CAN "Error 25" (ENOTTY) on Filter Registration & Missing candump

Hi everyone,

I am developing a custom C++ driver for the TOFSense MS laser rangefinder over CAN on an FMU-v3 (Pixhawk pix32 pro) board.

The driver compiles and runs, and successfully opens the file descriptor (e.g., /dev/can0). However, I am receiving 0 data events. The root cause appears to be that the driver fails to register ANY hardware acceptance filter (Standard or Extended) via ioctl, always returning Error 25 (ENOTTY). Consequently, the hardware seems to be rejecting all incoming frames.

Additionally, I am unable to get candump enabled in the build, suggesting my configuration changes are being ignored or overwritten.

Hardware Setup

  • FC: Pixhawk pix32 pro (FMU-v3 / STM32F427)

  • Sensor: TOFSense MS (CAN Mode)

  • Settings: 500k Baud, “Active” output mode (verified working via NAssistant).

  • Param: UAVCAN_ENABLE set to 0 to free up the bus.

The Problem

When the driver starts, it attempts to register a hardware filter to accept traffic. I have tried three different approaches in my open_can_device() function:

  1. Standard Filter (CANIOC_ADD_STDFILTER) → Returns Error 25 (ENOTTY).

  2. Extended Filter (CANIOC_ADD_EXTFILTER) → Returns Error 25 (ENOTTY).

  3. Brute Force: Trying both sequentially → Both fail with Error 25.

Because the ioctl fails, the hardware filter is never set, so the CAN controller discards all packets, resulting in read: 0 events.

NSH Output

nsh> tofsensecan start
WARN  [tofsensecan] Extended Filter rejected (Error 25). Falling back to Standard Filter...
ERROR [tofsensecan] CRITICAL: Failed to set Standard Filter too! Error: 25
ERROR [tofsensecan] WARNING: No hardware filters set. Driver may receive 0 events.
INFO  [tofsensecan] CAN device /dev/can0 opened

nsh> tofsensecan status
TOFSense MS CAN Rangefinder
  CAN Interface: 0
  CAN ID: 0x200
tofsensecan: read: 0 events, 0us elapsed
tofsensecan: com_err: 0 events

Build System Issue

I suspect this is a configuration mismatch in the NuttX build system for FMU-v3. I have attempted to enable CONFIG_CAN_EXTID=y and CONFIG_CAN_UTILS=y (for candump) by editing boards/px4/fmu-v3/nuttx-config/nsh/defconfig.

However, after running make distclean and make px4_fmu-v3_default upload:

  1. candump is still missing (“command not found”).

  2. The driver still throws ENOTTY for both filter types.

It seems make distclean is wiping my manual config changes, but menuconfig changes don’t seem to persist into the default build target for FMU-v3.

Driver Code Snippet

Here is the open logic that is failing:

C++

int TOFSenseCAN::open_can_device() {
    // ... open /dev/can0 code ...

    // Attempt 1: Extended Filter
    struct canioc_extfilter_s ext_filter;
    ext_filter.xf_id1 = 0; 
    ext_filter.xf_id2 = 0; // Mask 0 (Accept All)
    int ret = ::ioctl(_can_fd, CANIOC_ADD_EXTFILTER, (unsigned long)&ext_filter);

    if (ret < 0) {
         // Attempt 2: Fallback to Standard
        struct canioc_stdfilter_s std_filter;
        std_filter.sf_id1 = 0;
        std_filter.sf_id2 = 0; 
        ret = ::ioctl(_can_fd, CANIOC_ADD_STDFILTER, (unsigned long)&std_filter);
    }
    // Result: Both fail with errno 25
}

My Question: How do I correctly persist CONFIG_CAN_EXTID=y and CONFIG_CAN_UTILS=y for the FMU-v3 Default build target so that I can use candump and register filters without getting ENOTTY?

Any help is appreciated!