Closed gworkman closed 1 year ago
Thanks for the L4 Fix!
I use CAN with this lib regularly, but it's on G4 and H7 that use the (completely different) FD CAN periph and support library. So, I haven't tested with BX CAN; I have no immediate insight into why it's not working.
Have you tried it in loopback mode (Assuming BX CAN has that)? That will help you narrow it down to CAN periph config vice transceiver or GPIO.
Also, try printing the CAN status register contents; see what (error etc) flags are set.
Another thing to investigate is if you can receive CAN messages from other devices.
Thanks! I just tried the loopback mode. It helped to step away from it for a day, it was definitely a user issue. I didn't have any other devices hooked up on the CAN bus, so of course it couldn't send any packets. Loopback works, and it seems to work now!
Thanks :)
Hi! This has been a great library, and I've been loving the ability to use rust over the CubeMX C projects. I have encountered one bug though, and wanted to see if I could get some additional eyes into what I'm doing wrong.
First of all, I'd like to bring it to your attention that the bxcan driver is not gated properly - there are two different names for the feature. One is
can_bx
(defined inCargo.toml
) and the other one isbx_can
(defined incan.rs
). I fixed this issue, so I will submit a quick PR to showcase the issue and the fix.Second, I am using an STM32L431 chip. For this chip, there are 14 filter banks for the CAN filters. However, the following line in
can.rs
excludes the L4 family from having a definition for theNUM_FILTER_BANKS
const (see below). In the PR I will link to this issue, I set the feature gating to just theL4
family. I didn't do any other research on the other families, so maybe that is something we would need to address before merging this into a release.Finally, with these changes, I can compile the library with the features enabled:
stm32-hal2 = { path = "../stm32-hal", version = "^1.6.3", features = ["l4x1", "l4rt", "can_bx"]}
However, once trying to use the CAN peripheral, I get stuck. The
can.transmit(&frame)
function works on the first call, but after that I get errors. It looks like the transmit is not working at all for some reason. The message might be getting queued, but the FIFO seems to be busy. The error is as follows:ERROR panicked at 'called
Result::unwrap()on an
Errvalue: WouldBlock', src/main.rs:149:35
When wrapping the call to
transmit
in thenb::block!
macro, it simply hangs indefinitely.All of this leads me to believe that my device config must be wrong, but I just can't figure out where. Some additional eyes would be good for this issue. The full code for the example is below
Cargo.toml: