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

Shared library support #184

Merged
merged 10 commits into from
Mar 25, 2019
Merged

Conversation

wpmccormick
Copy link
Contributor

Changes to CMakeLists files to support shared libraries in support of issue #183 .

@wpmccormick
Copy link
Contributor Author

I'm not sure what do do about this ...

configure_file(  
	"${PROJECT_SOURCE_DIR}/src/ports/devicedata.h.in"
	"${PROJECT_BINARY_DIR}/src/ports/devicedata.h"
	)

... in the case of BUILD_SHARED_LIBS

@MartinMelikMerkumians
Copy link
Member

Hi,

The devicedata.h has probably to be changed, that these parameters have to be provided by a to be defined start function for library use. Vendor ID, device type and so on are needed parameters for device identification at the PLC.

Regarding your problem with the circular dependencies (I only see your comment in an email, but not in the associated issue), I have to check, but from a the first look, I would guess, that for library use, the functions HandleApplication, CheckIoConnectionEvent, AfterAssemblyDataReceived, BeforeAssemblyDataSend, ResetDevice, and ResetDeviceToInitialConfiguration have to be provided via function handles, as these functions are application dependent.

The functions CipCalloc and CipFree should be moved to the platform dependent code sections, and RunIdleChanged should move into the common CIP lib.

@wpmccormick
Copy link
Contributor Author

Okay, I see where/how I'll need to work with devicedata.h.

I removed my comment regarding circular dependencies because it's not an issue after all; it was just an issue with library linking. I've actually got a ROS1/C++ project compiling and linking (catkin) against OpENer shared libs. However, I decided to close the PR until I get a little further along.

Should moving the functions CipCalloc, CipFree, and RunIdleChanged be a requirement for merging any forthcoming PR for shared lib support?

@MartinMelikMerkumians
Copy link
Member

Hi,
yes, I guess it is necessary to move them in order to get a working library without dependencies to the sample application, which makes sense to be decoupled.

@wpmccormick
Copy link
Contributor Author

It looks like CipCalloc and CipFree are already located in the platform dependent sampleapplication.c. It looks like CipCalloc would be better placed in the CIP lib; probably cipcommon.c. And CipFree might be placed there as well, as it seems sort of like a common thing, though it's never called from there.

So I'm thinking that you meant to say these Cip functions should be moved out of platform dependent code (sampleapplication.c)? As for RunIdleChanged, I can see that one moved to cipioconnection.c.

All that aside, one cannot help but notice the "Copyright (c) 2011, Rockwell Automation, Inc" at the top of most source files. It would seem like a good thing to try to keep such files unchanged. Or is there no chance that Rockwell would make updated versions available? but then again, I don't understand the genesis and roadmap of this project. Please share that if you can.

In any event, circular dependencies notwithstanding, I was able to link the existing main and sampleapplication to shared libraries, and tested against an actual running PLC. So it can all work the way it is, it's just not as nice as it might be. But maybe that is your motivation?

@MartinMelikMerkumians
Copy link
Member

Hi,
yes they are, but as you say they should live in the CIP library, so that the lib code get independent of the sample application. Putting RunIdleChanged into cipioconnection seems to be a good idea.

Yes, I would like to do it nice, but if it works for you, I would still merge your changes and improve on them later on.

The main reason for the copyright attributed to Rockwell Automation is that they are the sole sponsor of this project, but although all code is copyrighted to Rockwell, it is still under the BSD license. But you hit an important point. I will try to discuss this with Rockwell, how to handle that for contributions in the future.

@wpmccormick
Copy link
Contributor Author

OK, I'm pretty much out of time and over budget on this project as it is. So I'd like to re-open the PR and have you merge, at your convenience and as your time permits.

Also, my project is using OpENer as a git sub-module, pushing a tagged version. So if you would, please tag the master branch with a version I can hang the rest of my project on.

Thanks,

Bill

@wpmccormick wpmccormick reopened this Mar 19, 2019
Bill McCormick added 3 commits March 22, 2019 17:13
+ BUILD_SHARED_LIBS default OFF
+ Prefer using VERSION on project seeting to seetin _VERSION_MAJOR/MINOR explicitly
+ Check for existing Vendor ID, Device Type, Device Name, Product Code
Copy link
Member

@MartinMelikMerkumians MartinMelikMerkumians left a comment

Choose a reason for hiding this comment

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

Changed this myself

@@ -12,7 +12,7 @@
#include "typedefs.h"
#include "ciptypes.h"
#include "ciperror.h"
#include "opener_user_conf.h"
//#include "opener_user_conf.h"

Choose a reason for hiding this comment

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

Hi, commenting this out breaks the traces.

@MartinMelikMerkumians
Copy link
Member

Thanks for sharing the code! Shared library is merged into master

@MartinMelikMerkumians
Copy link
Member

Oh, your last commit was a little bit to late. I have to add it now in addition to the rest of the code

@MartinMelikMerkumians MartinMelikMerkumians merged commit 3e59dac into EIPStackGroup:master Mar 25, 2019
@ghost ghost removed the in progress label Mar 25, 2019
@wpmccormick
Copy link
Contributor Author

Yea, sorry about that late commit. I didn't have a proper build environment to test with until I got to work this morning.

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

Successfully merging this pull request may close these issues.

2 participants