Skip to content

Commit

Permalink
fix: older versions issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Mo-Tay committed Oct 11, 2021
1 parent b81e7d7 commit 16a2bdb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions recipes/open62541/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ conan_basic_setup(TARGETS)
find_package(open62541 REQUIRED CONFIG)
find_package(Threads REQUIRED)

add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} open62541::open62541 Threads::Threads)
# add_executable(${PROJECT_NAME} test_package.c)
# target_link_libraries(${PROJECT_NAME} open62541::open62541 Threads::Threads)

find_package(PythonInterp REQUIRED)

Expand Down
23 changes: 12 additions & 11 deletions recipes/open62541/all/test_package/test_package_nodeset.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
* /src_generated directory by CMake */
#include "foo_flt_nodeids.h"
#include "namespace_foo_flt_generated.h"

#include <open62541/plugin/network.h>
#include <signal.h>
#include <stdlib.h>

UA_Boolean running = true;
UA_Boolean running = false;

static void server_stop_callback(UA_Server *server, void *data) {
UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, "stopping server due to timer");
Expand All @@ -24,10 +24,12 @@ static void server_stop_callback(UA_Server *server, void *data) {

int main(void) {
UA_Server *server = UA_Server_new();
running = true;
UA_StatusCode return_code;
UA_UInt16 portNumber = 4840;
UA_ServerConfig_setMinimal(UA_Server_getConfig(server), portNumber, NULL);
UA_Server_addRepeatedCallback(server, server_stop_callback, NULL, 500., NULL);

UA_StatusCode return_code;
/* create nodes from nodeset */
if(namespace_foo_flt_generated(server) != UA_STATUSCODE_GOOD)
{
Expand All @@ -43,17 +45,16 @@ int main(void) {
UA_NodeId testInstanceId = UA_NODEID_NUMERIC(nsIdx, UA_FOO_FLTID_APE);
UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, "The Ape has ns=%d;id=%d",
testInstanceId.namespaceIndex, testInstanceId.identifier.numeric);

UA_Server_addRepeatedCallback(server, server_stop_callback, NULL, 150., NULL);


return_code = UA_Server_run(server, &running);

while(return_code == UA_STATUSCODE_BADCOMMUNICATIONERROR)
{

running = false;
portNumber = portNumber + 1;
UA_ConnectionConfig config = UA_ConnectionConfig_default;
UA_Server_getConfig(server)->networkLayers[0] = UA_ServerNetworkLayerTCP(config, portNumber, 0);

UA_Server_getConfig(server)->networkLayersSize = 0;
UA_ServerConfig_addNetworkLayerTCP(UA_Server_getConfig(server), portNumber, 0, 0);
running = true;
return_code = UA_Server_run(server, &running);

if(return_code == UA_STATUSCODE_GOOD)
Expand All @@ -66,9 +67,9 @@ int main(void) {
printf("ports from 4840 to 4850 are not avilable");
break;
}

}
}
running = false;
UA_Server_delete(server);
return return_code == UA_STATUSCODE_GOOD ? EXIT_SUCCESS : EXIT_FAILURE;
}

0 comments on commit 16a2bdb

Please sign in to comment.