MCPcopy Index your code
hub / github.com/Rahix/profirust

github.com/Rahix/profirust @v0.6.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.6.0 ↗ · + Follow
503 symbols 1,285 edges 39 files 53 documented · 11%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

profirust

crates.io page docs.rs page CI

A PROFIBUS-DP compatible communication stack written in Rust.

What's this?

profirust is a pure-Rust PROFIBUS-DP compatible communication stack. PROFIBUS is an industrial bus protocol used to communicate with field devices like remote I/O, transducers, valves, drives, etc.

If you want to learn more, I suggest reading my blog posts about profirust or my PROFIBUS Primer.

Project Status

profirust works well for the features it currently supports, however it has not proven itself in a real application yet. There are still some features missing which are needed for production use. Check the roadmap below.

At this time, profirust is developed as a spare time project. If you are interested in this project, help is gladly accepted in the following forms:

  • Code Contributions
  • Donation of PROFIBUS peripherals or other equipment for testing purposes
  • Funding of access to the needed IEC standards for improving compliance
  • Reporting any kinds of issues encountered while using profirust

Supported Hardware

profirust is designed to have as little hardware dependency as possible. All you need is a UART interface with an RS-485 transceiver. You can then write a matching implementation of [ProfibusPhy]. It is encouraged to submit such implementations for inclusion in profirust.

At the moment, the following implementations are available:

  • [SerialPortPhy]: Platform-independent PHY implementation for serial port devices
  • [LinuxRs485Phy]: Linux userspace PHY implementation for UART TTY devices
  • [Rp2040Phy]: Implementation for RP2040 microcontrollers
  • Planned: Generic implementation for [embedded-hal]-supported microcontrollers

Roadmap

  • [x] Single-master bus up to 6 Mbit/s
  • [x] Cyclic communication with DP-V0 peripherals
  • [x] Basic Diagnostics
  • [x] Extended Diagnostics (DP-V0)
  • [x] Multi-master bus
  • [x] Bus discovery utilities
  • [ ] Bus error tracking
  • [ ] Reliable communication at 12 Mbit/s
  • [ ] Communication with DP-V1 peripherals
  • [ ] Equidistant bus cycle
  • [ ] Isochronous bus cycle
  • [ ] Passive Station (Peripheral)

Getting Started

This is a short guide for getting communication up and running with your PROFIBUS peripheral:

  1. Find the GSD (generic station description) file for your peripheral. Usually, the manufacturer offers these for download somewhere.
  2. Run the gsdtool to set up the configuration and parameterization of your peripheral: bash cargo run -p gsdtool -- config-wizard path/to/peripheral.gsd The configuration wizard will walk you through all the settings you need to make. At this stage, you also need to setup the modules of your peripheral. The wizard will then give you Rust code for configuring the peripheral options to your selected values.
  3. Modify an example for your peripheral. Update the peripheral address. Then paste the PeripheralOptions block and I/O buffers that gsdtool emitted.
  4. Run the example, ideally with RUST_LOG=trace to see bus communication. Hopefully, you should now be able to establish cyclic communication with your peripheral.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Extension points exported contracts — how you extend this code

ProfibusPhy (Interface)
Generic abstraction for `profirust` PHY implementations [4 implementers]
src/phy/mod.rs
FdlApplication (Interface)
The interface for application layer components. Only one application layer component is permitted per FDL master. [4 implementers]
src/fdl/mod.rs

Core symbols most depended-on inside this repo

parse_number
called by 46
gsd-parser/src/parser.rs
next
called by 46
src/phy/simulator.rs
send_token_telegram
called by 38
src/fdl/telegram.rs
iter
called by 33
src/dp/master.rs
witness_token_pass
called by 27
src/fdl/token_ring.rs
parameters
called by 26
src/fdl/active.rs
parse_bool
called by 19
gsd-parser/src/parser.rs
parse_string_literal
called by 16
gsd-parser/src/parser.rs

Shape

Method 322
Function 82
Class 61
Enum 36
Interface 2

Languages

Rust100%

Modules by API surface

src/fdl/active.rs80 symbols
src/fdl/telegram.rs45 symbols
src/fdl/test_active.rs40 symbols
gsd-parser/src/lib.rs33 symbols
src/time.rs27 symbols
src/phy/simulator.rs25 symbols
src/dp/peripheral.rs24 symbols
src/dp/master.rs23 symbols
src/dp/diagnostics.rs22 symbols
src/fdl/token_ring.rs21 symbols
src/fdl/parameters.rs21 symbols
src/phy/linux.rs14 symbols

For agents

$ claude mcp add profirust \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact