Skip to content

stm32: Fix printing value of pyb.CAN auto_restart on FDCAN hardware. - #18951

Merged
dpgeorge merged 1 commit into
micropython:masterfrom
projectgus:bugfix/pyb_can_print_auto_restart
Mar 19, 2026
Merged

dpgeorge merged 1 commit into
micropython:masterfrom
projectgus:bugfix/pyb_can_print_auto_restart

Conversation

@projectgus

@projectgus projectgus commented Mar 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

As pointed out in #18572 (comment). The DAR register field is for disabling auto-retransmit, FDCAN hardware doesn't support automatic restart to clear Bus Off.

This work was funded through GitHub Sponsors.

Testing

Manually built a NUCLEO_G474RE board and ran the pyb_can.py unit test.

Generative AI

I did not use generative AI tools when creating this PR.

@projectgus

Copy link
Copy Markdown
Contributor Author

Very glad this doesn't change the print output, so don't have to revisit the pyb_can.py test! (DAR is always un-set, so it prints False before and after this fix.)

@projectgus projectgus mentioned this pull request Mar 19, 2026
9 tasks done
Comment thread ports/stm32/pyb_can.c
@@ -144,7 +144,7 @@ static void pyb_can_print(const mp_print_t *print, mp_obj_t self_in, mp_print_ki
self->can_id,
mode,
#if MICROPY_HW_ENABLE_FDCAN
(self->can.Instance->CCCR & FDCAN_CCCR_DAR) ? MP_QSTR_True : MP_QSTR_False
MP_QSTR_False // auto_restart not supported on FDCAN hardware
#else
(self->can.Instance->MCR & CAN_MCR_ABOM) ? MP_QSTR_True : MP_QSTR_False

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uncrustify insists on this indent here, for whatever reason. 🤷

@github-actions

github-actions Bot commented Mar 19, 2026 •

Copy link
Copy Markdown

Code size report:

Reference:  stm32: Add machine.CAN implementation. [6cac2d2]
Comparison: stm32: Fix printing value of pyb.CAN auto_restart on FDCAN hardware. [merge of c802a13]
  mpy-cross:    +0 +0.000% 
   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
      esp32:    +0 +0.000% ESP32_GENERIC
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

@dpgeorge dpgeorge left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@dpgeorge

Copy link
Copy Markdown
Member

Very glad this doesn't change the print output, so don't have to revisit the pyb_can.py test! (DAR is always un-set, so it prints False before and after this fix.)

Yes, I saw this as well in my testing.

@dpgeorge dpgeorge added this to the release-1.28.0 milestone Mar 19, 2026
The DAR register field is for auto-retransmit, FDCAN doesn't support
automatic restart to clear Bus Off.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <[email protected]>
@dpgeorge
dpgeorge force-pushed the bugfix/pyb_can_print_auto_restart branch from 716e3f0 to c802a13 Compare March 19, 2026 14:18
@dpgeorge
dpgeorge merged commit c802a13 into micropython:master Mar 19, 2026
10 checks passed
@projectgus
projectgus deleted the bugfix/pyb_can_print_auto_restart branch March 20, 2026 01:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants