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
1
Merge Requests
1
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
f541b4bb
Commit
f541b4bb
authored
Oct 28, 2021
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename.
parent
fb7f6def
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
12 deletions
+12
-12
coupler/opc-ua-server/server.c
coupler/opc-ua-server/server.c
+12
-12
No files found.
coupler/opc-ua-server/server.c
View file @
f541b4bb
...
@@ -22,8 +22,8 @@ uint8_t I2C_0_RELAYS_STATE = 0; // state of 4 relays at MOD-IO 0
...
@@ -22,8 +22,8 @@ uint8_t I2C_0_RELAYS_STATE = 0; // state of 4 relays at MOD-IO 0
uint8_t
I2C_1_RELAYS_STATE
=
0
;
// state of 4 relays at MOD-IO 1
uint8_t
I2C_1_RELAYS_STATE
=
0
;
// state of 4 relays at MOD-IO 1
// the default addresses of MOD-IOs
// the default addresses of MOD-IOs
const
int
MOD_IO
_0_ADDR
=
0x58
;
const
int
I2C
_0_ADDR
=
0x58
;
const
int
MOD_IO
_1_ADDR
=
0x59
;
const
int
I2C
_1_ADDR
=
0x59
;
// the block device at host machine
// the block device at host machine
static
const
char
I2C_BLOCK_DEVICE_NAME
[]
=
"/dev/i2c-1"
;
static
const
char
I2C_BLOCK_DEVICE_NAME
[]
=
"/dev/i2c-1"
;
...
@@ -147,11 +147,11 @@ static void afterWriteTime0(UA_Server *server,
...
@@ -147,11 +147,11 @@ static void afterWriteTime0(UA_Server *server,
UA_Int32
hrValue
=
*
(
UA_Int32
*
)
data
->
value
.
data
;
UA_Int32
hrValue
=
*
(
UA_Int32
*
)
data
->
value
.
data
;
if
(
hrValue
>
0
){
if
(
hrValue
>
0
){
I2C_0_RELAYS_STATE
|=
1UL
<<
0
;
I2C_0_RELAYS_STATE
|=
1UL
<<
0
;
setRelayState
(
I2C_0_RELAYS_STATE
,
MOD_IO
_0_ADDR
);
setRelayState
(
I2C_0_RELAYS_STATE
,
I2C
_0_ADDR
);
}
}
else
{
else
{
I2C_0_RELAYS_STATE
&=
~
(
1UL
<<
0
);
I2C_0_RELAYS_STATE
&=
~
(
1UL
<<
0
);
setRelayState
(
I2C_0_RELAYS_STATE
,
MOD_IO
_0_ADDR
);
setRelayState
(
I2C_0_RELAYS_STATE
,
I2C
_0_ADDR
);
}
}
}
}
}
}
...
@@ -164,11 +164,11 @@ static void afterWriteTime1(UA_Server *server,
...
@@ -164,11 +164,11 @@ static void afterWriteTime1(UA_Server *server,
UA_Int32
hrValue
=
*
(
UA_Int32
*
)
data
->
value
.
data
;
UA_Int32
hrValue
=
*
(
UA_Int32
*
)
data
->
value
.
data
;
if
(
hrValue
>
0
){
if
(
hrValue
>
0
){
I2C_0_RELAYS_STATE
|=
1UL
<<
1
;
I2C_0_RELAYS_STATE
|=
1UL
<<
1
;
setRelayState
(
I2C_0_RELAYS_STATE
,
MOD_IO
_0_ADDR
);
setRelayState
(
I2C_0_RELAYS_STATE
,
I2C
_0_ADDR
);
}
}
else
{
else
{
I2C_0_RELAYS_STATE
&=
~
(
1UL
<<
1
);
I2C_0_RELAYS_STATE
&=
~
(
1UL
<<
1
);
setRelayState
(
I2C_0_RELAYS_STATE
,
MOD_IO
_0_ADDR
);
setRelayState
(
I2C_0_RELAYS_STATE
,
I2C
_0_ADDR
);
}
}
}
}
}
}
...
@@ -181,11 +181,11 @@ static void afterWriteTime2(UA_Server *server,
...
@@ -181,11 +181,11 @@ static void afterWriteTime2(UA_Server *server,
UA_Int32
hrValue
=
*
(
UA_Int32
*
)
data
->
value
.
data
;
UA_Int32
hrValue
=
*
(
UA_Int32
*
)
data
->
value
.
data
;
if
(
hrValue
>
0
){
if
(
hrValue
>
0
){
I2C_0_RELAYS_STATE
|=
1UL
<<
2
;
I2C_0_RELAYS_STATE
|=
1UL
<<
2
;
setRelayState
(
I2C_0_RELAYS_STATE
,
MOD_IO
_0_ADDR
);
setRelayState
(
I2C_0_RELAYS_STATE
,
I2C
_0_ADDR
);
}
}
else
{
else
{
I2C_0_RELAYS_STATE
&=
~
(
1UL
<<
2
);
I2C_0_RELAYS_STATE
&=
~
(
1UL
<<
2
);
setRelayState
(
I2C_0_RELAYS_STATE
,
MOD_IO
_0_ADDR
);
setRelayState
(
I2C_0_RELAYS_STATE
,
I2C
_0_ADDR
);
}
}
}
}
}
}
...
@@ -198,11 +198,11 @@ static void afterWriteTime3(UA_Server *server,
...
@@ -198,11 +198,11 @@ static void afterWriteTime3(UA_Server *server,
UA_Int32
hrValue
=
*
(
UA_Int32
*
)
data
->
value
.
data
;
UA_Int32
hrValue
=
*
(
UA_Int32
*
)
data
->
value
.
data
;
if
(
hrValue
>
0
){
if
(
hrValue
>
0
){
I2C_0_RELAYS_STATE
|=
1UL
<<
3
;
I2C_0_RELAYS_STATE
|=
1UL
<<
3
;
setRelayState
(
I2C_0_RELAYS_STATE
,
MOD_IO
_0_ADDR
);
setRelayState
(
I2C_0_RELAYS_STATE
,
I2C
_0_ADDR
);
}
}
else
{
else
{
I2C_0_RELAYS_STATE
&=
~
(
1UL
<<
3
);
I2C_0_RELAYS_STATE
&=
~
(
1UL
<<
3
);
setRelayState
(
I2C_0_RELAYS_STATE
,
MOD_IO
_0_ADDR
);
setRelayState
(
I2C_0_RELAYS_STATE
,
I2C
_0_ADDR
);
}
}
}
}
}
}
...
@@ -248,7 +248,7 @@ static void stopHandler(int sign) {
...
@@ -248,7 +248,7 @@ static void stopHandler(int sign) {
int
main
(
void
)
{
int
main
(
void
)
{
// set all relays to OFF at startup
// set all relays to OFF at startup
setRelayState
(
0x00
,
MOD_IO
_0_ADDR
);
setRelayState
(
0x00
,
I2C
_0_ADDR
);
signal
(
SIGINT
,
stopHandler
);
signal
(
SIGINT
,
stopHandler
);
signal
(
SIGTERM
,
stopHandler
);
signal
(
SIGTERM
,
stopHandler
);
...
@@ -266,7 +266,7 @@ int main(void) {
...
@@ -266,7 +266,7 @@ int main(void) {
UA_Server_delete
(
server
);
UA_Server_delete
(
server
);
// set all relays to OFF at startup
// set all relays to OFF at startup
setRelayState
(
0x00
,
MOD_IO
_0_ADDR
);
setRelayState
(
0x00
,
I2C
_0_ADDR
);
return
retval
==
UA_STATUSCODE_GOOD
?
EXIT_SUCCESS
:
EXIT_FAILURE
;
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