ARMmbed / mbed-os

Arm Mbed OS is a platform operating system designed for the internet of things
https://mbed.com
Other
4.65k stars 2.97k forks source link

[STM32] CAN write() return value #3464

Closed szechyjs closed 7 years ago

szechyjs commented 7 years ago

Description

According to the CAN.h header file the write() method is only supposed to return 1 if send was successful. 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 write was successful.

Actual behavior Returns 1 regardless if write was successful.

Steps to reproduce

if (can1.write(CANMessage(1337, &data, sizeof(data)))
{
    // This will always print
    printf("tx\n");
}
0xc0170 commented 7 years ago

cc @bcostm @adustm @LMESTM @jeromecoutant

adustm commented 7 years ago

Hello @0xc0170 @szechyjs It is not obvious to me that the can_write function is supposed to do some polling as long as the msg is not written. We are just preparing the sending of the the system and setting the interruptions to be notified when the msg is sent.

Cheers

adustm commented 7 years ago

Hello What do we do with this issue ? Is it sure that we are supposed to wait ? I've seen that @Nodraak has created a PR for the read part. Would you be interested into creating a PR for the write part also ?

Cheers

Nodraak commented 7 years ago

Hi !

What is the status here ? It seems that the issue has been fixed by commit 1c4e0d7dcbc78dfa066e64f16213317b8cb91395, as can_write() can sometimes return 0.

adustm commented 7 years ago

Hi,

It seems that the issue has been fixed by commit 1c4e0d7, as can_write() can sometimes return 0.

I think you are right. @szechyjs could you please check if it fits your need and maybe clode the issue ?

Kind regards

0xc0170 commented 7 years ago

I'll close this . Please reopen if any new update