Open asbachb opened 6 years ago
Hi, currently no, but the stm32F0xx hardware does have a "silent mode" that does exactly that :
In Silent mode, the bxCAN is able to receive valid data frames and valid remote frames, but it sends only recessive bits on the CAN bus and it cannot start a transmission. [...] Silent mode can be used to analyze the traffic on a CAN bus without affecting it by the transmission of dominant bits (Acknowledge Bits, Error Frames).
And there is a "listen-only" flag at the kernel level :
$ ip link set can0 help
Usage: ip link set DEVICE type can
[ bitrate BITRATE [ sample-point SAMPLE-POINT] ] |
....
[ loopback { on | off } ]
[ listen-only { on | off } ]
[ triple-sampling { on | off } ]
[ one-shot { on | off } ]
[ berr-reporting { on | off } ]
[ fd { on | off } ]
[ fd-non-iso { on | off } ]
[ presume-ack { on | off } ]
...
So :
Actually I think I was partly wrong, firmware definitely should already support silent mode :
usbd_gs_can.c:393
case GS_USB_BREQ_MODE:
..........
can_enable(ch,
(mode->flags & GS_CAN_MODE_LOOP_BACK) != 0,
(mode->flags & GS_CAN_MODE_LISTEN_ONLY) != 0,
(mode->flags & GS_CAN_MODE_ONE_SHOT) != 0
So I guess one would have to enable listen-only just before bringing interface up . Has anyone tried ?
I happen to have a test setup handy to try this. Seems like it's working to me FWIW.
I'm using a candleLight on one Linux machine attached to another CAN interface on another Linux machine. The bus just has those 2 devices and a terminator, nothing else.
My test sequence:
candump any,0:0,#FFFFFFFF
shows frames and no ERRORFRAMEssudo ip link set brtcan2 down
candump any,0:0,#FFFFFFFF
sudo ip link set brtcan2 type can listen-only on && sudo ip link set brtcan2 up
sudo ip link set brtcan2 down && sudo ip link set brtcan2 type can listen-only off && sudo ip link set brtcan2 up
@brian-brt awesome, thanks for testing! Do I understand correctly that with brtcan2 (candleLight) in listen-only mode, it receives the error frames ? (I'm not sure if both ends are seeing the ERRORFRAMEs or just the sender)
No, I didn't actually try reading frames from the candleLight device originally. Testing again, the candleLight device does not see any ERRORFRAMEs. When it's not in listen-only mode, it sees all the frames (as expected). In listen-only mode, it sees a single frame being sent repeatedly.
Receiving the non-ACKed frames is what I mentioned in https://github.com/candle-usb/candleLight_fw/issues/55#issuecomment-732543598 about listen-only implying presume-ack. I think on a "correct" listen-only device those would all be no-ACK ERRORFRAMEs.
Hi,
I wonder if the firmware supports putting the can device into listen only mode?
Thanks Benjamin