Skip to content

Changes required in STM CAN read API #14677

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 25, 2021

Conversation

MubeenHCLite
Copy link
Contributor

@MubeenHCLite MubeenHCLite commented May 19, 2021

Summary of changes

Added working functionality for both bxCAN and FDCAN where the CAN can accept filter IDs and work as desired.
FIFO selection in case of can_read is not supported as the can_filter sets FIFO0 as default FIFO, and the same is updated.

Impact of changes

Migration actions required

Documentation


Pull request type

[x] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results

Tests were carried out on both FDCAN and bxCAN, where multiple IDs were updated to be filtered on multiple CAN instances.
Results were verified that the filtering is as required.

[] No Tests required for this change (E.g docs only update)
[x] Covered by existing mbed-os tests (Greentea or Unittest)
[] Tests / results supplied as part of this PR

Reviewers


@ciarmcom ciarmcom requested review from a team May 19, 2021 06:30
@ciarmcom
Copy link
Member

@MubeenHCLite, thank you for your changes.
@ARMmbed/team-st-mcd @ARMmbed/mbed-os-maintainers please review.

Copy link
Contributor

@0xc0170 0xc0170 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise LGTM

@@ -956,8 +958,10 @@ int can_write(can_t *obj, CAN_Message msg, int cc)

int can_read(can_t *obj, CAN_Message *msg, int handle)
{

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this empty space is not needed?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MubeenHCLite ping :-)

@0xc0170
Copy link
Contributor

0xc0170 commented May 21, 2021

@MubeenHCLite Please fill in the sections in the pull request template (PR type, how was it tested)

@adbridge
Copy link
Contributor

@MubeenHCLite could you please fill in the PR template header correctly as per the guidelines provided.

@ciarmcom ciarmcom added the stale Stale Pull Request label Jun 1, 2021
@ciarmcom
Copy link
Member

ciarmcom commented Jun 1, 2021

This pull request has automatically been marked as stale because it has had no recent activity. , please complete review of the changes to move the PR forward. Thank you for your contributions.

@mergify
Copy link

mergify bot commented Jun 1, 2021

This PR cannot be merged due to conflicts. Please rebase to resolve them.

@ciarmcom ciarmcom removed the stale Stale Pull Request label Jun 1, 2021
@0xc0170 0xc0170 added the release-type: patch Indentifies a PR as containing just a patch label Jun 2, 2021
@0xc0170
Copy link
Contributor

0xc0170 commented Jun 11, 2021

Please rebase instead of merging (clean linear history). Commit b6cab7 should not be in the pull request

@0xc0170 0xc0170 self-requested a review June 14, 2021 09:25
@0xc0170
Copy link
Contributor

0xc0170 commented Jun 14, 2021

Can this be rebased and we can proceed?

@MubeenHCLite
Copy link
Contributor Author

I have rebased the branch to current master head

Copy link
Collaborator

@jeromecoutant jeromecoutant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment from @cindyli-13 not fully addressed.
Seems that multiple filter configuration can be supported

@MubeenHCLite
Copy link
Contributor Author

Comment from @cindyli-13 not fully addressed.
Seems that multiple filter configuration can be supported

@cindyli-13 has already confirmed it is working fine

@jeromecoutant
Copy link
Collaborator

@cindyli-13 has already confirmed it is working fine

So maybe comments like
"message filter handle is not supported for STM controllers"
Have to be reconsidered ?

@MubeenHCLite MubeenHCLite force-pushed the corrections_in_STM_canapi branch from 6b6cab7 to 4c47d15 Compare June 14, 2021 14:19
@mergify
Copy link

mergify bot commented Jun 14, 2021

This PR cannot be merged due to conflicts. Please rebase to resolve them.

@cindyli-13
Copy link
Contributor

Comment from @cindyli-13 not fully addressed.
Seems that multiple filter configuration can be supported

@cindyli-13 has already confirmed it is working fine

Sorry if I wasn't clear earlier. I tested using a different Mbed patch and can confirm that I am able to configure multiple CAN filters. However I think that this PR will prevent the ability to configure multiple CAN filters because the can_filter() function will exit without configuring a filter if the filter handle is not 0.

@MubeenHCLite
Copy link
Contributor Author

I will complete the implementation shortly and submit the PR

@MubeenHCLite
Copy link
Contributor Author

Added working code to accept filter IDs for both bxCAN and FDCAN. Tested the patch on multiple can instances and results are as desired.

Note : Currently there is no way we can configure the number of standard/extended IDs to be filtered in FDCAN (List size Standard, list Size extended, refer RM), hence they are by default set to maximum possible values.

@pilotak
Copy link
Contributor

pilotak commented Jun 23, 2021

I can confirm that it works and fixes the handle addressing

Here is a test code, only 0xFF0080 and 0xFF0580 is received

#include <mbed.h>
CAN can(PB_8, PB_9);
DigitalOut can_sleep(PB_7, 0);

#define ID   0xFF0080
#define ID2  0xFF0580
#define MASK 0xFFFFFF

int main() {
    can.frequency(250000);
    can.mode(CAN::Normal);
    can.filter(ID, MASK, CANExtended, 0);
    can.filter(ID2, MASK, CANExtended, 1);

    CANMessage msg;
    printf("start\n");

    while (1) {
        if (can.read(msg)) {
            printf("Message received ID: %X\n", msg.id);
        }
    }
}

It would be nice if following warnings could be fixed as well

[Warning] stm32g4xx_hal_fdcan.h@1327,49: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
[Warning] stm32g4xx_hal_fdcan.h@1327,68: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
[Warning] stm32g4xx_hal_fdcan.h@1325,61: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
[Warning] stm32g4xx_hal_fdcan.h@1325,84: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
[Warning] stm32g4xx_hal_fdcan.h@1331,46: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
[Warning] stm32g4xx_hal_fdcan.h@1331,65: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
[Warning] stm32g4xx_hal_fdcan.h@1325,61: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
[Warning] stm32g4xx_hal_fdcan.h@1325,84: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]

@MubeenHCLite
Copy link
Contributor Author

@pilotak
Thanks for the confirmation on working status.

We will take up resolving all the warnings in a separate issue.

@jeromecoutant
Copy link
Collaborator

We will take up resolving all the warnings in a separate issue.

ST_INTERNAL_REF 109607

@0xc0170 0xc0170 added needs: review release-type: patch Indentifies a PR as containing just a patch and removed needs: work labels Jun 24, 2021
Copy link
Contributor

@0xc0170 0xc0170 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one style nit

@@ -1130,6 +1135,8 @@ int can_filter(can_t *obj, uint32_t id, uint32_t mask, CANFormat format, int32_t
{
success = 1;
}
} else if (format == CANAny) {
success = 0; // filter for CANAny is not supported by STM32, return a failure
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aligned to 4 spaces (it's just 2?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected the alignment

@mergify mergify bot dismissed 0xc0170’s stale review June 25, 2021 06:38

Pull request has been modified.

@0xc0170
Copy link
Contributor

0xc0170 commented Jun 25, 2021

CI started

@mbed-ci
Copy link

mbed-ci commented Jun 25, 2021

Jenkins CI Test : ✔️ SUCCESS

Build Number: 1 | 🔒 Jenkins CI Job | 🌐 Logs & Artifacts

CLICK for Detailed Summary

jobs Status
jenkins-ci/mbed-os-ci_unittests ✔️
jenkins-ci/mbed-os-ci_build-cloud-example-ARM ✔️
jenkins-ci/mbed-os-ci_cmake-cloud-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-greentea-ARM ✔️
jenkins-ci/mbed-os-ci_build-cloud-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_cmake-cloud-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-greentea-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_cmake-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_cmake-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_greentea-test ✔️

@0xc0170 0xc0170 merged commit de7e326 into ARMmbed:master Jun 25, 2021
@mergify mergify bot removed the ready for merge label Jun 25, 2021
@mbedmain mbedmain added release-version: 6.13.0 Release-pending and removed release-type: patch Indentifies a PR as containing just a patch Release-pending labels Jul 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants