weixin_39583623
weixin_39583623
2021-01-10 10:02

Bypassing libuavcan for Nuttx-CAN interface

Hello,

I have a usecase where I have to use PX4 stack without libuavcan for accessing the Nuttx-CAN interface on Aerocore2 board (based on STM32 microcontroller). Currently I have modelled my CAN module based on the Nuttx CAN example. While executing the module I didn't get any error but I can't see the traffic on CAN bus.

Can anyone, -kirienko provide some input here?

PS: I have used `/dev/can0' as the CAN device as per Nuttx example.

该提问来源于开源项目:PX4/PX4-Autopilot

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

12条回答

  • weixin_39583623 weixin_39583623 3月前

    Moved the topic to discussion forum!

    点赞 评论 复制链接分享
  • weixin_39583623 weixin_39583623 3月前

    Reopening since the associated forum topic is not yet approved by the moderator!

    Can anyone provide some info here?

    点赞 评论 复制链接分享
  • weixin_39520979 weixin_39520979 3月前

    do you know more?

    点赞 评论 复制链接分享
  • weixin_39517520 weixin_39517520 3月前

    -Sadhasivam - you will have to enable the CONFIG_CAN in the nuttx defconfig. See https://github.com/PX4/Firmware/blob/master/src/drivers/boards/aerocore2/can.c#L59-L69

    点赞 评论 复制链接分享
  • weixin_39583623 weixin_39583623 3月前

    I have enabled that option and the write command succeeds but still I can't see any frames on the bus! But with UAVCAN I can see proper CAN frames. Can you see whats going wrong here? I'm sure that the STM32 driver successfully sends the CAN frames and it returns the sent bytes. However the frames are not visible on the CAN bus when probed.

    点赞 评论 复制链接分享
  • weixin_39517520 weixin_39517520 3月前

    -Sadhasivam -

    Am I correct to assume you have uavcan removed from the build when you are testing this?

    Where are you calling dev_caninit()? It should be called late in board_app_initialize

    I would suggest you step through the code and see if the correct bus is being used, and if there are errors reported back by the CAN HW.

    点赞 评论 复制链接分享
  • weixin_39583623 weixin_39583623 3月前

    I'm calling dev_caninit in my module and using CAN bus 1! I did look into the code and debugged it and everything seems to be correct but still nothing on the CAN bus. Is there any pinmux settings need to be set? Is UAVCAN doing anything special than the Nuttx CAN driver?

    There is no error btw from the STM32 CAN driver. It correctly returns the bytes transferred.

    点赞 评论 复制链接分享
  • weixin_39517520 weixin_39517520 3月前

    Pin init is done in stm32_caninitialize - check them in your board.h and see if they match your HW.

    点赞 评论 复制链接分享
  • weixin_39583623 weixin_39583623 3月前

    I have verified the pin settings and everything seems to be correct! Btw, the driver only works with Loopback mode enabled (Send+Receive). Without it, there is no CAN frame eventhough write succeeds.

    点赞 评论 复制链接分享
  • weixin_39622398 weixin_39622398 3月前

    -Sadhasivam the symptoms you described could be because of bad connectivity with other nodes on the bus. Remember, a CAN bus can function only if there are at least two nodes on it.

    点赞 评论 复制链接分享
  • weixin_39583623 weixin_39583623 3月前

    I have nailed down the issue. My CAN sniffer was single-ended, so by mistake I was probing it on CAN-H but it should have done on CAN-L. After correcting this, I can see the frames in CAN bus.

    Thanks everyone for your support!

    点赞 评论 复制链接分享
  • weixin_39886205 weixin_39886205 3月前

    Hi Mani, -Sadhasivam I am trying to do the same. Can you please guide me through the steps. I am not able to find the links mentioned in your issue and replies.

    I am trying to do the same on Pixhawk 4.

    点赞 评论 复制链接分享