Comments (7)
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.
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 maxconnection_size
supported by your device.
make sureconnection_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?;
read_tag_fragmented()
You can try read_tag_fragmented. It's a little harder in this way.
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.
from eip-rs.
let me do a little testing
from eip-rs.
One possible solution is read your UDT's members separately.
and Let me try read_tag_fragmented
.
from eip-rs.
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.
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)
- Building the example from readme fails with unresolved import HOT 1
- Float values HOT 1
- How to know which version of tokio should be used. HOT 2
- infinite reading... HOT 3
- Bytes HOT 1
- reading integer HOT 1
- How to read SLC 500 addresses? HOT 3
- Undefined Behavior with StreamExt::collect HOT 1
- PortSegment configuration. HOT 1
- Encoder/Decoder should pass in some context data
- Question: Can eip-rs Read UDTs? HOT 3
- Validate buffer size everywhere necessary
- Future goals HOT 1
- Can not read a large template HOT 3
- Backtrace HOT 6
- Future cannot be sent between threads safely HOT 3
- I was not able to read a tag value in a controller.. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eip-rs.