Skip to content

[STM32] CAN read() return value #3463

@szechyjs

Description

@szechyjs

Description

  • Type: Bug
  • Priority: Major

According to the CAN.h header file the read() method is only supposed to return 1 if data was read. All of the STM32 implementations in can_api.c are hard coded to return 1;.

The NXP targets implement this correctly, can_api.c


Bug

Target
STM32

Expected behavior
Only return 1 if new data was read.

Actual behavior
Returns 1 regardless if data was received or not. If a message has previously been received then this will be returned again.

Steps to reproduce

CANMessage msg;
while(true)
{
    if (can1.read(msg))
    {
        // This will always print
        printf("rx -id: %i, data: %x\n", msg.id, *msg.data);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions