Skip to content
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

Fix cpp implementations #255

Merged
merged 9 commits into from
May 18, 2022
Merged

Conversation

asmfreak
Copy link
Contributor

@asmfreak asmfreak commented May 16, 2022

This patch includes some quality-of-life improvements:

  1. All external methods in serialization support header-only library are now marked with inline to avoid linker errors if serialization code was included from several different translation units.
  2. Refactor bitspan constructors to make user code easier and should fix Fatal error in serialization.hpp of cpp output #254.
uavcan::node::Heartbeat_1_0 hb{};
std::array<uint8_t, uavcan::node::Heartbeat_1_0::SERIALIZATION_BUFFER_SIZE_BYTES> data;

// before change:
hb.serialize({{data}, 0});

// after change:
hb.serialize(data);
  1. Change naming of service types from uavcan::node::GetInfo_1_0::Request_1_0 to uavcan::node::GetInfo::Request_1_0
  2. Add a special service type alongside Request and Response and some constexpr boolean traits to ease templating on services:
namespace uavcan
{
namespace node
{
namespace GetInfo
{
struct Request_1_0 final
{
    // ...
    static constexpr bool IsServiceType = true;
    static constexpr bool IsService = false;
    static constexpr bool IsRequest = true;
    static constexpr bool IsResponse = false;
    // ...
};

struct Response_1_0 final
{
    // ...
    static constexpr bool IsServiceType = true;
    static constexpr bool IsService = false;
    static constexpr bool IsRequest = false;
    static constexpr bool IsResponse = true;
    // ...
};

struct Service_1_0 {
    static constexpr bool IsServiceType = true;
    static constexpr bool IsService = true;
    static constexpr bool IsRequest = false;
    static constexpr bool IsResponse = false;

    using Request = Request_1_0;
    using Response = Response_1_0;
};

} // namespace GetInfo_1_0
} // namespace node
} // namespace uavcan

@asmfreak asmfreak marked this pull request as ready for review May 16, 2022 23:26
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

84.0% 84.0% Coverage
0.0% 0.0% Duplication

@thirtytwobits thirtytwobits merged commit cbf871c into OpenCyphal:main May 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fatal error in serialization.hpp of cpp output
2 participants