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

Implementation of UDP TX #363

Merged
merged 79 commits into from
Jun 26, 2024
Merged

Implementation of UDP TX #363

merged 79 commits into from
Jun 26, 2024

Conversation

serges147
Copy link
Collaborator

@serges147 serges147 commented Jun 21, 2024

  • UDP implementation:
    • TransportDelegate & TransportImp.
    • Defined udp::IMedia, udp::ITxSocket & upd::IRxSocket protocols.
    • Implementation of all 3 TX sessions.
  • Fixed various Sonar issues (after switching to correct "libcyphal" quality profile at Sonar cloud).
  • Increased CAN-related code coverage to 100% (files, lines, functions & branches!).
  • A bit less of code duplication (f.e. libcyphal::detail::UniquePtrSpec helper).
  • Simplifying "swapping" behavior by using std::exchange.

Here is code coverage. Note that low (red) coverage at RX is currently expected - will be addressed by near future next PRs.
image

serges147 added 30 commits May 15, 2024 17:33
@serges147 serges147 self-assigned this Jun 21, 2024
@serges147 serges147 marked this pull request as ready for review June 21, 2024 14:09
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
4.6% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

Comment on lines +35 to +57
struct Publish
{
UdpardMicrosecond deadline_us;
UdpardPriority priority;
UdpardPortID subject_id;
UdpardTransferID transfer_id;
};
struct Request
{
UdpardMicrosecond deadline_us;
UdpardPriority priority;
UdpardPortID service_id;
UdpardNodeID server_node_id;
UdpardTransferID transfer_id;
};
struct Respond
{
UdpardMicrosecond deadline_us;
UdpardPriority priority;
UdpardPortID service_id;
UdpardNodeID client_node_id;
UdpardTransferID transfer_id;
};
Copy link
Member

Choose a reason for hiding this comment

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

Should we not extract the common fields into a new type and use composition with that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Am I right that you are proposing to extract deadline_us, priority & transfer_id to some BaseMetadata?

In general I saw and was aware of this duplication, but decided that a bit of duplication in detail won't hurt but instead will give clear independence/separation of the cases (which are instantiated in 3 different places, and in the end consumed by 3 different operator()-s)...

Copy link
Collaborator Author

@serges147 serges147 Jun 25, 2024

Choose a reason for hiding this comment

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

@pavel-kirienko ? (see above question)

static cetl::optional<AnyError> optAnyErrorFromUdpard(const std::int32_t result)
{
// Udpard error results are negative, so we need to negate them to get the error code.
const std::int32_t canard_error = -result;
Copy link
Member

Choose a reason for hiding this comment

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

udpard_error

Comment on lines +28 to +32
struct IpEndpoint final
{
std::uint32_t ip_address;
std::uint16_t udp_port;
};
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be wiser to alias UdpardUDPIPEndpoint so that you don't have to convert there and back in your code. Also I think it's more accurate to call it a UDP/IP endpoint, not just an IP endpoint.

Copy link
Collaborator Author

@serges147 serges147 Jun 25, 2024

Choose a reason for hiding this comment

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

My thinking was that we are under udp:: namespace, so the type is kinda already has UDP, like udp::IpEndpoint...

@serges147
Copy link
Collaborator Author

@thirtytwobits Scott, how is PR overall? Aproveable? ;)

@serges147 serges147 merged commit 37c2ac5 into main Jun 26, 2024
20 of 21 checks passed
@serges147 serges147 deleted the sshirokov/udp branch June 26, 2024 06:09
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.

3 participants