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
88859691
Commit
88859691
authored
Jan 24, 2022
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose only OPC-UA nodes based on configured I2C slave list.
parent
80960f0e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
27 deletions
+50
-27
coupler/opc-ua-server/server.c
coupler/opc-ua-server/server.c
+50
-27
No files found.
coupler/opc-ua-server/server.c
View file @
88859691
...
...
@@ -35,7 +35,7 @@ static char args_doc[] = "...";
static
struct
argp_option
options
[]
=
{
{
"port"
,
'p'
,
"4840"
,
0
,
"Port to bind to."
},
{
"device"
,
'd'
,
"/dev/i2c-1"
,
0
,
"Linux block device path."
},
{
"slave-address-list"
,
's'
,
"0x58"
,
0
,
"
L
ist of slave I2C addresses."
},
{
"slave-address-list"
,
's'
,
"0x58"
,
0
,
"
Comma separated l
ist 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."
},
{
0
}
...
...
@@ -96,6 +96,25 @@ char *I2C_BLOCK_DEVICE_NAME;
// global virtual mode needed for testing on x86 platform
bool
I2C_VIRTUAL_MODE
=
0
;
static
int
getI2CSlaveListLength
()
{
/*
* Return ONLY registred I2C slaves
*/
int
i
;
int
addr
;
int
counter
=
0
;
int
length
=
sizeof
(
I2C_SLAVE_ADDR_LIST
)
/
sizeof
(
int
);
for
(
i
=
0
;
i
<
length
;
i
++
)
{
addr
=
I2C_SLAVE_ADDR_LIST
[
i
];
if
(
addr
!=
0
)
{
counter
++
;
}
}
return
counter
;
}
static
int
setRelayState
(
int
command
,
int
i2c_addr
)
{
/*
* Set relays' state over I2C
...
...
@@ -160,7 +179,7 @@ static void addVariable(UA_Server *server) {
/*
* Create all variables representing MOD-IO's relays
*/
int
length
=
sizeof
(
I2C_SLAVE_ADDR_LIST
)
/
sizeof
(
int
);
int
length
=
getI2CSlaveListLength
(
);
if
(
length
>=
1
)
{
// IC2-0
addIntegerVariableNode
(
server
,
"i2c0.relay0"
,
"I2C0 / Relay 0"
);
...
...
@@ -335,7 +354,9 @@ static void afterWriteTimeI2C1_3(UA_Server *server,
}
}
static
void
addValueCallbackToCurrentTimeVariable
(
UA_Server
*
server
)
{
int
length
=
getI2CSlaveListLength
();
// I2C0
// relay 0
UA_NodeId
currentNodeId0
=
UA_NODEID_STRING
(
1
,
"i2c0.relay0"
);
...
...
@@ -365,6 +386,7 @@ static void addValueCallbackToCurrentTimeVariable(UA_Server *server) {
callback3
.
onWrite
=
afterWriteTimeI2C0_3
;
UA_Server_setVariableNode_valueCallback
(
server
,
currentNodeId3
,
callback3
);
if
(
length
>
1
){
// I2C1
// relay 0
UA_NodeId
currentNodeId4
=
UA_NODEID_STRING
(
1
,
"i2c1.relay0"
);
...
...
@@ -393,6 +415,7 @@ static void addValueCallbackToCurrentTimeVariable(UA_Server *server) {
callback7
.
onRead
=
beforeReadTime
;
callback7
.
onWrite
=
afterWriteTimeI2C1_3
;
UA_Server_setVariableNode_valueCallback
(
server
,
currentNodeId7
,
callback7
);
}
}
...
...
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