SocketCAN with PX4 v1.12.3

Hello everyone,

I鈥檝e been attempting to communicate with a CAN sensor on a Cubeorange flight controller, but I can鈥檛 seem to get it to work with v1.12.3. I can, however, configure SocketCAN on v1.13.2 and successfully communicate with the sensor.

On v1.13.2, I add the SocketCAN driver for my MCU (Backport STM32H7 FDCAN by JacobCrabill 路 Pull Request #185 路 PX4/NuttX 路 GitHub) and enable all the CAN related config with the make cubepilot_cubeorange menuconfig menu. I also create a custom driver that I manually run in the NuttX shell to initialize the 鈥渃an0鈥 interface that calls stm32_fdcansockinitialize(0) in its main. Also in the NuttX shell, I manually bring up the 鈥渃an0鈥 interface with ifup can0 and double-check that it鈥檚 up with ifconfig. This setup works with this version and I鈥檓 able to read from my CAN sensor (using a custom module and even with candump).

Now I鈥檝e got another system that requires v1.12.3 and uses the same sensor and flight controller. When I repeat the process above, I鈥檓 unable to communicate with the CAN sensor. From what I can see, it seems that everything hangs on a poll() function waiting for a file descriptor to become ready.

Anyone have success in getting SocketCAN working with v1.12.3? There are obviously other changes that have been added between v1.12.3 and v1.13.2, so maybe I need additional files to get it working? Thanks in advance!

Hi cegar
I also have the demand to communicate with a sensor through CAN. However, I found that in hardware which uses stm32h7 chip, the normal method of read() and write() can port can not be used. It seems that you achieved that by using SocketCAN, can you give a brief instruction about how to get it work? Or can you please show me some code of confuguring and reading CAN port. Thanks a lot!

Hi Tink,
Have you any progress with your issue?
I need to implement can driver for some device and stuck with it.I鈥檓 using stm32h7 (CubeOrange).
Could you help with this issue?
Thanks.

Hi Vlad
I finally get it through by using socket can method, which differs from normal can driver and read/write method.
Pls check out this article: