Giter Site home page Giter Site logo

Comments (7)

GeneL avatar GeneL commented on June 13, 2024

Hi Joylei,
Great library!
Could you provide examples to read a LARGE structured tag (>500) and list USER DEFINED structure types including the ones > 500.
Thank you in advance,
Eugene Liberman.

from eip-rs.

Joylei avatar Joylei commented on June 13, 2024

@GeneL

The library is able to list UDT for you automatically. You do not need to do additional works. Please check the examples in the repository.

For large structured tag, I think you have 2 options.

  • large forward open
    Check if your devices support large forward open. also check the max connection_size supported by your device.
    make sure connection_size is large enough to hold all the data packet in a single request/response.
    Please check OpenOptions and connection_size.
const CONNECTION_SIZE:u16=2000;
let opts = OpenOptions::default().connection_size(CONNECTION_SIZE).large_open(true);
let mut client =
    AbEipConnection::new_host_lookup("YOUR_DEVICE_IP", opts).await?;
let mut buf = BytesMut::new();
let total:u16 = ...;
loop {
   let (has_more, value): (_,TagValue<Bytes>) = client.read_tag_fragmented(...)
         .total(total).offset(buf.len())
         .call().await;
   let bytes = value.value;
   buf.put_slice(&bytes[...]);
   if !has_more {
        break;
   }
}
// decode your tag data from buf

check source code for how to decode.

from eip-rs.

GeneL avatar GeneL commented on June 13, 2024

from eip-rs.

Joylei avatar Joylei commented on June 13, 2024

let me do a little testing

from eip-rs.

Joylei avatar Joylei commented on June 13, 2024

One possible solution is read your UDT's members separately.

and Let me try read_tag_fragmented.

from eip-rs.

Joylei avatar Joylei commented on June 13, 2024

list tag and type definition

let's say you list tags

...
Ok(SymbolInstance { id: 0x6d10, name: "test_frag", symbol_type: SymbolType { type: "struct", dims: 0, instance_id: 0xa82 } })
...

the template instance id is 0xa82.
Then you read the template for 0xa82:

template instance:
Template { instance_id: 2690, handle: 34287, member_count: 16, object_size: 117, struct_size: 1408 }
template definition:
TemplateDefinition { name: "frag", members: {"long_name_long_2": MemberInfo { name: "long_name_long_2", array_size: 0, type_info: SymbolType { type: "struct", dims: 0, instance_id: 0xfce }, offset: 88 }, "long_name_long_3": MemberInfo { 
name: "long_name_long_3", array_size: 0, type_info: SymbolType { type: "struct", dims: 0, instance_id: 0xfce }, offset: 176 }, "long_name_long_4": MemberInfo { name: "long_name_long_4", array_size: 0, type_info: SymbolType { type: "struct", dims: 0, instance_id: 0xfce }, offset: 264 }, "long_name_long_6": MemberInfo { name: "long_name_long_6", array_size: 0, type_info: SymbolType { type: "struct", dims: 0, instance_id: 0xfce }, offset: 440 }, "long_name_long_12": MemberInfo { name: "long_name_long_12", array_size: 0, type_info: SymbolType { type: "struct", dims: 0, instance_id: 0xfce }, offset: 968 }, "long_name_long_1": MemberInfo { name: "long_name_long_1", array_size: 0, type_info: SymbolType { type: "struct", dims: 0, instance_id: 0xfce }, offset: 0 }, "long_name_long_8": MemberInfo { name: "long_name_long_8", array_size: 0, type_info: SymbolType { type: "struct", dims: 0, instance_id: 0xfce }, offset: 616 }, "long_name_long_14": 
MemberInfo { name: "long_name_long_14", array_size: 0, type_info: SymbolType { type: "struct", dims: 0, instance_id: 0xfce }, offset: 1144 }, "long_name_long_15": MemberInfo { name: "long_name_long_15", array_size: 0, type_info: SymbolType { type: "struct", dims: 0, instance_id: 0xfce }, offset: 1232 }, "long_name_long_5": MemberInfo { name: "long_name_long_5", array_size: 0, type_info: SymbolType { type: "struct", dims: 0, instance_id: 0xfce }, offset: 352 }, "long_name_long_11": MemberInfo { name: "long_name_long_11", array_size: 0, type_info: SymbolType { type: "struct", dims: 0, instance_id: 0xfce }, offset: 880 }, "long_name_long_7": MemberInfo { name: "long_name_long_7", array_size: 0, type_info: SymbolType { type: "struct", dims: 0, instance_id: 0xfce }, offset: 528 }, "long_name_long_13": MemberInfo { name: "long_name_long_13", array_size: 0, type_info: SymbolType { type: "struct", dims: 0, instance_id: 0xfce }, offset: 1056 }, "long_name_long_16": MemberInfo { name: "long_name_long_16", array_size: 0, type_info: SymbolType { type: "struct", dims: 0, instance_id: 0xfce }, offset: 1320 }, "long_name_long_9": MemberInfo { name: "long_name_long_9", array_size: 0, type_info: SymbolType { type: "struct", dims: 0, instance_id: 0xfce }, offset: 704 }, "long_name_long_10": MemberInfo { name: "long_name_long_10", array_size: 0, type_info: SymbolType { type: "struct", dims: 0, instance_id: 0xfce }, offset: 792 }} }

The template structure_size indicates how large the instance of the template will be.

read UDT's members separately

let mut res:BigUdt = ...;

//member1
let tag= EPath::parse_tag("test_frag.long_name_long_1")?;
let value: TagValue<i32> = client.read_tag(tag).await?;
res.member1 = value.value;

//member2
let tag= EPath::parse_tag("test_frag.long_name_long_2")?;
let value: TagValue<i32> = client.read_tag(tag).await?;
res.member2 = value.value;

//other members...

To be more efficient, you can try multiple service packet service.

from eip-rs.

Joylei avatar Joylei commented on June 13, 2024

I've got read_tag_fragmented working. I will publish a new version soon.
I'm closing the issue. If you have issues or questions, please open new issues.

from eip-rs.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.