Joylei / eip-rs

rseip - EIP&CIP client in pure Rust, for generic CIP and AB PLC
MIT License
50 stars 6 forks source link

PortSegment configuration. #18

Open ftneves opened 10 months ago

ftneves commented 10 months ago

Hi my name is Francisco, I'm from Brazil and I am a industrial automation engineer. I'm a beginner rust user. I working in a project to collect data from 4 logix controllers and I'm using yours lib. I can connect with 1 controller using the default port segment, but in my case, the other 3 controllers are connected in a 1756-EN2T module, so I have: The backplane, on slot 0 1756-L82ES (172.16.1.130), on slot 6 1756-EN2T (192.168.0.1) where I have the other 3 controllers, connected on another backplane by 1756-EN2TR on slot 3 (192.168.0.2). Is it possible to do that communication? Could you help me?

Joylei commented 9 months ago

It's possible. I think you need to figure out the routing paths.

Please refer to Routing_Paths for understanding of routing paths.


Sample code for building routing paths:

    let mut routing_path = EPath::new();
    // -- EN2T at slot 6 --
    routing_path = routing_path.with_port_slot(1, 6); // backplane, slot 6
    routing_path.push(Segment::Port(PortSegment {
        port: 2, // EN2T port 2
        link: bytes::Bytes::from_static(&[192, 168, 0, 1]),
    }));
    // -- final device
    routing_path = routing_path.with_port(1); // backplane, slot 0
    let mut client = AbEipClient::new_host_lookup("192.168.0.2")
        .await?
        .with_connection_path(routing_path);