Creation of OpENer Linux library packages

163 views
Skip to first unread message

Hidagus

unread,
Mar 23, 2021, 10:34:19 PM3/23/21
to EIP Stack Group OpENer users
Hi,
My current project would like to use OpENer as a library for our Linux based software to communicate with a PLC that runs Ethernet/IP. We don't use OpENer binaries as a standalone executable, but rather as a library that other software packages can utilize for communicate with a EIP scanner. 
I have created two packages, one contains the shared object and the other devel package that contains required header files. Our application initialization software is written similarly to source/src/ports/POSIX/main.c. However I got NetworkHandlerInitialize() error which fails at bind(g_network_status.udp_unicast_listener,  (struct sockaddr *) &my_address,  sizeof(struct sockaddr) ) ) in generic_networkhandler.c.
I wonder if my OpENer packages is incomplete and causes the error. Can you advise if any file/library is missing?
(1) OpENer library package contains:
      /usr/lib64/libopener.so
      /usr/share/doc/OpENer
      /usr/share/doc/OpENer/AUTHORS
      /usr/share/doc/OpENer/ChangeLog.txt
      /usr/share/doc/OpENer/README.md
      /usr/share/doc/OpENer/TODO
      /usr/share/licenses/OpENer
      /usr/share/licenses/OpENer/license.txt
    The libopener.so library is created with following source files:
      set(CIP_SRC
      "cip/appcontype.c"
      "cip/cipassembly.c"
      "cip/cipclass3connection.c"
      "cip/cipcommon.c"
      "cip/cipconnectionmanager.c"
      "cip/cipconnectionobject.c"
      "cip/cipdlr.c"
      "cip/cipelectronickey.c"
      "cip/cipepath.c"
      "cip/cipethernetlink.c"
      "cip/cipidentity.c"
      "cip/cipioconnection.c"
      "cip/cipmessagerouter.c"
      "cip/cipqos.c"
      "cip/cipstring.c"
      "cip/ciptcpipinterface.c")
      
      set(ENET_ENCAP_SRC
      "enet_encap/cpf.c"
      "enet_encap/encap.c"
      "enet_encap/endianconv.c")
      
     set(PLATFORM_GENERIC_SRC
      "ports/generic_networkhandler.c"
      "ports/socket_timer.c"
      "ports/udp_protocol.c")
      
     set(PLATFORM_SPEC_SRC
      "ports/POSIX/networkhandler.c"
      "ports/POSIX/opener_error.c"
      "ports/POSIX/networkconfig.c")
      
     set(UTILS_SRC
      "utils/doublylinkedlist.c"
      "utils/enipmessage.c"
      "utils/random.c"
      "utils/xorshiftrandom.c")
      
     set(NVDATA_SRC
      "ports/nvdata/nvdata.c"
      "ports/nvdata/nvqos.c"
      "ports/nvdata/nvtcpip.c"
      "ports/nvdata/conffile.c")

(2) OpENer devel package contains: 
      /usr/include/appcontype.h
      /usr/include/cipassembly.h
      /usr/include/cipclass3connection.h
      /usr/include/cipcommon.h
      /usr/include/cipconnectionmanager.h
      /usr/include/cipconnectionobject.h
      /usr/include/cipdlr.h
      /usr/include/cipelectronickey.h
      /usr/include/cipepath.h
      /usr/include/ciperror.h
      /usr/include/cipethernetlink.h
      /usr/include/cipidentity.h
      /usr/include/cipioconnection.h
      /usr/include/cipmessagerouter.h
      /usr/include/cipqos.h
      /usr/include/cipstring.h
      /usr/include/ciptcpipinterface.h
      /usr/include/ciptypes.h
      /usr/include/cpf.h
      /usr/include/devicedata.h
      /usr/include/doublylinkedlist.h
      /usr/include/encap.h
      /usr/include/endianconv.h
      /usr/include/enipmessage.h
      /usr/include/generic_networkhandler.h
      /usr/include/networkconfig.h
      /usr/include/networkhandler.h
      /usr/include/nvdata.h
      /usr/include/opener_api.h
      /usr/include/opener_error.h
      /usr/include/opener_user_conf.h
      /usr/include/platform_network_includes.h
      /usr/include/socket_timer.h
      /usr/include/trace.h
      /usr/include/typedefs.h
      /usr/include/udp_protocol.h

I have tried debugging this issue for a while, but still can not get it resolved.
Your help is much appreciated,

-- Hidagus

martin...@gmail.com

unread,
Mar 25, 2021, 7:36:59 AM3/25/21
to EIP Stack Group OpENer users
Hi.
The exact error message would be helpful. In general "bind" is a OS-library command and not part of the OpENer lib source.

Martin

Hidagus

unread,
Mar 25, 2021, 1:10:12 PM3/25/21
to EIP Stack Group OpENer users
The error I got is:

error with UDP unicast bind: 98 - Address already in use
!!!Unprocessed message. Destination: 501 Source: 539 Cmd: 841

Is it also possible that my capability is not set up correctly?
Thanks for your help,

--Hidagus

Hidagus

unread,
Mar 25, 2021, 1:22:43 PM3/25/21
to EIP Stack Group OpENer users
From  'netstat -tuplen' I only see  that UDP port# 44818 is bound to 0.0.0.0. There are no TCP and UDP port# 44818 tied to interface IP address or UDP port# 2222 tied to 0.0.0.0 as seen with bin/OpENer:
   udp        0      0 0.0.0.0:44818           0.0.0.0:*                           0          37020109   4570/sysConnect
(sysConnect is our program)

martin...@gmail.com

unread,
Mar 26, 2021, 4:12:05 AM3/26/21
to EIP Stack Group OpENer users
Hi,
no, if they wouldn't be set correctly you would get an error message at startup with the provided example. This error message has not been generated by OpENer, so that's unfortunately not helping me.
But if everything compiles and runs, why did you think you were missing a library?

For you netstat output, you are right, these two binded ports are missing, but as you use OpENer as a library I cannot say what is the issue there. Probably you forgot to initialize them correctly?

-Martin

Reply all
Reply to author
Forward
0 new messages