l5x
A Rust library for parsing Rockwell Automation L5X files exported from Studio 5000 Logix Designer.
Features
- RLL (Relay Ladder Logic) parsing - parse ladder logic instructions into AST
- Tag reference extraction - find all tag references in rungs
- Security/Safety features - protection against certan type of badly formed XML
Installation
Add to your Cargo.toml:
[]
= "0.4"
Usage
Parse an L5X file
use Project;
let xml = read_to_string?;
let project: Project = from_str?;
// Access controller information
println!;
// Iterate over programs
for program in &project.controller.programs.program
Parse with security limits (recommended for untrusted files)
use ;
// Use strict limits for untrusted input
let limits = strict;
let xml = read_to_string?;
match
// Available profiles:
// - SecurityLimits::strict() - For untrusted input (10 MB, 32 levels)
// - SecurityLimits::balanced() - For typical files (100 MB, 100 levels)
// - SecurityLimits::relaxed() - For trusted files (500 MB, 256 levels)
Parse ladder logic rungs
use parse_rung;
let rung = parse_rung;
// Extract tag references
for tag in rung.tag_references
Access tags and data types
use Project;
let project: Project = from_str?;
// Controller-scoped tags
if let Some = &project.controller.tags
// User-defined types
if let Some = &project.controller.data_types
L5X File Format
L5X is an XML-based export format for Rockwell Automation PLCs. This crate supports:
- Controllers: ControlLogix, CompactLogix
- Programs: with routines in RLL, ST, FBD, SFC
- Tags: Controller and program-scoped
- Data Types: Built-in and user-defined (UDTs)
- Add-On Instructions (AOIs)
- Modules: I/O configuration
- Tasks: Continuous, periodic, event
RLL Instruction Support
The RLL parser handles standard ladder logic syntax:
- Instructions: XIC, XIO, OTE, OTL, OTU, TON, TOF, CTU, CTD, MOV, ADD, etc.
- Branches: Parallel and series connections
- Expressions: Arithmetic and comparison in CMP, CPT, etc.
- Arrays: Multi-dimensional with literal or tag indices
- Structured tags: Member access (e.g.,
Timer.DN)
Disclaimer
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.
"Rockwell Automation", "Allen-Bradley", "Studio 5000", "Logix Designer", "ControlLogix", and "CompactLogix" are trademarks of Rockwell Automation, Inc.