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
532da4c8
Commit
532da4c8
authored
Oct 29, 2021
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly switch OFF all attached MOD-IOs (i.e. I2C slaves).
parent
6dd5e15e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
+17
-3
coupler/opc-ua-server/server.c
coupler/opc-ua-server/server.c
+17
-3
No files found.
coupler/opc-ua-server/server.c
View file @
532da4c8
...
...
@@ -23,6 +23,9 @@ uint8_t I2C_1_RELAYS_STATE = 0; // state of 4 relays at I2C slave 1
const
int
I2C_0_ADDR
=
0x58
;
const
int
I2C_1_ADDR
=
0x59
;
// the list of attached I2C slaves
const
int
I2C_SLAVE_ADDR_LIST
[]
=
{
I2C_0_ADDR
,
I2C_1_ADDR
};
// the block device at host machine
static
const
char
I2C_BLOCK_DEVICE_NAME
[]
=
"/dev/i2c-1"
;
...
...
@@ -398,8 +401,14 @@ static void stopHandler(int sign) {
}
int
main
(
void
)
{
int
i
;
int
length
=
sizeof
(
I2C_SLAVE_ADDR_LIST
)
/
sizeof
(
int
);
// set all relays to OFF at startup
setRelayState
(
0x00
,
I2C_0_ADDR
);
for
(
i
=
0
;
i
<
length
;
i
++
)
{
setRelayState
(
0x00
,
I2C_SLAVE_ADDR_LIST
[
i
]);
}
signal
(
SIGINT
,
stopHandler
);
signal
(
SIGTERM
,
stopHandler
);
...
...
@@ -416,8 +425,13 @@ int main(void) {
UA_Server_delete
(
server
);
// set all relays to OFF at startup
setRelayState
(
0x00
,
I2C_0_ADDR
);
// set all relays to OFF at shutdown
for
(
i
=
0
;
i
<
length
;
i
++
)
{
setRelayState
(
0x00
,
I2C_SLAVE_ADDR_LIST
[
i
]);
}
return
retval
==
UA_STATUSCODE_GOOD
?
EXIT_SUCCESS
:
EXIT_FAILURE
;
}
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