Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assert fails for request-response pairs out of order #78

Open
acalandra-cpr opened this issue Oct 18, 2019 · 0 comments
Open

Assert fails for request-response pairs out of order #78

acalandra-cpr opened this issue Oct 18, 2019 · 0 comments

Comments

@acalandra-cpr
Copy link

acalandra-cpr commented Oct 18, 2019

Hello,

We're using your library to read registers off one of our appliances and notice that sometimes we get issues because the library assumes responses received from requests are in the same order -- we're not sure if it's a library problem or a user-of-the-library problem. Here's how this problem occurs.

At a high-level, this is what we're doing:

from cpppo.server.enip.get_attribute import proxy

client = proxy(host=host, port=port, route_path=False, send_path='')
client.open_gateway()
try:
    registers = [ "VO_ERR", "VO_ERX", "VO_FLT" ]
    response = client.read(registers)
    items = list(response)
    # do something ...
except Exception as e:
    log(e)
    client.close_gateway()

# ...

This code works fine until the following happens:
wireshark
What's happening according to wireshark is we send read requests for our 3 registers, then in black, you can see we get a response back for the VO_ERX register, while the respone the library was expecting to receive first is in blue (VO_ERR). This happens only sometimes, but when it does, we see the following (note that this isn't the error from that specific wireshark capture but the same assert always fails):

Request:     0 (Context:        '0'/       '1') Mismatched;
op: {
    "path": [
        {
            "symbolic": "VO_ERR"
        }
    ],
    "offset": null,
    "route_path": false,
    "sender_context": "0",
    "send_path": ""
}
request: {
    "path.segment[0].symbolic": "VO_ERR",
    "read_tag.elements": 1,
    "service": 76,
    "input": "bytearray(b'L\\x04\\x91\\x06VO_ERR\\x01\\x00')"
}
reply: {
    "status": 5,
    "input": "array('c', '\\xcc\\x00\\x05\\x00')",
    "status_ext.size": 0,
    "read_tag": true,
    "service": 204
}

I'm not sure if we're using the wrong abstraction (i.e. using proxy) or if the library must have these responses appear in order. Any ideas? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant