Skip to content

Refactor p-net into Rust for Enhanced Safety and Modernization #589

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

Open
DonavanMartin opened this issue Jun 2, 2025 · 0 comments
Open

Comments

@DonavanMartin
Copy link

Description

This issue proposes refactoring the p-net library, which implements the PROFINET protocol for industrial automation, from C into Rust. The goal is to create a Rust-native implementation (p-net-rs) that maintains p-net’s functionality while leveraging Rust’s memory safety, concurrency, and modern ecosystem to improve reliability and developer experience in real-time industrial applications.

Motivation

  • No Rust Equivalent: As of June 2025, there is no mature Rust library for PROFINET, despite Rust’s growing adoption in industrial systems.
  • Safety: Rust eliminates C issues like buffer overflows and memory leaks, critical for PROFINET’s real-time, safety-critical use cases.
  • Performance: Rust’s performance is comparable to C, suitable for PROFINET’s real-time requirements.
  • Ecosystem: Integration with Rust crates (e.g., tokio for async networking) can enhance p-net for Industry 4.0 applications.

Goals

  • Develop a Rust-native p-net-rs library supporting core PROFINET features (e.g., RT communication, device discovery, cyclic data exchange).
  • Ensure compatibility with industrial systems (e.g., PLCs, Siemens devices).
  • Provide idiomatic Rust APIs that are safe and easy to use.
  • Support cross-platform use (Linux, Windows, RTOS).

Non-Goals

  • Replacing the C implementation (Rust version can coexist).
  • Adding new PROFINET features beyond the current implementation.

Proposed Approach

Setup:

  • Create a new repo (p-net-rs) or Rust submodule in p-net.
  • Use cargo and MIT license (matching p-net).

Implementation:

  • Port PROFINET stack (e.g., DCE/RPC, RT messaging) to Rust with safe abstractions.
  • Use tokio or smol for async Ethernet communication.
  • Implement core features: device identification, cyclic I/O, alarms.

Testing:

  • Unit tests with cargo test.
  • Integration tests with PROFINET devices or simulators (e.g., Siemens TIA Portal).

Documentation:

Rustdoc and examples for common PROFINET use cases (e.g., factory automation).

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

No branches or pull requests

1 participant