Skip to content

Commit aa18978

Browse files
committed
l5x release
1 parent 9a3c6ab commit aa18978

3 files changed

Lines changed: 123 additions & 4 deletions

File tree

‎Cargo.lock‎

Lines changed: 11 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎l5x/Cargo.toml‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,19 @@
22
name = "l5x"
33
version = "0.3.0"
44
edition = "2021"
5-
description = "Tools for parsing and analyzing PLC software"
5+
description = "Parser for Rockwell Automation L5X files (Studio 5000 Logix Designer)"
66
license = "MIT"
7+
repository = "https://github.com/radevgit/plc"
8+
homepage = "https://github.com/radevgit/plc"
9+
documentation = "https://docs.rs/l5x"
10+
readme = "README.md"
11+
keywords = ["plc", "l5x", "rockwell", "allen-bradley", "ladder-logic"]
12+
categories = ["parsing", "development-tools"]
13+
authors = ["radevgit"]
14+
rust-version = "1.70"
715

816
[dependencies]
917
quick-xml = { version = "0.37", features = ["serialize", "overlapped-lists"] }
1018
serde = { version = "1.0", features = ["derive"] }
1119
winnow = "0.6"
12-
iecst = { path = "../iecst" }
20+
iecst = "0.1"

‎l5x/README.md‎

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# l5x
2+
3+
A Rust library for parsing Rockwell Automation L5X files exported from Studio 5000 Logix Designer.
4+
5+
## Features
6+
7+
- **Fast, type-safe parsing** using quick-xml and serde
8+
- **Complete L5X schema support** - 247 types generated from the official XSD
9+
- **RLL (Relay Ladder Logic) parsing** - parse ladder logic instructions into AST
10+
- **Tag reference extraction** - find all tag references in rungs
11+
12+
## Installation
13+
14+
Add to your `Cargo.toml`:
15+
16+
```toml
17+
[dependencies]
18+
l5x = "0.3"
19+
```
20+
21+
## Usage
22+
23+
### Parse an L5X file
24+
25+
```rust
26+
use l5x::Project;
27+
28+
let xml = std::fs::read_to_string("project.L5X")?;
29+
let project: Project = l5x::from_str(&xml)?;
30+
31+
// Access controller information
32+
println!("Controller: {}", project.controller.name);
33+
34+
// Iterate over programs
35+
for program in &project.controller.programs.program {
36+
println!("Program: {}", program.name);
37+
}
38+
```
39+
40+
### Parse ladder logic rungs
41+
42+
```rust
43+
use l5x::rll::parse_rung;
44+
45+
let rung = parse_rung("XIC(Start)OTE(Motor);");
46+
47+
// Extract tag references
48+
for tag in rung.tag_references() {
49+
println!("Tag: {} ({})", tag.name, if tag.is_write { "write" } else { "read" });
50+
}
51+
```
52+
53+
### Access tags and data types
54+
55+
```rust
56+
use l5x::Project;
57+
58+
let project: Project = l5x::from_str(&xml)?;
59+
60+
// Controller-scoped tags
61+
if let Some(tags) = &project.controller.tags {
62+
for tag in &tags.tag {
63+
println!("Tag: {} : {}", tag.name, tag.data_type);
64+
}
65+
}
66+
67+
// User-defined types
68+
if let Some(datatypes) = &project.controller.data_types {
69+
for dt in &datatypes.data_type {
70+
println!("DataType: {}", dt.name);
71+
}
72+
}
73+
```
74+
75+
## L5X File Format
76+
77+
L5X is an XML-based export format for Rockwell Automation PLCs. This crate supports:
78+
79+
- **Controllers**: ControlLogix, CompactLogix
80+
- **Programs**: with routines in RLL, ST, FBD, SFC
81+
- **Tags**: Controller and program-scoped
82+
- **Data Types**: Built-in and user-defined (UDTs)
83+
- **Add-On Instructions (AOIs)**
84+
- **Modules**: I/O configuration
85+
- **Tasks**: Continuous, periodic, event
86+
87+
## RLL Instruction Support
88+
89+
The RLL parser handles standard ladder logic syntax:
90+
91+
- **Instructions**: XIC, XIO, OTE, OTL, OTU, TON, TOF, CTU, CTD, MOV, ADD, etc.
92+
- **Branches**: Parallel and series connections
93+
- **Expressions**: Arithmetic and comparison in CMP, CPT, etc.
94+
- **Arrays**: Multi-dimensional with literal or tag indices
95+
- **Structured tags**: Member access (e.g., `Timer.DN`)
96+
97+
## Disclaimer
98+
99+
This is an independent open-source project and is not affiliated with, endorsed by, sponsored by, or associated with Rockwell Automation, Inc. or any of its subsidiaries or affiliates.
100+
101+
"Rockwell Automation", "Allen-Bradley", "Studio 5000", "Logix Designer", "ControlLogix", and "CompactLogix" are trademarks of Rockwell Automation, Inc.
102+

0 commit comments

Comments
 (0)