9个不稳定版本 (3个破坏性版本)

0.4.3 2022年11月17日
0.4.2 2022年9月22日
0.4.1 2022年8月26日
0.4.0 2022年6月13日
0.0.1 2018年5月1日

#456硬件支持

Download history · Rust 包仓库 47/week @ 2024-03-31 · Rust 包仓库 9/week @ 2024-04-07 · Rust 包仓库 32/week @ 2024-04-14 · Rust 包仓库 28/week @ 2024-04-21 · Rust 包仓库 9/week @ 2024-04-28 · Rust 包仓库 16/week @ 2024-05-05 · Rust 包仓库 23/week @ 2024-05-12 · Rust 包仓库 23/week @ 2024-05-19 · Rust 包仓库 16/week @ 2024-05-26 · Rust 包仓库 23/week @ 2024-06-02 · Rust 包仓库 17/week @ 2024-06-09 · Rust 包仓库 21/week @ 2024-06-16 · Rust 包仓库 23/week @ 2024-06-23 · Rust 包仓库 2/week @ 2024-06-30 · Rust 包仓库 42/week @ 2024-07-07 · Rust 包仓库 32/week @ 2024-07-14 · Rust 包仓库

每月100 次下载
用于 ads-proxy

MIT/Apache

155KB
3K SLoC

ads

Build status crates.io docs.rs

此crate允许连接到Beckhoff TwinCAT设备和其他使用ADS(自动化设备规范)协议的服务器。

安装

使用Cargo作为通常操作,无需系统依赖。

[dependencies]
ads = "0.4"

Rust版本

最低支持的Rust版本是1.48.0。

使用方法

一个简单的示例

fn main() -> ads::Result<()> {
    // Open a connection to an ADS device identified by hostname/IP and port.
    // For TwinCAT devices, a route must be set to allow the client to connect.
    // The source AMS address is automatically generated from the local IP,
    // but can be explicitly specified as the third argument.
    let client = ads::Client::new(("plchost", ads::PORT), ads::Timeouts::none(),
                                  ads::Source::Auto)?;

    // Specify the target ADS device to talk to, by NetID and AMS port.
    // Port 851 usually refers to the first PLC instance.
    let device = client.device(ads::AmsAddr::new([5, 32, 116, 5, 1, 1].into(), 851));

    // Ensure that the PLC instance is running.
    assert!(device.get_state()?.0 == ads::AdsState::Run);

    // Request a handle to a named symbol in the PLC instance.
    let handle = Handle::new(device, "MY_SYMBOL")?;

    // Read data in form of an u32 from the handle.
    let value: u32 = handle.read_value()?;
    println!("MY_SYMBOL value is {}", value);

    // Connection will be closed when the client is dropped.
    Ok(())
}

功能

实现了所有ADS请求。

其他功能包括从通道接收通知的支持、通过ADS进行文件访问以及通过UDP通信以识别ADS系统和自动设置路由。

示例

名为adstool的工具位于examples/下,与C++库提供的类似。

依赖项

~3.5MB
~64K SLoC