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

Add Large Forward Open service #25

Merged
merged 2 commits into from
Jun 3, 2020
Merged

Add Large Forward Open service #25

merged 2 commits into from
Jun 3, 2020

Conversation

nefethael
Copy link

Signed-off-by: Vincent Prince vincent.prince.fr@gmail.com

@nefethael
Copy link
Author

nefethael commented May 28, 2020

Hi all,

This is my first contribution to EIPScanner, I'm not sure my PR takes care of everything (examples, doc, etc)?

Also, I only tried LFO feature with OpENer stack and wireshark (I don't own any CIP adapter equipment), so I'm not 100% confident about implementation.

First commit allows output assembly to change data without vector copy, maybe a better solution would be to provide something like this in IOConnection? Current solution is not threadsafe.

using SendDataHandle = std::function<std::vector<uint8_t>&(void)>;

Second commit allows creation of ConnectionManager object as another class member without causing a timeout on first forward open.

Last commit adds large forward open service and provides a new NetworkConnectionParametersBuilder class that takes care of serializing/deserializing network connection parameters. It can be used this way

        ConnectionManager connectionManager;

        ConnectionParameters parameters;
        parameters.connectionPath = {0x20, 0x04,0x24, 151, 0x2C, 150, 0x2C, 100};
        parameters.o2tRealTimeFormat = true;
        parameters.originatorVendorId = 342;
        parameters.originatorSerialNumber = 32423;

        parameters.t2oNetworkConnectionParams =
                NetworkConnectionParametersBuilder(0, true)
                .SetConnectionType(NetworkConnectionParametersBuilder::P2P)
                .SetPriority(NetworkConnectionParametersBuilder::SCHEDULED)
                .SetConnectionSize(32).Build();

        parameters.o2tNetworkConnectionParams =
                NetworkConnectionParametersBuilder(0, true)
                .SetConnectionType(NetworkConnectionParametersBuilder::P2P)
                .SetPriority(NetworkConnectionParametersBuilder::SCHEDULED)
                .SetConnectionSize(32).Build();

        parameters.originatorSerialNumber = 0x12345;
        parameters.o2tRPI = 1000000;
        parameters.t2oRPI = 1000000;
        parameters.transportTypeTrigger |= NetworkConnectionParams::CLASS1;

        auto io = connectionManager.largeForwardOpen(si, parameters);
        ...

I'm open to any remarks & suggestions

Best regards,
Vincent

@atimin
Copy link
Contributor

atimin commented May 28, 2020

Hey @nefethael , thank you for the contribution.

We appreciate your help and we are open to work here together. Unfortunately, I'm pretty busy at the moment and cannot make the code review in details. I'll give you my feedback at the weekend.

Best regards,
Aleksey

@atimin atimin self-assigned this May 30, 2020
@atimin atimin self-requested a review May 30, 2020 03:14
auto now = std::chrono::steady_clock::now();
auto sinceLastHandle =
std::chrono::duration_cast<std::chrono::milliseconds>(now - _lastHandleTime);
Logger(LogLevel::TRACE) << "Last call was " << sinceLastHandle.count() << "ms ago";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, there is an issue in our logger... This statement are calculated even if a user use a higher logging level. It could cause performance problems if you have a lot of IO connections.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I can remove Logger call then?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, please.

Vincent Prince added 2 commits May 31, 2020 08:17
If ConnectionManager is created way before forwardOpen call,
session is terminated due to timeout.
By moving timeout handling in IOConnection, timeout is calculated only if a session exists.

Signed-off-by: Vincent Prince <vincent.prince.fr@gmail.com>
Signed-off-by: Vincent Prince <vincent.prince.fr@gmail.com>
@nefethael
Copy link
Author

@FLIPBack I rebased PR branch with corrections. I just reverted setDataToSend stuff without any workaround for 0-copy vector, they're not that big regarding send period :)

@atimin
Copy link
Contributor

atimin commented Jun 2, 2020

Hi @nefethael, thanks I see. What about other two topics?:

  1. LOG_TRACE
  2. Code conversion

@nefethael
Copy link
Author

@FLIPBack I removed LOG_TRACE in notify function and fixed upper/lower-case issues, normally it should be ok

@atimin
Copy link
Contributor

atimin commented Jun 3, 2020

@nefethael I didn't notice it because I was waiting for an additional commit =) Okay, I'll take your PR. Thank you very much for your contribution again!

@atimin atimin merged commit 6d475df into nimbuscontrols:master Jun 3, 2020
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

Successfully merging this pull request may close these issues.

2 participants