Sergej Herbert
Sergej Herbert

Reputation: 873

How to browse the nodes of an OPC UA server with Rust?

I want to browse a known OPC UA server endpoint to get the nodes in order to poll them later with Rust.

I have been using the locka99/opcua crate and managed to use their samples to read values of known nodes (of the sample server), but I can not get any browsing to work.

There is a browse method on the session struct, but it requires a BrowseDescription as argument, which in itself requires already a NodeId:

session.browse(BrowseDescription {
    // how can I know the parameters?
})

How can I build the BrowseDescription struct (with a NodeId) if the NodeId is what I am looking for?

Upvotes: 2

Views: 1068

Answers (1)

VSDekar
VSDekar

Reputation: 1821

I know it is a very old question, but since I stumbled over this as well, here is what I found in an issue from the linked repo. This helped me to get started:

https://github.com/locka99/opcua/issues/105#issuecomment-813046915

let results = session.browse(&[BrowseDescription {
  node_id: ObjectId::RootFolder.into(),
  browse_direction: BrowseDirection::Forward,
  reference_type_id:  ReferenceTypeId::Organizes,
  include_subtypes: true,
  node_class_mask: 0,
  result_mask: BrowseDescriptionResultMask::all().bits() as u32,
}]);

Upvotes: 2

Related Questions