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
6450eaed
Commit
6450eaed
authored
May 05, 2022
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separate CLI handling to a new file.
parent
48570036
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
95 additions
and
92 deletions
+95
-92
coupler/opc-ua-server/cli.h
coupler/opc-ua-server/cli.h
+94
-0
coupler/opc-ua-server/server.c
coupler/opc-ua-server/server.c
+1
-92
No files found.
coupler/opc-ua-server/cli.h
0 → 100644
View file @
6450eaed
/*
* Command Line Interface handling.
*/
const
char
*
argp_program_version
=
"OSIE OPC-UA coupler 0.0.1"
;
const
char
*
argp_program_bug_address
=
"ivan@nexedi.com"
;
static
char
doc
[]
=
"OPC-UA server which controls MOD-IO's relays' state over OPC-UA protocol."
;
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
,
"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."
},
{
"username"
,
'u'
,
""
,
0
,
"Username."
},
{
"password"
,
'w'
,
""
,
0
,
"Password."
},
{
"key"
,
'k'
,
""
,
0
,
"x509 key."
},
{
"certificate"
,
'c'
,
""
,
0
,
"X509 certificate."
},
{
"id"
,
'i'
,
"0"
,
0
,
"ID of coupler."
},
{
"heart-beat"
,
'b'
,
"0"
,
0
,
"Publish heart beat to other couplers."
},
{
"heart-beat-interval"
,
't'
,
"500"
,
0
,
"Heart beat interval in ms."
},
{
"heart-beat-id-list"
,
'l'
,
""
,
0
,
"Comma separated list of IDs of couplers to watch for heart beats. \
If heart beat is missing coupler goes to safe mode."
},
{
"network-address-url-data-type"
,
'n'
,
"opc.udp://224.0.0.22:4840/"
,
0
,
"Netwrok address URL type used for Pub/Sub."
},
{
0
}
};
struct
arguments
{
int
mode
;
int
port
;
char
*
device
;
char
*
slave_address_list
;
char
*
username
;
char
*
password
;
char
*
key
;
char
*
certificate
;
int
id
;
bool
heart_beat
;
int
heart_beat_interval
;
char
*
heart_beat_id_list
;
char
*
network_address_url_data_type
;
};
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
;
case
'd'
:
arguments
->
device
=
arg
;
break
;
case
's'
:
arguments
->
slave_address_list
=
arg
;
break
;
case
'm'
:
arguments
->
mode
=
arg
?
atoi
(
arg
)
:
DEFAULT_MODE
;
break
;
case
'u'
:
arguments
->
username
=
arg
;
break
;
case
'w'
:
arguments
->
password
=
arg
;
break
;
case
'c'
:
arguments
->
certificate
=
arg
;
break
;
case
'k'
:
arguments
->
key
=
arg
;
break
;
case
'i'
:
arguments
->
id
=
arg
?
atoi
(
arg
)
:
DEFAULT_ID
;
break
;
case
'b'
:
arguments
->
heart_beat
=
atoi
(
arg
);
break
;
case
't'
:
arguments
->
heart_beat_interval
=
arg
?
atoi
(
arg
)
:
DEFAULT_HEART_BEAT_INTERVAL
;
break
;
case
'l'
:
arguments
->
heart_beat_id_list
=
arg
;
break
;
case
'n'
:
arguments
->
network_address_url_data_type
=
arg
;
break
;
case
ARGP_KEY_ARG
:
return
0
;
default:
return
ARGP_ERR_UNKNOWN
;
}
return
0
;
}
coupler/opc-ua-server/server.c
View file @
6450eaed
...
...
@@ -50,98 +50,7 @@ const int DEFAULT_ID = 0;
#include "keep_alive_publisher.h"
#include "keep_alive_subscriber.h"
// CLI arguments handling
const
char
*
argp_program_version
=
"OSIE OPC-UA coupler 0.0.1"
;
const
char
*
argp_program_bug_address
=
"ivan@nexedi.com"
;
static
char
doc
[]
=
"OPC-UA server which controls MOD-IO's relays' state over OPC-UA protocol."
;
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
,
"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."
},
{
"username"
,
'u'
,
""
,
0
,
"Username."
},
{
"password"
,
'w'
,
""
,
0
,
"Password."
},
{
"key"
,
'k'
,
""
,
0
,
"x509 key."
},
{
"certificate"
,
'c'
,
""
,
0
,
"X509 certificate."
},
{
"id"
,
'i'
,
"0"
,
0
,
"ID of coupler."
},
{
"heart-beat"
,
'b'
,
"0"
,
0
,
"Publish heart beat to other couplers."
},
{
"heart-beat-interval"
,
't'
,
"500"
,
0
,
"Heart beat interval in ms."
},
{
"heart-beat-id-list"
,
'l'
,
""
,
0
,
"Comma separated list of IDs of couplers to watch for heart beats. \
If heart beat is missing coupler goes to safe mode."
},
{
"network-address-url-data-type"
,
'n'
,
"opc.udp://224.0.0.22:4840/"
,
0
,
"Netwrok address URL type used for Pub/Sub."
},
{
0
}
};
struct
arguments
{
int
mode
;
int
port
;
char
*
device
;
char
*
slave_address_list
;
char
*
username
;
char
*
password
;
char
*
key
;
char
*
certificate
;
int
id
;
bool
heart_beat
;
int
heart_beat_interval
;
char
*
heart_beat_id_list
;
char
*
network_address_url_data_type
;
};
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
;
case
'd'
:
arguments
->
device
=
arg
;
break
;
case
's'
:
arguments
->
slave_address_list
=
arg
;
break
;
case
'm'
:
arguments
->
mode
=
arg
?
atoi
(
arg
)
:
DEFAULT_MODE
;
break
;
case
'u'
:
arguments
->
username
=
arg
;
break
;
case
'w'
:
arguments
->
password
=
arg
;
break
;
case
'c'
:
arguments
->
certificate
=
arg
;
break
;
case
'k'
:
arguments
->
key
=
arg
;
break
;
case
'i'
:
arguments
->
id
=
arg
?
atoi
(
arg
)
:
DEFAULT_ID
;
break
;
case
'b'
:
arguments
->
heart_beat
=
atoi
(
arg
);
break
;
case
't'
:
arguments
->
heart_beat_interval
=
arg
?
atoi
(
arg
)
:
DEFAULT_HEART_BEAT_INTERVAL
;
break
;
case
'l'
:
arguments
->
heart_beat_id_list
=
arg
;
break
;
case
'n'
:
arguments
->
network_address_url_data_type
=
arg
;
break
;
case
ARGP_KEY_ARG
:
return
0
;
default:
return
ARGP_ERR_UNKNOWN
;
}
return
0
;
}
#include "cli.h"
static
struct
argp
argp
=
{
options
,
parse_opt
,
args_doc
,
doc
,
0
,
0
,
0
};
...
...
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