Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
osie
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
osie
Commits
eb01425d
Commit
eb01425d
authored
Apr 19, 2022
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split concept of COUPLER_ID and PUBLISHER_ID for keep alive implementation.
parent
bcd01d80
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
12 deletions
+15
-12
coupler/opc-ua-server/keep_alive.h
coupler/opc-ua-server/keep_alive.h
+3
-3
coupler/opc-ua-server/server.c
coupler/opc-ua-server/server.c
+10
-7
coupler/opc-ua-server/server_subscribe.c
coupler/opc-ua-server/server_subscribe.c
+2
-2
No files found.
coupler/opc-ua-server/keep_alive.h
View file @
eb01425d
/*
Keep alive implementation for couplers based on OPC UA's pub/sub mechanism
*/
// both publisher and subscriber should use same publisher id
const
int
PUBLISHER_ID
=
2234
;
UA_NodeId
connectionIdent
,
publishedDataSetIdent
,
writerGroupIdent
;
...
...
@@ -17,7 +19,7 @@ static void addPubSubConnection(UA_Server *server, UA_String *transportProfile,
&
UA_TYPES
[
UA_TYPES_NETWORKADDRESSURLDATATYPE
]);
/* Changed to static publisherId from random generation to identify
* the publisher on Subscriber side */
connectionConfig
.
publisherId
.
numeric
=
2234
;
connectionConfig
.
publisherId
.
numeric
=
PUBLISHER_ID
;
UA_Server_addPubSubConnection
(
server
,
&
connectionConfig
,
&
connectionIdent
);
}
...
...
@@ -113,8 +115,6 @@ static void addDataSetWriter(UA_Server *server) {
&
dataSetWriterConfig
,
&
dataSetWriterIdent
);
}
// XXX: work of LEO which to integrate above
typedef
struct
PublishedVariable
{
char
*
name
;
char
*
description
;
...
...
coupler/opc-ua-server/server.c
View file @
eb01425d
...
...
@@ -36,6 +36,9 @@
#define countof(a) (sizeof(a)/sizeof(*(a)))
// global Id of coupler
static
int
COUPLER_ID
=
0
;
// The default port of OPC-UA server
const
int
DEFAULT_OPC_UA_PORT
=
4840
;
const
int
DEFAULT_MODE
=
0
;
...
...
@@ -55,7 +58,7 @@ static struct argp_option options[] = {
{
"password"
,
'w'
,
""
,
0
,
"Password."
},
{
"key"
,
'k'
,
""
,
0
,
"x509 key."
},
{
"certificate"
,
'c'
,
""
,
0
,
"X509 certificate."
},
{
"id"
,
'i'
,
""
,
0
,
"ID of coupler."
},
{
"id"
,
'i'
,
"
0
"
,
0
,
"ID of coupler."
},
{
0
}
};
...
...
@@ -69,7 +72,7 @@ struct arguments
char
*
password
;
char
*
key
;
char
*
certificate
;
char
*
id
;
int
id
;
};
static
error_t
parse_opt
(
int
key
,
char
*
arg
,
struct
argp_state
*
state
)
...
...
@@ -101,7 +104,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state)
arguments
->
key
=
arg
;
break
;
case
'i'
:
arguments
->
id
=
arg
;
arguments
->
id
=
arg
?
atoi
(
arg
)
:
0
;
break
;
case
ARGP_KEY_ARG
:
return
0
;
...
...
@@ -138,7 +141,7 @@ int main(int argc, char **argv)
arguments
.
password
=
""
;
arguments
.
key
=
""
;
arguments
.
certificate
=
""
;
arguments
.
id
=
""
;
arguments
.
id
=
0
;
argp_parse
(
&
argp
,
argc
,
argv
,
0
,
0
,
&
arguments
);
printf
(
"Mode=%d
\n
"
,
arguments
.
mode
);
...
...
@@ -147,10 +150,10 @@ int main(int argc, char **argv)
printf
(
"Slave address list=%s
\n
"
,
arguments
.
slave_address_list
);
printf
(
"Key=%s
\n
"
,
arguments
.
key
);
printf
(
"Certificate=%s
\n
"
,
arguments
.
certificate
);
printf
(
"ID=%s
\n
"
,
arguments
.
id
);
printf
(
"ID=%d
\n
"
,
arguments
.
id
);
// transfer to global variables (CLI input)
COUPLER_ID
=
arguments
.
id
;
I2C_VIRTUAL_MODE
=
arguments
.
mode
;
I2C_BLOCK_DEVICE_NAME
=
arguments
.
device
;
...
...
@@ -229,7 +232,7 @@ int main(int argc, char **argv)
// enable keep-alive
UA_Int32
defaultInt32
=
0
;
UA_Int32
couplerID
=
atoi
(
arguments
.
id
)
;
UA_Int32
couplerID
=
COUPLER_ID
;
const
PublishedVariable
publishedVariableArray
[]
=
{
// representing time in millis since start of process
{
...
...
coupler/opc-ua-server/server_subscribe.c
View file @
eb01425d
...
...
@@ -212,9 +212,9 @@ static void fillTestDataSetMetaData(UA_DataSetMetaDataType *pMetaData) {
UA_DataSetMetaDataType_init
(
pMetaData
);
pMetaData
->
name
=
UA_STRING
(
"DataSet 1 (subscribed)"
);
/* Static definition of number of fields size to
4
to create four different
/* Static definition of number of fields size to
2
to create four different
* targetVariables of distinct datatype
* Currently the publisher sends only DateTime data type
*/
*/
pMetaData
->
fieldsSize
=
2
;
pMetaData
->
fields
=
(
UA_FieldMetaData
*
)
UA_Array_new
(
pMetaData
->
fieldsSize
,
&
UA_TYPES
[
UA_TYPES_FIELDMETADATA
]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment