Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bruceunx/rs-melsec
https://github.com/bruceunx/rs-melsec
Last synced: 6 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/bruceunx/rs-melsec
- Owner: bruceunx
- License: mit
- Created: 2024-08-02T06:12:58.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-08-03T06:43:12.000Z (4 months ago)
- Last Synced: 2024-08-04T07:47:44.036Z (4 months ago)
- Language: Rust
- Size: 50.8 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rs-melsec
rs-melsec is a Rust implementation of the MELSEC Communication Protocol that allows you to interact with Mitsubishi PLCs. Inspired by the `pymcprotocol` and `pymelsec` libraries, `rs-melsec` aims to provide additional features and enhanced flexibility, while leveraging the safety and performance benefits of the Rust programming language.
## Installation
> Add `rs-melsec` to your `Cargo.toml`:
```toml
[dependencies]
rs-melsec = "0.1.0"
```## Usage
```rust
use rs_melsec::client::Client;
use rs_melsec::db::DataType;
use rs_melsec::tag::QueryTag;
use std::env;fn main() {
let args: Vec = env::args().collect();
let host = args.get(1).expect("failed to get host");
let default_port = 6000;
let num_port = args
.get(2)
.and_then(|s| s.parse::().ok())
.or(Some(default_port))
.unwrap();let mut tags = Vec::new();
tags.push(QueryTag {
device: "M8304".to_string(),
data_type: DataType::BIT,
});
let client = Client::new(host.to_string(), num_port, "iQ-R", true);
let result = client.read(tags).expect("failed to read data");
for tag in result {
println!("{}", tag);
}
}
```> run `cargo run --bin host port`