-
Notifications
You must be signed in to change notification settings - Fork 432
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
feat(plc4rs): Add transport layer with TCP/UDP implementations #2010
base: develop
Are you sure you want to change the base?
Conversation
- Add async S7 protocol parsing with Tokio - Implement fuzz testing infrastructure - Add comprehensive documentation - Set up CI/CD pipeline for Rust
Oh wow :-) Welcome to the project ... this is really something super interesting for us. I had it on my todo list for way too long. Do I understand the PR correctly, that you are currently manually implementing the types needed in order to create the driver? If yes, that's absolutely fine and usually the way I started porting PLC4X to other languages. Once you have most parts implemented, I will definitely help you port that to have that code generated. Please ping me, if you need help with that. I know we have a super-ancient branch in our repo, where Julian once started working on something like that ... perhaps that could also be helpful for you? (https://github.com/apache/plc4x/tree/feature/plc4rs/plc4rust) Chris |
@chrisdutz Thank you for the warm welcome, Chris! Yes, you understood correctly - I'm currently implementing the core types manually to better understand the protocol intricacies and establish a solid foundation for the Rust implementation. This approach helps ensure we leverage Rust's type system and safety features effectively while maintaining high performance. Thank you for pointing out Julian's branch - I'll definitely take a look at it. While starting fresh helped me understand the requirements better, there might be valuable insights there that could inform this implementation. I'm very interested in learning more about the code generation approach you mentioned. Once I have the core types and parsing logic stabilized, I'd greatly appreciate your guidance on integrating with PLC4X's code generation system. Currently focusing on:
I'm hoping to contribute this as part of GSoC 2025, so I wanted to get an early start to demonstrate commitment and gather community feedback. Would you prefer I continue with the manual implementation for now, or would you like to discuss code generation integration earlier in the process? |
Cool :-) This way I might even have some chance to start learning rust ;-) As long as possible, it would be cool, if you could structurally stick to the structures as we define them in the s7 mspec, that will ensure that we can convert your manually written code into generated one a lot easier: https://github.com/apache/plc4x/blob/develop/protocols/s7/src/main/resources/protocols/s7/s7.mspec Also when looking at the java implementation, don't let yourself be confused ... there is also a subscription protocol implemented in parallel in there, which complicates things quite a bit. Usually a reason why I like to start off with Modbus, for porting PLC4X to new languages ... it's definitely the simplest protocol. |
@chrisdutz Thanks Chris! Happy to help you get started with Rust too. The s7.mspec is really helpful - I'll make sure my Rust structs follow these definitions closely. Makes sense about keeping it compatible with the code generation system. About the subscription protocol - I think I'll start with just the basic S7 protocol first to keep things clean. I can look at Modbus too if you think that would be more helpful for understanding the overall architecture. Let me update the current implementation to match the mspec and I'll push the changes soon. |
@chrisdutz I've made some changes:
For now, I'm thinking of the following next steps:
|
I guess in order to review the actual code, it would probably help, if I understood Rust ;-) I can give you some pointers to what's generally important when bringing plc4x to new languages:
The following would be for when the code-gen has generally been implemented:
I'll try to have a look and play around with your driver. Thanks for contributing. |
So from a quick look, I guess we'll need a Maven integration to allow a normal maven build to trigger the rust build, but I think we can borrow things from Julian's branch. Possibly I could create PRs for your PR ... Let me see which form of collaboration works best. |
Add initial SPI layer for PLC4X Rust with: - Transport trait with retry and logging support - TCP transport implementation with configuration - Basic error handling using thiserror - Example showing TCP transport usage This provides the foundation for protocol-specific implementations.
@chrisdutz Hey Chris, Added the initial SPI layer with a basic TCP transport implementation. Kept it focused for now:
Let me know if this looks OK as a starting point. Planning to add UDP and Serial support (in follow-up PRs). |
Wie... Great stuff... I'll look at it ASAP, however it might take a bit as I'm traveling to a music festival over the weekend and next week is the last of my 2,5 month sabbatical... Still some things to finish. Just want you to know that you're not frustrated why I'm so slow... It's not lack of interest, it's too much stuff going on. Looking forward to getting the time to have a deeper lookm |
@chrisdutz No worries at all about the timing, Chris! Enjoy the music festival and your remaining sabbatical time. While you're away, I'll focus on:
I'll keep the changes small and focused to make review easier when you have time. Looking forward to your deeper look whenever you're back! |
- Implement UDP transport following TCP pattern - Add configuration support for UDP - Update example to show both TCP and UDP usage - Add basic UDP transport tests This builds on the TCP transport to provide UDP support for the PLC4X Rust implementation.
PLC4X Rust Implementation
This PR implements the initial transport layer and S7 protocol foundation in Rust. The implementation focuses on memory safety, performance, and maintainability.
Current Features:
Transport Layer (SPI)
Protocol Implementation
Testing
Next Steps:
Technical Details:
Looking forward to feedback on the transport layer implementation before proceeding with the full protocol implementation.