Using CAN FD, with these settings:
Code: Select all
* pcanpcifd3: (/sys/class/pcan/pcanpcifd3)
- file: /dev/pcan3
- dev: "234:3"
- dev_name: "/dev/pcan3"
- minor: 3
- base: 0x80ED4000
- irq: 16
-----------------
- adapter_name: "PCAN-M.2"
- adapter_partnum: "IPEH-004085"
- adapter_number: 0
- adapter_version: "3.2.1"
- type: "pcifd"
- hwtype: 19
- devid: 0xFFFFFFFF
- ctrlr_number: 3
-----------------
- clock: 80 MHz
- nom_bitrate: 1 MBit/s
- btr0btr1: 0x4110
- data_bitrate: 5 MBit/s
- init_flags: 0x80000104
- clk_drift: 131073
- ts_fixed: 0
-----------------
- nom_brp: 8
- nom_sample_point: 60.00%
- nom_sjw: 4
- nom_tseg1: 5
- nom_tseg2: 4
- nom_tq: 100
- data_brp: 2
- data_sample_point: 62.50%
- data_sjw: 3
- data_tseg1: 4
- data_tseg2: 3
- data_tq: 25
-----------------
- bus_state: OK (1)
- bus_load: 0%
- rx_error_counter: 0
- tx_error_counter: 0
- rx_fifo_ratio: 0%
- tx_fifo_ratio: 0%
-----------------
- irqs: 3294
- status: 0
- errors: 0
- read: 1
- write: 0
-----------------
- TPCANHandle: "PCAN_PCIBUS4" (0x044)
I have verified with an oscilloscope that the SYNC is sent every 1 ms with 50 us margin of error.
The TPDO sent by the motor is also sent every 1 ms, 200 us after the SYNC frame, with 40 us margin of error.
The problem I am experiencing is that I read every 1 ms, and sometimes I get 0 TPDO and sometimes I get 2 TPDO. I don't know the details of the interaction between the library, the driver and the hardware, but it looks as if there's a buffer the hardware and my application that is not updated as soon as the message is received, but waits for some time, probably for the IRQ.
I have verified the stamps of the CAN FD frames, and they are stamped as being received 1 ms apart, but the CAN_ReadFD function returns PCAN_ERROR_QRCVEMPTY when according to the timestamp the message was received by the device 600-700 us ago.
My system is deterministic, I am using the same structure to control the motor through EtherCAT and don't have this bundling problem.
I have the same problem with the Linux netdev driver as well as with the chardev driver.
Attaching my kernel config.
How can I remove this delay or buffering between the hardware receiving the message and my application being able to read it via CAN_ReadFD function call.