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
4cbe4062
Commit
4cbe4062
authored
Oct 07, 2021
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use bitwise operation to set proper relays' state (WIP).
parent
3fbb86ee
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
4 deletions
+14
-4
coupler/opc-ua-server/server.c
coupler/opc-ua-server/server.c
+14
-4
No files found.
coupler/opc-ua-server/server.c
View file @
4cbe4062
...
...
@@ -17,6 +17,9 @@
#include <open62541/server.h>
#include <open62541/server_config_default.h>
// global relay state
uint8_t
myrelay
=
0
;
static
int
setRelayState
(
int
command
)
{
/*
* Set relays' state over I2C
...
...
@@ -127,7 +130,7 @@ static void beforeReadTime(UA_Server *server,
const
UA_NodeId
*
sessionId
,
void
*
sessionContext
,
const
UA_NodeId
*
nodeid
,
void
*
nodeContext
,
const
UA_NumericRange
*
range
,
const
UA_DataValue
*
data
)
{
//
printf("Before read.");
//
nothing to do as not yet needed.
}
static
void
afterWriteTime
(
UA_Server
*
server
,
...
...
@@ -138,12 +141,19 @@ static void afterWriteTime(UA_Server *server,
if
(
data
->
value
.
type
==
&
UA_TYPES
[
UA_TYPES_INT32
])
{
UA_Int32
hrValue
=
*
(
UA_Int32
*
)
data
->
value
.
data
;
//printf("
int32V
alue %u\n", hrValue);
//printf("
v
alue %u\n", hrValue);
if
(
hrValue
>
0
){
setRelayState
(
0x0F
);
//printf("relaystate=%d", (int) myrelay);
myrelay
|=
1UL
<<
0
;
// relay0
myrelay
|=
1UL
<<
1
;
myrelay
|=
1UL
<<
2
;
myrelay
|=
1UL
<<
3
;
// relay3
setRelayState
(
myrelay
);
}
else
{
setRelayState
(
0x00
);
myrelay
&=
~
(
1UL
<<
0
);
// relay0
myrelay
&=
~
(
1UL
<<
3
);
// relay3
setRelayState
(
myrelay
);
}
}
}
...
...
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