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
Martin Manchev
osie
Commits
502ab54b
Commit
502ab54b
authored
Apr 20, 2022
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add heart_beat callback. Cleanup tabulations.
parent
0de27517
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
24 deletions
+42
-24
coupler/opc-ua-server/server.c
coupler/opc-ua-server/server.c
+42
-24
No files found.
coupler/opc-ua-server/server.c
View file @
502ab54b
...
...
@@ -37,6 +37,11 @@
// global Id of coupler
static
int
COUPLER_ID
=
0
;
// global HEART BEATs of coupler
static
int
HEART_BEATS
=
0
;
// the heart beat interval
static
int
HEART_BEAT_INTERVAL
=
250
;
// The default port of OPC-UA server
const
int
DEFAULT_OPC_UA_PORT
=
4840
;
const
int
DEFAULT_MODE
=
0
;
...
...
@@ -51,7 +56,7 @@ static struct argp_option options[] = {
{
"device"
,
'd'
,
"/dev/i2c-1"
,
0
,
"Linux block device path."
},
{
"slave-address-list"
,
's'
,
"0x58"
,
0
,
"Comma separated list of slave I2C addresses."
},
{
"mode"
,
'm'
,
"0"
,
0
,
"Set different modes of operation of coupler. Default (0) is set attached \
I2C's state state. Virtual (1) which does NOT set any I2C slaves' state."
},
I2C's state state. Virtual (1) which does NOT set any I2C slaves' state."
},
{
"username"
,
'u'
,
""
,
0
,
"Username."
},
{
"password"
,
'w'
,
""
,
0
,
"Password."
},
{
"key"
,
'k'
,
""
,
0
,
"x509 key."
},
...
...
@@ -78,36 +83,36 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state)
struct
arguments
*
arguments
=
state
->
input
;
switch
(
key
)
{
case
'p'
:
arguments
->
port
=
arg
?
atoi
(
arg
)
:
DEFAULT_OPC_UA_PORT
;
break
;
arguments
->
port
=
arg
?
atoi
(
arg
)
:
DEFAULT_OPC_UA_PORT
;
break
;
case
'd'
:
arguments
->
device
=
arg
;
break
;
arguments
->
device
=
arg
;
break
;
case
's'
:
arguments
->
slave_address_list
=
arg
;
break
;
arguments
->
slave_address_list
=
arg
;
break
;
case
'm'
:
arguments
->
mode
=
arg
?
atoi
(
arg
)
:
DEFAULT_MODE
;
break
;
arguments
->
mode
=
arg
?
atoi
(
arg
)
:
DEFAULT_MODE
;
break
;
case
'u'
:
arguments
->
username
=
arg
;
break
;
arguments
->
username
=
arg
;
break
;
case
'w'
:
arguments
->
password
=
arg
;
break
;
arguments
->
password
=
arg
;
break
;
case
'c'
:
arguments
->
certificate
=
arg
;
break
;
arguments
->
certificate
=
arg
;
break
;
case
'k'
:
arguments
->
key
=
arg
;
break
;
arguments
->
key
=
arg
;
break
;
case
'i'
:
arguments
->
id
=
arg
?
atoi
(
arg
)
:
0
;
break
;
arguments
->
id
=
arg
?
atoi
(
arg
)
:
0
;
break
;
case
ARGP_KEY_ARG
:
return
0
;
return
0
;
default:
return
ARGP_ERR_UNKNOWN
;
return
ARGP_ERR_UNKNOWN
;
}
return
0
;
}
...
...
@@ -122,6 +127,14 @@ static void stopHandler(int sign)
running
=
false
;
}
void
callbackTicHeartBeat
()
{
/* Increase periodically heart beats of the server */
HEART_BEATS
+=
1
;
UA_LOG_INFO
(
UA_Log_Stdout
,
UA_LOGCATEGORY_USERLAND
,
"heart_beat %d"
,
HEART_BEATS
);
// XXX: set OPC ua's heat_beat value
}
int
main
(
int
argc
,
char
**
argv
)
{
int
i
;
...
...
@@ -180,7 +193,7 @@ int main(int argc, char **argv)
UA_ServerConfig
*
config
=
UA_Server_getConfig
(
server
);
config
->
verifyRequestTimestamp
=
UA_RULEHANDLING_ACCEPT
;
// add variables representing physical relar
ys
/ inputs, etc
// add variables representing physical relar
ay
/ inputs, etc
addVariable
(
server
);
addValueCallbackToCurrentTimeVariable
(
server
);
...
...
@@ -229,8 +242,13 @@ int main(int argc, char **argv)
#endif
// enable keep-alive
UA_Int32
defaultInt32
=
0
;
UA_Int32
couplerID
=
COUPLER_ID
;
// add a callback which will increment heart beat tics
UA_UInt64
callbackId
=
1
;
UA_Server_addRepeatedCallback
(
server
,
callbackTicHeartBeat
,
NULL
,
HEART_BEAT_INTERVAL
,
&
callbackId
);
UA_Int32
defaultInt32
=
0
;
//XXX: use unsigned int
UA_Int32
couplerID
=
COUPLER_ID
;
//XXX: use unsigned int
const
PublishedVariable
publishedVariableArray
[]
=
{
// representing time in millis since start of process
{
...
...
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