Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Extend CanMsg to allow to distinguish between standard and extended ids …#194

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
aentinger merged 14 commits intomasterfromfix-11-bit-can-id
Sep 4, 2023

Conversation

aentinger
Copy link
Contributor

… following a <linux/can.h> inspired approach.

designer2k2 reacted with thumbs up emoji
…Ds following a <linux/can.h> inspired approach.
@aentingeraentinger self-assigned thisAug 2, 2023
@codecov-commenter
Copy link

codecov-commenter commentedAug 2, 2023
edited
Loading

Codecov Report

Patch coverage:100.00% and project coverage change:+0.16% 🎉

Comparison is base(84b98c7) 95.77% compared to head(e091080) 95.93%.

Additional details and impacted files
@@            Coverage Diff             @@##           master     #194      +/-   ##==========================================+ Coverage   95.77%   95.93%   +0.16%==========================================  Files          13       14       +1       Lines         970     1009      +39     ==========================================+ Hits          929      968      +39  Misses         41       41
Files ChangedCoverage Δ
api/CanMsg.h100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report?Share it here.

…n order to eliminate the 3 MSBits encoded status flags.
… files, inline functions to prevent linker errors, and define static constants so that the compiler can place them in memory. All of those changes broaden adoption.
@aentinger
Copy link
ContributorAuthor

Hi@facchinm ☕ 👋

This PR is required by

which support both standard (11-Bit) and extended (29-Bit) CAN IDs by the respective platform libraries.

I'm not a 💯 on the proposed design, especiallyid still being a publicly exposed member variable. Personally I'd like to turnid private, something that would also work with both aforementioned pull requests, but may cause problems for users which have already adopted the new CAN API. I'd love to hear your thoughts on this.

Copy link

@thirtytwobitsthirtytwobits left a comment

Choose a reason for hiding this comment

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

Really exciting to see CAN move forward in Arduino and looking forward to CAN-FD support in this header.

@@ -82,11 +92,45 @@ class CanMsg : public Printable
return n;
}


uint32_t getStandardId() const {

Choose a reason for hiding this comment

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

Would it make sense to make the ID an ADT? That way you could have something like:

class CanId : public Printable{    virtual uint32_t toInt() const = 0;};class ExtendedCanId : public CanId...class StandardCanId: public CanId...

This would allow libraries to be written that extend this to things like:

class DroneCANId : public ExtendedCanId...class CyphalId : public ExtendedCandId...class ARINC825 : public ExtendedCanId...// etc.

@@ -31,14 +33,19 @@ namespace arduino
class CanMsg : public Printable
{
public:
static size_t constexpr MAX_DATA_LENGTH = 8;
static uint8_t constexpr MAX_DATA_LENGTH = 8;

Choose a reason for hiding this comment

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

Of course, the thing that is most irksome when you finally add CAN-FD support is the quantization of the DLC. If you are trying to get ahead of adoption and avoid future churn you might want to start moving away from an integer data_length type to an enumerated one now.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I had been thinking of making aCanFdMsg whoseMAX_DATA_LENGTH would be 64 then. Overall I'm a fan ofconst/constexpr overenum because they provide a strong type guarantee (vs.enum that easily and without warning converts to int, etc.).

Note: enum classes in public Arduino APIs are discouraged (they'd provide strong type support).

@facchinm
Copy link
Member

especially id still being a publicly exposed member variable.

I'm ok for leaving it public to keep the APIs space simpler and allow some optimizations for libraries adopting this.

@aentingeraentinger marked this pull request as ready for reviewSeptember 4, 2023 09:46
@aentingeraentinger merged commitfbc0646 intomasterSep 4, 2023
@aentingeraentinger deleted the fix-11-bit-can-id branchSeptember 4, 2023 09:49
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@thirtytwobitsthirtytwobitsthirtytwobits left review comments

@facchinmfacchinmfacchinm approved these changes

Assignees

@aentingeraentinger

Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@aentinger@codecov-commenter@facchinm@thirtytwobits@per1234

[8]ページ先頭

©2009-2025 Movatter.jp