Embeddig OPC UA Client within TTCN-3 [message #1726425] |
Sun, 13 March 2016 12:12 |
Muhammad Burhan Hassan Messages: 28 Registered: November 2015 |
Junior Member |
|
|
HI ,
I am trying to embedded OPC UA Client (in C) within TTCN-3 module. The brief introduction of OPC UA can be viewed from http://open62541.org/.
1. So far i have created an example and embedded a simple C++ based function ( by declaring it in "MyExternalFunction.ttcn") within TTCN-3 module.
2. Then i created OPC UA Client separate, and compiled and executed it successfully. This client is compiled by
"gcc -std=c99 -I ./include -o server_method server_method.c New-SensAct.h New-SensAct.c open62541.o"
where "./include" have some header files, and "open62541.o" is pre-compiled library of standard.
3. Now both of the programs are executing correctly, seperatly.
4. I tried to include the function of OPC UA Client within "MyExternalFunction.ttcn", and implemented it in respective .cc file, where the example function was already implemented during step 1.
5. Then i tried to make by including required files like :
"ttcn3_makefilegen -f UdpMod.ttcn UDPasp_PortType.ttcn UDPasp_Types.ttcn UDPasp_PT.cc UDPasp_PT.hh MyExternalFunction.ttcn MyExternal.cc open62541.h open62541.c open62541.o New-SensAct.h New-SensAct.c"
where "MyExternal.cc" has implementation of function. Am i allowed to use ".c" and ".h" files in this process? how can i pass the argument "./include" to include additional header files?
6. When i make it, the following error is shown:
$ make
make[1]: Entering directory '/cygdrive/c/Burhan/Thesis/TTCN3Examples/TestSystem-SiLDemostrator'
/home/b.hassan/install/bin/compiler -L \
UdpMod.ttcn UDPasp_PortType.ttcn UDPasp_Types.ttcn MyExternalFunction.ttcn - UdpMod.ttcn UDPasp_PortType.ttcn UDPasp_Types.ttcn MyExternalFunction.ttcn
Notify: Parsing TTCN-3 module `UdpMod.ttcn'...
Notify: Parsing TTCN-3 module `UDPasp_PortType.ttcn'...
Notify: Parsing TTCN-3 module `UDPasp_Types.ttcn'...
Notify: Parsing TTCN-3 module `MyExternalFunction.ttcn'...
Notify: Checking modules...
Notify: Generating code...
Notify: File `UdpMod.cc' was generated.
Notify: 1 file was updated.
touch compile
make[1]: Leaving directory '/cygdrive/c/Burhan/Thesis/TTCN3Examples/TestSystem-SiLDemostrator'
g++ -c -DWIN32 -I/home/b.hassan/install/include -Wall -o UdpMod.o UdpMod.cc
if g++ -Wl,--enable-auto-import,--enable-runtime-pseudo-reloc -o UdpMod.exe UdpMod.o UDPasp_PortType.o UDPasp_Types.o MyExternalFunction.o UDPasp_PT.o MyExternal.o open62541.o \
-L/home/b.hassan/install/lib -lttcn3-parallel \
-L/lib -lcrypto \
-L/home/b.hassan/install/lib -lxml2; \
then : ; else /home/b.hassan/install/bin/titanver UdpMod.o UDPasp_PortType.o UDPasp_Types.o MyExternalFunction.o UDPasp_PT.o MyExternal.o open62541.o; exit 1; fi
UdpMod.o:UdpMod.cc:(.text+0x34ed): undefined reference to `MyExternalFunction::f__ReadVariableNode(CHARSTRING const&)'
UdpMod.o:UdpMod.cc:(.text+0x34ed): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `MyExternalFunction::f__ReadVariableNode(CHARSTRING const&)'
MyExternalFunction.o:MyExternalFunction.cc:(.rdata$.refptr._ZN18MyExternalFunction19f__ReadVariableNodeERK10CHARSTRING[.refptr._ZN18MyExternalFunction19f__ReadVariableNodeERK10CHARSTRING]+0x0): undefined reference to `MyExternalFunction::f__ReadVariableNode(CHARSTRING const&)'
collect2: error: ld returned 1 exit status
Makefile:127: recipe for target 'UdpMod.exe' failed
make: *** [UdpMod.exe] Error 1
I don't know if i am having issues with inclusions, compilation or what.
Any type of help will be highly appreciated.
Regards,
Burhan
|
|
|
Re: Embeddig OPC UA Client within TTCN-3 [message #1726427 is a reply to message #1726425] |
Sun, 13 March 2016 13:22 |
|
Hi Muhammad,
in https://www.eclipse.org/forums/index.php/t/1068836/
you can find a complete example of C/C++ external function usage. Please check if your includes and namespace are OK.
You can include additional header files via the CPPFLAGS in the Makefile, e.g.:
# Flags for the C++ preprocessor (and makedepend as well):
CPPFLAGS = -D$(PLATFORM) -I$(TTCN3_DIR)/include -I/home/yourusername/yourfolder/include
The object file should not be used when generating the Makefile:
makefilegen -f UdpMod.ttcn UDPasp_PortType.ttcn UDPasp_Types.ttcn UDPasp_PT.cc UDPasp_PT.hh MyExternalFunction.ttcn MyExternal.cc open62541.h open62541.c New-SensAct.h New-SensAct.c
and yes you can use .c and .h files here.
( I assume open62541.o builds from the downloaded sources open62541.h and open62541.c ;
if you have to add it as a pre-compiled library, you will have to create e.g. a static archive open62541.a and add it to
LDFLAGS:
# Flags for the linker:
LDFLAGS = -L/home/yourusername/lib
where lib is the folder where your archive resides)
The error message indicates that MyExternalFunction::f__ReadVariableNode(CHARSTRING const&) is not visible in the compiled binary; it could be that namespace in
MyExternal.cc is not set to MyExternalFunction.
I hope this helps
Best regards
Elemer
|
|
|
Powered by
FUDForum. Page generated in 0.03161 seconds