You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
stm32: pyb.CAN.init(extframe=False) excludes all frames #5508
There apprears to be an issue in the CAN drivers which prevents receiving messages with non extended id's.
As a test I'm using a pyboard-D to send data between the 2 CAN ports.
This works fine when the can filter is set to extframe=True. can.init(mode=pyb.CAN.NORMAL, extframe=True, prescaler=4, sjw=1, bs1=7, bs2=1)
However, when changed to False, there are no incoming frames detected.
I can see the frames with a CAN bus analyzer, but the rx callback does not trigger. can.init(mode=pyb.CAN.NORMAL, extframe=False, prescaler=4, sjw=1, bs1=7, bs2=1
I think I might have found where this goes wrong.
I'm using CAN.MASK32 with a blank values like this: can.setfilter(bank=self.itf-1, mode=pyb.CAN.MASK32, fifo=self.itf-1, params=(0x0, 0x0))
Now when I trace back the code, I come to pyb_can.c, where the filtermasks are set.
They appear to be designed for extended identifier format judging from the high value 0x1FFFE000.
Now when I change it to blank, I start receiving the packets. filter.FilterIdHigh = 0x0000; filter.FilterIdLow = 0x0000; filter.FilterMaskIdHigh = 0x0000; filter.FilterMaskIdLow = 0x0000;
I don't understand the bitwise operators that are applied in the original code, maybe someone can have a look at it.
While writing down the steps to reproduce and looking at the code I realized, I should have used MASK16 instead of MASK32.
Sorry for the confusion. I managed to receive non-extended id messages on non fd interfaces with the following filter:
can1.setfilter(bank=0, mode=pyb.CAN.MASK16, fifo=0, params=(0x0, 0x0, 0x0, 0x0))
Activity
JohnieBraaf commentedon Jan 9, 2020
thnx @jimmo, see the details below:
There apprears to be an issue in the CAN drivers which prevents receiving messages with non extended id's.
As a test I'm using a pyboard-D to send data between the 2 CAN ports.
This works fine when the can filter is set to extframe=True.
can.init(mode=pyb.CAN.NORMAL,extframe=True, prescaler=4, sjw=1, bs1=7,bs2=1)However, when changed to False, there are no incoming frames detected.
I can see the frames with a CAN bus analyzer, but the rx callback does not trigger.
can.init(mode=pyb.CAN.NORMAL,extframe=False, prescaler=4, sjw=1, bs1=7,bs2=1I think I might have found where this goes wrong.
I'm using CAN.MASK32 with a blank values like this:
can.setfilter(bank=self.itf-1,mode=pyb.CAN.MASK32, fifo=self.itf-1, params=(0x0,0x0))Now when I trace back the code, I come to pyb_can.c, where the filtermasks are set.
They appear to be designed for extended identifier format judging from the high value 0x1FFFE000.
micropython/ports/stm32/pyb_can.c
Lines 710 to 713 in bfbd944
Now when I change it to blank, I start receiving the packets.
filter.FilterIdHigh = 0x0000; filter.FilterIdLow = 0x0000;filter.FilterMaskIdHigh = 0x0000; filter.FilterMaskIdLow = 0x0000;I don't understand the bitwise operators that are applied in the original code, maybe someone can have a look at it.
gooyle commentedon Oct 15, 2020
has it been fixed already?we met it again,firmware we used is
pybv11-20200902-v1.13JohnieBraaf commentedon Oct 15, 2020
Don't think so. You will need to hack the workaround in yourself or even better attempt a proper fix. The workaround works in any case
gooyle commentedon Oct 25, 2020
thx,a new version lib works,no preblems appear till now
Merge pull request micropython#5508 from dhalbert/arg-fixes
JohnieBraaf commentedon Jan 24, 2022
While writing down the steps to reproduce and looking at the code I realized, I should have used MASK16 instead of MASK32.
Sorry for the confusion. I managed to receive non-extended id messages on non fd interfaces with the following filter:
can1.setfilter(bank=0, mode=pyb.CAN.MASK16, fifo=0, params=(0x0, 0x0, 0x0, 0x0))
JohnieBraaf commentedon Jan 24, 2022
@jimmo this issue can be closed