Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
etherlabmaster
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ICS Control System Infrastructure
etherlabmaster
Commits
c19f0c6d
Commit
c19f0c6d
authored
16 years ago
by
Florian Pose
Browse files
Options
Downloads
Patches
Plain Diff
Added multi-slave support.
parent
902865c3
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
tools/Master.cpp
+18
-0
18 additions, 0 deletions
tools/Master.cpp
tools/Master.h
+1
-0
1 addition, 0 deletions
tools/Master.h
tools/main.cpp
+18
-11
18 additions, 11 deletions
tools/main.cpp
with
37 additions
and
11 deletions
tools/Master.cpp
+
18
−
0
View file @
c19f0c6d
...
@@ -98,6 +98,21 @@ void Master::listSlaves()
...
@@ -98,6 +98,21 @@ void Master::listSlaves()
/****************************************************************************/
/****************************************************************************/
void
Master
::
listPdos
(
int
slavePosition
)
void
Master
::
listPdos
(
int
slavePosition
)
{
if
(
slavePosition
==
-
1
)
{
unsigned
int
numSlaves
=
slaveCount
(),
i
;
for
(
i
=
0
;
i
<
numSlaves
;
i
++
)
{
listSlavePdos
(
i
,
true
);
}
}
else
{
listSlavePdos
(
slavePosition
,
false
);
}
}
/****************************************************************************/
void
Master
::
listSlavePdos
(
uint16_t
slavePosition
,
bool
printSlave
)
{
{
ec_ioctl_slave_t
slave
;
ec_ioctl_slave_t
slave
;
ec_ioctl_sync_t
sync
;
ec_ioctl_sync_t
sync
;
...
@@ -107,6 +122,9 @@ void Master::listPdos(int slavePosition)
...
@@ -107,6 +122,9 @@ void Master::listPdos(int slavePosition)
getSlave
(
&
slave
,
slavePosition
);
getSlave
(
&
slave
,
slavePosition
);
if
(
printSlave
)
cout
<<
"=== Slave "
<<
slavePosition
<<
" ==="
<<
endl
;
for
(
i
=
0
;
i
<
slave
.
sync_count
;
i
++
)
{
for
(
i
=
0
;
i
<
slave
.
sync_count
;
i
++
)
{
getSync
(
&
sync
,
slavePosition
,
i
);
getSync
(
&
sync
,
slavePosition
,
i
);
...
...
This diff is collapsed.
Click to expand it.
tools/Master.h
+
1
−
0
View file @
c19f0c6d
...
@@ -44,6 +44,7 @@ class Master
...
@@ -44,6 +44,7 @@ class Master
void
listPdos
(
int
);
void
listPdos
(
int
);
protected:
protected:
void
listSlavePdos
(
uint16_t
,
bool
=
false
);
unsigned
int
slaveCount
();
unsigned
int
slaveCount
();
void
slaveSyncs
(
uint16_t
);
void
slaveSyncs
(
uint16_t
);
void
getSlave
(
ec_ioctl_slave_t
*
,
uint16_t
);
void
getSlave
(
ec_ioctl_slave_t
*
,
uint16_t
);
...
...
This diff is collapsed.
Click to expand it.
tools/main.cpp
+
18
−
11
View file @
c19f0c6d
...
@@ -16,10 +16,10 @@ using namespace std;
...
@@ -16,10 +16,10 @@ using namespace std;
#define DEFAULT_MASTER 0
#define DEFAULT_MASTER 0
#define DEFAULT_COMMAND "slaves"
#define DEFAULT_COMMAND "slaves"
#define DEFAULT_SLAVE
SPEC ""
#define DEFAULT_SLAVE
POSITION -1
static
unsigned
int
masterIndex
=
DEFAULT_MASTER
;
static
unsigned
int
masterIndex
=
DEFAULT_MASTER
;
static
int
slavePosition
=
-
1
;
static
int
slavePosition
=
DEFAULT_SLAVEPOSITION
;
static
string
command
=
DEFAULT_COMMAND
;
static
string
command
=
DEFAULT_COMMAND
;
/*****************************************************************************/
/*****************************************************************************/
...
@@ -34,8 +34,10 @@ void printUsage()
...
@@ -34,8 +34,10 @@ void printUsage()
<<
"Global options:"
<<
endl
<<
"Global options:"
<<
endl
<<
" --master -m <master> Index of the master to use. Default: "
<<
" --master -m <master> Index of the master to use. Default: "
<<
DEFAULT_MASTER
<<
endl
<<
DEFAULT_MASTER
<<
endl
<<
" --slave -s <slave> Numerical ring position. Default: All "
<<
" --slave -s <slave> Positive numerical ring position,"
"slaves."
<<
endl
<<
endl
<<
" or 'all' for all slaves. Default: 'all'."
<<
endl
<<
" --help -h Show this help."
<<
endl
;
<<
" --help -h Show this help."
<<
endl
;
}
}
...
@@ -69,14 +71,19 @@ void getOptions(int argc, char **argv)
...
@@ -69,14 +71,19 @@ void getOptions(int argc, char **argv)
break
;
break
;
case
's'
:
case
's'
:
number
=
strtoul
(
optarg
,
&
remainder
,
0
);
if
(
!
strcmp
(
optarg
,
"all"
))
{
if
(
remainder
==
optarg
||
*
remainder
slavePosition
=
-
1
;
||
number
<
0
||
number
>
0xFFFF
)
{
}
else
{
cerr
<<
"Invalid slave position "
<<
optarg
<<
"!"
<<
endl
;
number
=
strtoul
(
optarg
,
&
remainder
,
0
);
printUsage
();
if
(
remainder
==
optarg
||
*
remainder
exit
(
1
);
||
number
<
0
||
number
>
0xFFFF
)
{
cerr
<<
"Invalid slave position "
<<
optarg
<<
"!"
<<
endl
;
printUsage
();
exit
(
1
);
}
slavePosition
=
number
;
}
}
slavePosition
=
number
;
break
;
break
;
case
'h'
:
case
'h'
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment