#opc-ua #plc #automation #safe-bindings #hardware #protocols #api-bindings

open62541

High-level, safe bindings for the C99 library open62541, an open source and free implementation of OPC UA (OPC Unified Architecture)

7 releases (4 breaking)

0.6.0-pre.2 Apr 12, 2024
0.6.0-pre.1 Apr 5, 2024
0.5.0 Mar 1, 2024
0.4.0 Feb 12, 2024
0.2.2 Jan 12, 2024

#533 in Network programming

Download history 7/week @ 2024-01-06 18/week @ 2024-01-13 44/week @ 2024-01-20 3/week @ 2024-01-27 30/week @ 2024-02-03 45/week @ 2024-02-10 74/week @ 2024-02-17 164/week @ 2024-02-24 69/week @ 2024-03-02 20/week @ 2024-03-09 2/week @ 2024-03-16 41/week @ 2024-03-30 81/week @ 2024-04-06 39/week @ 2024-04-13

161 downloads per month

MPL-2.0 license

220KB
3.5K SLoC

open62541

crates.io Docs Dependencies Testing License: MPL 2.0

This crate provides high-level, safe bindings for the C99 library open62541, an open source and free implementation of OPC UA.


lib.rs:

Rust wrapper for the open62541 library.

Examples

Connect to server

use open62541::AsyncClient;

#
let client = AsyncClient::new("opc.tcp://opcuademo.sterfive.com:26543")?;
#

Read node's value attribute

use open62541::ua::NodeId;

#
#
let node_id = NodeId::numeric(0, 2258); // Server/ServerStatus/CurrentTime

let value = client.read_value(&node_id).await?;

println!("Received value: {value:?}");
#

Watch node for changes in value attribute

#
#
#
#
// Create subscription that receives the updates.
let subscription = client.create_subscription().await?;
// Create monitored item to receive node updates.
let mut monitored_item = subscription.create_monitored_item(&node_id).await?;

while let Some(value) = monitored_item.next().await {
    println!("Received value: {value:?}");
}
#

Dependencies

~8–12MB
~221K SLoC