how to test uavcan communication with libcanard on STM32

77 views
Skip to first unread message

liub...@gmail.com

unread,
Mar 22, 2018, 8:47:51 AM3/22/18
to UAVCAN
Hi Pavel,

I am trying to create a node for bare metal on STM32F103 platform with libcanard.I referenced the basic tutorial project on https://kb.zubax.com/display/MAINKB/1.+Basic+tutorial, but I do not have a USB-CAN cable on the hand,can I test the UAVCAN communication like the CAN_Mode_LoopBack?Just send a message and receive it automation.

Can a common USB-CAN cable  compatible the  UAVCAN protocol? Or I need a special cable for UAVCAN?

Thanks.

bin

Pavel Kirienko

unread,
Mar 23, 2018, 5:13:45 AM3/23/18
to liub...@gmail.com, UAVCAN
Hello,

> can I test the UAVCAN communication like the CAN_Mode_LoopBack?Just send a message and receive it automation.

Yes.

> Can a common USB-CAN cable  compatible the  UAVCAN protocol?

Yes.

> Or I need a special cable for UAVCAN?

UAVCAN is just a high-level protocol that works on top of CAN, just like CANopen, CANaerospace, DeviceNet, and so on.

Pavel.

--
You received this message because you are subscribed to the Google Groups "UAVCAN" group.
To unsubscribe from this group and stop receiving emails from it, send an email to uavcan+unsubscribe@googlegroups.com.
To post to this group, send email to uav...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/uavcan/de86877f-0ba6-43d8-825f-1a4fb5f03e17%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted

Pavel Kirienko

unread,
Mar 24, 2018, 10:13:14 AM3/24/18
to liub...@gmail.com, UAVCAN
The STM32 driver shipped with Libcanard does not support loopback mode out of the box. You will need to modify the initialization of this register here: https://github.com/UAVCAN/libcanard/blob/636795f4bc395f56af8d2c61d3757b5e762bb9e5/drivers/stm32/canard_stm32.c#L226-L230. The Reference Manual on your STM32 chip will tell you the rest of the story.

Pavel. 

On Fri, Mar 23, 2018 at 2:33 PM, <liub...@gmail.com> wrote:
Hi Pavel,

Thank you for your reply.

To enable the  CAN_Mode_LoopBack modeWhich parameter should I config during the initial process of libcanard? follows is my sw&hw initial code:

static void swInit(void)
{
    int result = 0;
    CanardSTM32CANTimings timings;
    result = canardSTM32ComputeCANTimings(RCC_Clocks.PCLK1_Frequency, 1000000, &timings);
    if(result)
    {
        __ASM volatile("BKPT #01"); 
    }
    result = canardSTM32Init(&timings, CanardSTM32IfaceModeNormal);
    if(result)
    {
        __ASM volatile("BKPT #01"); 
    }
  
    canardInit(&g_canard,                           // Uninitialized library instance
               g_canard_memory_pool,                // Raw memory chunk used for dynamic allocation
               sizeof(g_canard_memory_pool),        // Size of the above, in bytes
               onTransferReceived,                // Callback, see CanardOnTransferReception
               shouldAcceptTransfer,              // Callback, see CanardShouldAcceptTransfer
               NULL); 
    
    canardSetLocalNodeID(&g_canard, 100);
}

static void hwInit(void)
{
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN1, ENABLE);
 
  GPIO_InitTypeDef GPIO_InitStructure;
  
  GPIO_PinAFConfig(CAN_GPIO_PORT, CAN_RX_SOURCE, CAN_AF_PORT);
  GPIO_PinAFConfig(CAN_GPIO_PORT, CAN_TX_SOURCE, CAN_AF_PORT); 

  GPIO_InitStructure.GPIO_Pin = CAN_RX_PIN | CAN_TX_PIN;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(CAN_GPIO_PORT, &GPIO_InitStructure);
}

bin

在 2018年3月23日星期五 UTC+8下午5:13:45,Pavel Kirienko写道:
Hello,

> can I test the UAVCAN communication like the CAN_Mode_LoopBack?Just send a message and receive it automation.

Yes.

> Can a common USB-CAN cable  compatible the  UAVCAN protocol?

Yes.

> Or I need a special cable for UAVCAN?

UAVCAN is just a high-level protocol that works on top of CAN, just like CANopen, CANaerospace, DeviceNet, and so on.

Pavel.
On Thu, Mar 22, 2018 at 2:47 PM, <liub...@gmail.com> wrote:
Hi Pavel,

I am trying to create a node for bare metal on STM32F103 platform with libcanard.I referenced the basic tutorial project on https://kb.zubax.com/display/MAINKB/1.+Basic+tutorial, but I do not have a USB-CAN cable on the hand,can I test the UAVCAN communication like the CAN_Mode_LoopBack?Just send a message and receive it automation.

Can a common USB-CAN cable  compatible the  UAVCAN protocol? Or I need a special cable for UAVCAN?

Thanks.

bin

--
You received this message because you are subscribed to the Google Groups "UAVCAN" group.
To unsubscribe from this group and stop receiving emails from it, send an email to uavcan+un...@googlegroups.com.

To post to this group, send email to uav...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/uavcan/de86877f-0ba6-43d8-825f-1a4fb5f03e17%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "UAVCAN" group.
To unsubscribe from this group and stop receiving emails from it, send an email to uavcan+unsubscribe@googlegroups.com.
To post to this group, send email to uav...@googlegroups.com.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages