Skip to content

Commit 0d26955

Browse files
Merge pull request #54 from fledge-iot/FOGL-5798
FOGL-5798 s2opcua common additional package files support added for Debian Platform only
2 parents 6fb13aa + b218c5a commit 0d26955

File tree

8 files changed

+409
-0
lines changed

8 files changed

+409
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ others/paho.mqtt.c/
1515
others/jansson
1616
others/lib60870
1717
others/libiec61850
18+
others/S2OPC
19+
others/check-0.15.2.tar.gz
20+
others/check-0.15.2
21+
others/libexpat
1822

1923
# Archived packages
2024
plugins/archive

others/make_deb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,13 @@ if [ "${ADDITIONAL_LIB_NAME}" == "iec" ]; then
142142
fi
143143
cp -R --preserve=links /usr/local/lib/liblib60870* usr/local/lib
144144
fi
145+
if [ "${ADDITIONAL_LIB_NAME}" == "s2opcua" ]; then
146+
cp -R --preserve=links /usr/local/lib/libs2opc_common.so usr/local/lib
147+
cp -R --preserve=links /usr/local/lib/libs2opc_clientserver.so usr/local/lib
148+
cp -R --preserve=links /usr/local/lib/libs2opc_clientwrapper.so usr/local/lib
149+
cp -R --preserve=links /usr/local/lib/libs2opc_commonwrapper.so usr/local/lib
150+
cp -R --preserve=links /usr/local/lib/libexpat.so.1 usr/local/lib
151+
fi
145152
echo "Done."
146153

147154
# Build the package

others/scripts/s2opcua/Description

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This Package contains an Expat, a C library for parsing XML and OPC UA Toolkit additional libraries.

others/scripts/s2opcua/S2OPC.patch

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
diff --git a/CommonDefs.cmake b/CommonDefs.cmake
2+
index 7cca75030..b22079425 100644
3+
--- a/CommonDefs.cmake
4+
+++ b/CommonDefs.cmake
5+
@@ -29,8 +29,8 @@ endforeach(OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES)
6+
## Manage static/shared property of external libraries
7+
8+
# Make CMake use static version of all dependencies by default
9+
-option(USE_STATIC_EXT_LIBS "S2OPC libraries and binaries depend on static version of external libraries" ON)
10+
-option(BUILD_SHARED_LIBS "Build dynamic libraries for S2OPC instead of static libraries" OFF)
11+
+option(USE_STATIC_EXT_LIBS "S2OPC libraries and binaries depend on static version of external libraries" OFF)
12+
+option(BUILD_SHARED_LIBS "Build dynamic libraries for S2OPC instead of static libraries" ON)
13+
if(USE_STATIC_EXT_LIBS)
14+
set(USE_STATIC_MBEDTLS_LIB ${USE_STATIC_EXT_LIBS})
15+
set(USE_STATIC_EXPAT_LIB ${USE_STATIC_EXT_LIBS})
16+
diff --git a/src/ClientServer/frontend/client_wrapper/libs2opc_client.h b/src/ClientServer/frontend/client_wrapper/libs2opc_client.h
17+
index 693c63ab0..24c67dac2 100644
18+
--- a/src/ClientServer/frontend/client_wrapper/libs2opc_client.h
19+
+++ b/src/ClientServer/frontend/client_wrapper/libs2opc_client.h
20+
@@ -129,7 +129,9 @@ typedef enum
21+
SOPC_LibSub_DataType_integer = 2,
22+
SOPC_LibSub_DataType_string = 3,
23+
SOPC_LibSub_DataType_bytestring = 4,
24+
- SOPC_LibSub_DataType_other = 5
25+
+ SOPC_LibSub_DataType_float = 5,
26+
+ SOPC_LibSub_DataType_double = 6,
27+
+ SOPC_LibSub_DataType_other = 7
28+
} SOPC_LibSub_DataType;
29+
30+
/**
31+
diff --git a/src/ClientServer/frontend/client_wrapper/state_machine.c b/src/ClientServer/frontend/client_wrapper/state_machine.c
32+
index 1ab4df97d..b2eef008a 100644
33+
--- a/src/ClientServer/frontend/client_wrapper/state_machine.c
34+
+++ b/src/ClientServer/frontend/client_wrapper/state_machine.c
35+
@@ -1298,10 +1298,12 @@ static void StaMac_ProcessMsg_PublishResponse(SOPC_StaMac_Machine* pSM, uint32_t
36+
assert(SOPC_ExtObjBodyEncoding_Object == pNotifMsg->NotificationData[0].Encoding);
37+
assert(&OpcUa_DataChangeNotification_EncodeableType == pNotifMsg->NotificationData[0].Body.Object.ObjType);
38+
pDataNotif = (OpcUa_DataChangeNotification*) pNotifMsg->NotificationData[0].Body.Object.Value;
39+
+ Helpers_Log(SOPC_LOG_LEVEL_INFO, "%s:%d: pDataNotif->NoOfMonitoredItems=%d", "StaMac_ProcessMsg_PublishResponse", __LINE__, pDataNotif->NoOfMonitoredItems);
40+
for (i = 0; i < pDataNotif->NoOfMonitoredItems; ++i)
41+
{
42+
pMonItNotif = &pDataNotif->MonitoredItems[i];
43+
status = Helpers_NewValueFromDataValue(&pMonItNotif->Value, &plsVal);
44+
+ Helpers_Log(SOPC_LOG_LEVEL_INFO, "%s:%d: i=%d, plsVal->type=%d", "StaMac_ProcessMsg_PublishResponse", __LINE__, i, plsVal->type);
45+
if (SOPC_STATUS_OK == status)
46+
{
47+
if (NULL != pSM->cbkLibSubDataChanged)
48+
diff --git a/src/ClientServer/frontend/client_wrapper/toolkit_helpers.c b/src/ClientServer/frontend/client_wrapper/toolkit_helpers.c
49+
index e2fa388ff..b4babe046 100644
50+
--- a/src/ClientServer/frontend/client_wrapper/toolkit_helpers.c
51+
+++ b/src/ClientServer/frontend/client_wrapper/toolkit_helpers.c
52+
@@ -111,8 +111,8 @@ SOPC_ReturnStatus Helpers_NewSCConfigFromLibSubCfg(const char* szServerUrl,
53+
status = SOPC_PKIProviderStack_CreateFromPaths(lPathsTrustedRoots, lPathsTrustedLinks, lPathsUntrustedRoots,
54+
lPathsUntrustedLinks, lPathsIssuedCerts, lPathsCRL, &pPki);
55+
if (SOPC_STATUS_OK != status)
56+
- {
57+
- Helpers_Log(SOPC_LOG_LEVEL_ERROR, "Failed to create PKI.");
58+
+ {
59+
+ Helpers_Log(SOPC_LOG_LEVEL_ERROR, "Failed to create PKI, status=%d", status);
60+
}
61+
}
62+
else
63+
@@ -536,9 +536,36 @@ SOPC_ReturnStatus Helpers_NewValueFromDataValue(SOPC_DataValue* pVal, SOPC_LibSu
64+
}
65+
/* else we leave value NULL and length = 0 */
66+
break;
67+
+
68+
+ case SOPC_Float_Id:
69+
+ plsVal->type = SOPC_LibSub_DataType_float;
70+
+ plsVal->value = SOPC_Malloc(sizeof(float));
71+
+ if (NULL == plsVal->value)
72+
+ {
73+
+ status = SOPC_STATUS_OUT_OF_MEMORY;
74+
+ }
75+
+ else
76+
+ {
77+
+ *(float*) plsVal->value = (float) pVal->Value.Value.Floatv;
78+
+ }
79+
+ break;
80+
+
81+
+ case SOPC_Double_Id:
82+
+ plsVal->type = SOPC_LibSub_DataType_double;
83+
+ plsVal->value = SOPC_Malloc(sizeof(double));
84+
+ if (NULL == plsVal->value)
85+
+ {
86+
+ status = SOPC_STATUS_OUT_OF_MEMORY;
87+
+ }
88+
+ else
89+
+ {
90+
+ *(double*) plsVal->value = (double) pVal->Value.Value.Doublev;
91+
+ }
92+
+ break;
93+
+
94+
case SOPC_Null_Id:
95+
- case SOPC_Float_Id:
96+
- case SOPC_Double_Id:
97+
+ // case SOPC_Float_Id:
98+
+ // case SOPC_Double_Id:
99+
case SOPC_DateTime_Id:
100+
case SOPC_Guid_Id:
101+
case SOPC_XmlElement_Id:
102+
diff --git a/src/Common/configuration/sopc_common_constants.h b/src/Common/configuration/sopc_common_constants.h
103+
index 874129c1e..9e24ed808 100644
104+
--- a/src/Common/configuration/sopc_common_constants.h
105+
+++ b/src/Common/configuration/sopc_common_constants.h
106+
@@ -77,7 +77,7 @@ bool SOPC_Common_SetEncodingConstants(SOPC_Common_EncodingConstants config);
107+
* Note: if 0 is chosen SOPC_RECEIVE_MAX_MESSAGE_LENGTH definition shall be changed not to use it and shall not be 0.
108+
*/
109+
#ifndef SOPC_DEFAULT_RECEIVE_MAX_NB_CHUNKS
110+
-#define SOPC_DEFAULT_RECEIVE_MAX_NB_CHUNKS 5
111+
+#define SOPC_DEFAULT_RECEIVE_MAX_NB_CHUNKS 10
112+
#endif /* SOPC_DEFAULT_RECEIVE_MAX_NB_CHUNKS */
113+
114+
/** @brief Maximum message length accepted in reception (must be >= SOPC_TCP_UA_MAX_BUFFER_SIZE), 0 means no limit.

others/scripts/s2opcua/VERSION

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fledge_s2opcua_version=1.9.2
2+
fledge_version>=1.9
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--- CMakeLists.txt 2021-04-27 14:35:52.359863999 +0530
2+
+++ CMakeLists.txt.updated 2021-04-27 14:26:16.551912000 +0530
3+
@@ -248,7 +248,9 @@
4+
check_c_compiler_flag("-pthread" HAVE_PTHREADS_FLAG)
5+
if (HAVE_PTHREADS_FLAG)
6+
add_definitions("-pthread")
7+
- add_link_options("-pthread")
8+
+ set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pthread")
9+
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
10+
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
11+
endif()
12+
endif()
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
/*
2+
* Licensed to Systerel under one or more contributor license
3+
* agreements. See the NOTICE file distributed with this work
4+
* for additional information regarding copyright ownership.
5+
* Systerel licenses this file to you under the Apache
6+
* License, Version 2.0 (the "License"); you may not use this
7+
* file except in compliance with the License. You may obtain
8+
* a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
/**
21+
* \file sopc_encodeabletype.h
22+
*
23+
* \brief Encodeable type and services
24+
*/
25+
26+
#ifndef SOPC_ENCODEABLETYPE_H_
27+
#define SOPC_ENCODEABLETYPE_H_
28+
29+
#include <stddef.h>
30+
#include <stdint.h>
31+
32+
#include "sopc_buffer.h"
33+
#include "sopc_enums.h"
34+
35+
/**
36+
* \brief Initialization function generic signature for an encodeable object
37+
*/
38+
typedef void(SOPC_EncodeableObject_PfnInitialize)(void* value);
39+
40+
/**
41+
* \brief Clear function generic signature for an encodeable object
42+
*/
43+
typedef void(SOPC_EncodeableObject_PfnClear)(void* value);
44+
45+
/**
46+
* \brief Get size function generic signature for an encodeable object
47+
* Note: Unused in S2OPC, NULL pointer may be provided instead of function pointer
48+
*/
49+
typedef void(SOPC_EncodeableObject_PfnGetSize)(void);
50+
51+
/**
52+
* \brief Encoding function generic signature for an encodeable object
53+
*/
54+
typedef SOPC_ReturnStatus(SOPC_EncodeableObject_PfnEncode)(const void* value,
55+
SOPC_Buffer* msgBuffer,
56+
uint32_t nestedStructLevel);
57+
58+
/**
59+
* \brief Decoding function generic signature for an encodeable object
60+
*/
61+
typedef SOPC_ReturnStatus(SOPC_EncodeableObject_PfnDecode)(void* value,
62+
SOPC_Buffer* msgBuffer,
63+
uint32_t nestedStructLevel);
64+
65+
/*
66+
* \brief Description of an encodeable type field.
67+
*
68+
* This structure has been designed to be very compact and fit into 8 bytes.
69+
* The \c isBuiltIn field indicates whether the field type is built-in or
70+
* defined in the address space. In the first case, the type index is a member
71+
* of the \c SOPC_BuiltinId enumeration. In the second case, it is a member of
72+
* the \c SOPC_TypeInternalIndex enumeration.
73+
*
74+
* The \c isArrayLength field indicates whether this field contains the length
75+
* of an array. When true, the field must be of built-in type \c Int32, and the
76+
* array is described by the next field.
77+
*
78+
* The \c isToEncode field indicates whether this field shall be encoded and
79+
* decoded. When false, the field is only initialized and cleared.
80+
*
81+
* Finally, the \c offset field gives the offset in bytes of the field in the
82+
* object structure.
83+
*/
84+
typedef struct SOPC_EncodeableType_FieldDescriptor
85+
{
86+
bool isBuiltIn : 1;
87+
bool isArrayLength : 1;
88+
bool isToEncode : 1;
89+
uint32_t typeIndex : 29;
90+
uint32_t offset;
91+
} SOPC_EncodeableType_FieldDescriptor;
92+
93+
/**
94+
* \brief Encodeable object type structure definition. It provides all the services
95+
* functions associated with the encodeable object for encoding needs.
96+
*/
97+
typedef struct SOPC_EncodeableType
98+
{
99+
char* TypeName;
100+
uint32_t TypeId;
101+
uint32_t BinaryEncodingTypeId;
102+
uint32_t XmlEncodingTypeId;
103+
char* NamespaceUri;
104+
size_t AllocationSize;
105+
SOPC_EncodeableObject_PfnInitialize* Initialize;
106+
SOPC_EncodeableObject_PfnClear* Clear;
107+
SOPC_EncodeableObject_PfnGetSize* GetSize;
108+
SOPC_EncodeableObject_PfnEncode* Encode;
109+
SOPC_EncodeableObject_PfnDecode* Decode;
110+
int32_t NoOfFields;
111+
const SOPC_EncodeableType_FieldDescriptor* Fields;
112+
} SOPC_EncodeableType;
113+
114+
/**
115+
* \brief Registers a user-defined encodeable type.
116+
* further calls to SOPC_EncodeableType_GetEncodeableType
117+
* will successfully identify the registered encodeable type
118+
*
119+
* \note All registered encoders must be freed by
120+
* SOPC_EncodeableType_RemoveUserType
121+
*
122+
* \param encoder The encoder definition to register
123+
* \return A status code indicating the result of operation
124+
*/
125+
SOPC_ReturnStatus SOPC_EncodeableType_AddUserType(SOPC_EncodeableType* encoder);
126+
127+
/**
128+
* \brief Removes a user-defined encodeable type previously created by
129+
* SOPC_EncodeableType_AddUserType
130+
*
131+
* \param encoder The encoder definition to register
132+
* \return A status code indicating the result of operation
133+
*/
134+
SOPC_ReturnStatus SOPC_EncodeableType_RemoveUserType(SOPC_EncodeableType* encoder);
135+
136+
/**
137+
* \brief Retrieve a defined encodeable object type with the given type Id.
138+
*
139+
* \param typeId Type identifier for which corresponding encodeable object type must be returned
140+
* \return The searched encodeable type or NULL if parameters are incorrect or type is not found
141+
*/
142+
SOPC_EncodeableType* SOPC_EncodeableType_GetEncodeableType(uint32_t typeId);
143+
144+
const char* SOPC_EncodeableType_GetName(SOPC_EncodeableType* encType);
145+
146+
/**
147+
* \brief Initialize an encodeable object.
148+
*
149+
* The \c pValue parameter shall correspond to an object of the appropriate
150+
* type.
151+
*/
152+
void SOPC_EncodeableObject_Initialize(SOPC_EncodeableType* type, void* pValue);
153+
154+
/**
155+
* \brief Clear an encodeable object.
156+
*
157+
* The \c pValue parameter shall correspond to an object of the appropriate
158+
* type.
159+
*/
160+
void SOPC_EncodeableObject_Clear(SOPC_EncodeableType* type, void* pValue);
161+
162+
/**
163+
* \brief Encode an encodeable object.
164+
*
165+
* The \c pValue parameter shall correspond to an object of the appropriate
166+
* type.
167+
*/
168+
SOPC_ReturnStatus SOPC_EncodeableObject_Encode(SOPC_EncodeableType* type,
169+
const void* pValue,
170+
SOPC_Buffer* buf,
171+
uint32_t nestedStructLevel);
172+
173+
/**
174+
* \brief Decode an encodeable object.
175+
*
176+
* The \c pValue parameter shall correspond to an object of the appropriate
177+
* type.
178+
*/
179+
SOPC_ReturnStatus SOPC_EncodeableObject_Decode(SOPC_EncodeableType* type,
180+
void* pValue,
181+
SOPC_Buffer* buf,
182+
uint32_t nestedStructLevel);
183+
184+
#endif /* SOPC_ENCODEABLETYPE_H_ */

0 commit comments

Comments
 (0)