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
746ebd0a
Commit
746ebd0a
authored
16 years ago
by
Florian Pose
Browse files
Options
Downloads
Patches
Plain Diff
Made verbosity a master property; added -Wall flag to tools.
parent
093154bf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
TODO
+0
-1
0 additions, 1 deletion
TODO
tools/Makefile.am
+1
-1
1 addition, 1 deletion
tools/Makefile.am
tools/Master.cpp
+26
-25
26 additions, 25 deletions
tools/Master.cpp
tools/Master.h
+15
-7
15 additions, 7 deletions
tools/Master.h
tools/main.cpp
+10
-12
10 additions, 12 deletions
tools/main.cpp
with
52 additions
and
46 deletions
TODO
+
0
−
1
View file @
746ebd0a
...
...
@@ -14,7 +14,6 @@ Version 1.4.0:
* Update documentation.
* Add -a and -p switches for 'ethercat config' command.
* Add a -n (numeric) switch to ethercat command.
* Make verbose and quite flags a master property.
* File access over EtherCAT (FoE).
* Allow master requesting when in ORPHANED phase
* Get original driver for r8169.
...
...
This diff is collapsed.
Click to expand it.
tools/Makefile.am
+
1
−
1
View file @
746ebd0a
...
...
@@ -37,6 +37,6 @@ ethercat_SOURCES = \
Master.cpp Master.h
\
main.cpp
ethercat_CFLAGS
=
-I
../master
ethercat_C
XX
FLAGS
=
-I
../master
-Wall
#------------------------------------------------------------------------------
This diff is collapsed.
Click to expand it.
tools/Master.cpp
+
26
−
25
View file @
746ebd0a
...
...
@@ -100,6 +100,7 @@ const CoEDataType *findDataType(uint16_t code)
Master
::
Master
()
{
index
=
0
;
verbosity
=
Normal
;
fd
=
-
1
;
}
...
...
@@ -117,6 +118,13 @@ void Master::setIndex(unsigned int i)
index
=
i
;
}
/****************************************************************************/
void
Master
::
setVerbosity
(
Verbosity
v
)
{
verbosity
=
v
;
}
/*****************************************************************************/
/**
...
...
@@ -128,9 +136,6 @@ void Master::writeAlias(
const
vector
<
string
>
&
commandArgs
)
{
ec_ioctl_slave_sii_t
data
;
ec_ioctl_slave_t
slave
;
unsigned
int
i
;
uint16_t
alias
;
stringstream
err
,
strAlias
;
int
number
;
...
...
@@ -176,10 +181,10 @@ void Master::writeAlias(
/** Lists the bus configuration.
*/
void
Master
::
showConfigs
(
bool
verbose
)
void
Master
::
showConfigs
()
{
if
(
verbose
)
{
showConfigs
();
if
(
verbos
ity
==
Verbos
e
)
{
show
Detailed
Configs
();
}
else
{
listConfigs
();
}
...
...
@@ -312,7 +317,7 @@ void Master::showMaster()
/****************************************************************************/
void
Master
::
listPdos
(
int
slavePosition
,
bool
quiet
)
void
Master
::
listPdos
(
int
slavePosition
)
{
open
(
Read
);
...
...
@@ -320,16 +325,16 @@ void Master::listPdos(int slavePosition, bool quiet)
unsigned
int
numSlaves
=
slaveCount
(),
i
;
for
(
i
=
0
;
i
<
numSlaves
;
i
++
)
{
listSlavePdos
(
i
,
quiet
,
true
);
listSlavePdos
(
i
,
true
);
}
}
else
{
listSlavePdos
(
slavePosition
,
quiet
,
false
);
listSlavePdos
(
slavePosition
,
false
);
}
}
/****************************************************************************/
void
Master
::
listSdos
(
int
slavePosition
,
bool
quiet
)
void
Master
::
listSdos
(
int
slavePosition
)
{
open
(
Read
);
...
...
@@ -337,10 +342,10 @@ void Master::listSdos(int slavePosition, bool quiet)
unsigned
int
numSlaves
=
slaveCount
(),
i
;
for
(
i
=
0
;
i
<
numSlaves
;
i
++
)
{
listSlaveSdos
(
i
,
quiet
,
true
);
listSlaveSdos
(
i
,
true
);
}
}
else
{
listSlaveSdos
(
slavePosition
,
quiet
,
false
);
listSlaveSdos
(
slavePosition
,
false
);
}
}
...
...
@@ -354,7 +359,7 @@ void Master::sdoDownload(
{
stringstream
strIndex
,
strSubIndex
,
strValue
,
err
;
ec_ioctl_slave_sdo_download_t
data
;
unsigned
int
i
,
number
;
unsigned
int
number
;
const
CoEDataType
*
dataType
=
NULL
;
if
(
slavePosition
<
0
)
{
...
...
@@ -394,7 +399,6 @@ void Master::sdoDownload(
}
}
else
{
// no data type specified: fetch from dictionary
ec_ioctl_slave_sdo_entry_t
entry
;
unsigned
int
entryByteSize
;
open
(
ReadWrite
);
...
...
@@ -524,7 +528,7 @@ void Master::sdoUpload(
stringstream
strIndex
,
strSubIndex
;
int
sval
;
ec_ioctl_slave_sdo_upload_t
data
;
unsigned
int
i
,
uval
;
unsigned
int
uval
;
const
CoEDataType
*
dataType
=
NULL
;
if
(
slavePosition
<
0
)
{
...
...
@@ -569,7 +573,6 @@ void Master::sdoUpload(
}
}
else
{
// no data type specified: fetch from dictionary
ec_ioctl_slave_sdo_entry_t
entry
;
unsigned
int
entryByteSize
;
open
(
Read
);
...
...
@@ -665,11 +668,11 @@ void Master::sdoUpload(
/****************************************************************************/
void
Master
::
showSlaves
(
int
slavePosition
,
bool
verbose
)
void
Master
::
showSlaves
(
int
slavePosition
)
{
open
(
Read
);
if
(
verbose
)
{
if
(
verbos
ity
==
Verbos
e
)
{
if
(
slavePosition
==
-
1
)
{
unsigned
int
numSlaves
=
slaveCount
(),
i
;
...
...
@@ -975,7 +978,7 @@ void Master::writeSlaveAlias(
/** Lists the complete bus configuration.
*/
void
Master
::
showConfigs
()
void
Master
::
show
Detailed
Configs
()
{
ec_ioctl_master_t
master
;
unsigned
int
i
,
j
,
k
,
l
;
...
...
@@ -1248,7 +1251,6 @@ void Master::showDomain(unsigned int domainIndex)
void
Master
::
listSlavePdos
(
uint16_t
slavePosition
,
bool
quiet
,
bool
withHeader
)
{
...
...
@@ -1287,7 +1289,7 @@ void Master::listSlavePdos(
<<
setw
(
4
)
<<
pdo
.
index
<<
"
\"
"
<<
pdo
.
name
<<
"
\"
"
<<
endl
;
if
(
q
uiet
)
if
(
verbosity
==
Q
uiet
)
continue
;
for
(
k
=
0
;
k
<
pdo
.
entry_count
;
k
++
)
{
...
...
@@ -1308,14 +1310,13 @@ void Master::listSlavePdos(
void
Master
::
listSlaveSdos
(
uint16_t
slavePosition
,
bool
quiet
,
bool
withHeader
)
{
ec_ioctl_slave_t
slave
;
ec_ioctl_slave_sdo_t
sdo
;
ec_ioctl_slave_sdo_entry_t
entry
;
unsigned
int
i
,
j
,
k
;
unsigned
int
i
,
j
;
const
CoEDataType
*
d
;
getSlave
(
&
slave
,
slavePosition
);
...
...
@@ -1331,7 +1332,7 @@ void Master::listSlaveSdos(
<<
setw
(
4
)
<<
sdo
.
sdo_index
<<
",
\"
"
<<
sdo
.
name
<<
"
\"
"
<<
endl
;
if
(
q
uiet
)
if
(
verbosity
==
Q
uiet
)
continue
;
for
(
j
=
0
;
j
<=
sdo
.
max_subindex
;
j
++
)
{
...
...
@@ -1392,7 +1393,7 @@ void Master::listSlaves(int slavePosition)
aliasIndex
=
0
;
}
if
(
slavePosition
==
-
1
||
i
==
slavePosition
)
{
if
(
slavePosition
==
-
1
||
i
==
(
unsigned
int
)
slavePosition
)
{
str
<<
dec
<<
i
;
slaveInfo
.
pos
=
str
.
str
();
str
.
clear
();
...
...
This diff is collapsed.
Click to expand it.
tools/Master.h
+
15
−
7
View file @
746ebd0a
...
...
@@ -42,17 +42,24 @@ class Master
void
setIndex
(
unsigned
int
);
enum
Verbosity
{
Quiet
,
Normal
,
Verbose
};
void
setVerbosity
(
Verbosity
);
void
writeAlias
(
int
,
bool
,
const
vector
<
string
>
&
);
void
showConfigs
(
bool
);
void
showConfigs
();
void
outputData
(
int
);
void
setDebug
(
const
vector
<
string
>
&
);
void
showDomains
(
int
);
void
showMaster
();
void
listPdos
(
int
,
bool
=
false
);
void
listSdos
(
int
,
bool
=
false
);
void
listPdos
(
int
);
void
listSdos
(
int
);
void
sdoDownload
(
int
,
const
string
&
,
const
vector
<
string
>
&
);
void
sdoUpload
(
int
,
const
string
&
,
const
vector
<
string
>
&
);
void
showSlaves
(
int
,
bool
);
void
showSlaves
(
int
);
void
siiRead
(
int
);
void
siiWrite
(
int
,
bool
,
const
vector
<
string
>
&
);
void
requestStates
(
int
,
const
vector
<
string
>
&
);
...
...
@@ -64,12 +71,12 @@ class Master
void
close
();
void
writeSlaveAlias
(
uint16_t
,
uint16_t
);
void
showConfigs
();
void
show
Detailed
Configs
();
void
listConfigs
();
void
outputDomainData
(
unsigned
int
);
void
showDomain
(
unsigned
int
);
void
listSlavePdos
(
uint16_t
,
bool
=
false
,
bool
=
false
);
void
listSlaveSdos
(
uint16_t
,
bool
=
false
,
bool
=
false
);
void
listSlavePdos
(
uint16_t
,
bool
=
false
);
void
listSlaveSdos
(
uint16_t
,
bool
=
false
);
void
listSlaves
(
int
);
void
showSlave
(
uint16_t
);
void
generateSlaveXml
(
uint16_t
);
...
...
@@ -102,6 +109,7 @@ class Master
enum
{
DefaultBufferSize
=
1024
};
unsigned
int
index
;
Verbosity
verbosity
;
int
fd
;
};
...
...
This diff is collapsed.
Click to expand it.
tools/main.cpp
+
10
−
12
View file @
746ebd0a
...
...
@@ -22,8 +22,7 @@ static int slavePosition = -1;
static
int
domainIndex
=
-
1
;
static
string
command
;
vector
<
string
>
commandArgs
;
static
bool
quiet
=
false
;
static
bool
verbose
=
false
;
static
Master
::
Verbosity
verbosity
=
Master
::
Normal
;
string
dataTypeStr
;
bool
force
=
false
;
...
...
@@ -141,13 +140,11 @@ void getOptions(int argc, char **argv)
break
;
case
'q'
:
quiet
=
true
;
verbose
=
false
;
verbosity
=
Master
::
Quiet
;
break
;
case
'v'
:
verbose
=
true
;
quiet
=
false
;
verbosity
=
Master
::
Verbose
;
break
;
case
'h'
:
...
...
@@ -182,13 +179,14 @@ int main(int argc, char **argv)
getOptions
(
argc
,
argv
);
try
{
master
.
set
Index
(
masterIndex
);
master
.
setIndex
(
masterIndex
);
master
.
set
Verbosity
(
verbosity
);
try
{
if
(
command
==
"alias"
)
{
master
.
writeAlias
(
slavePosition
,
force
,
commandArgs
);
}
else
if
(
command
==
"config"
)
{
master
.
showConfigs
(
verbose
);
master
.
showConfigs
();
}
else
if
(
command
==
"data"
)
{
master
.
outputData
(
domainIndex
);
}
else
if
(
command
==
"debug"
)
{
...
...
@@ -198,16 +196,16 @@ int main(int argc, char **argv)
}
else
if
(
command
==
"master"
)
{
master
.
showMaster
();
}
else
if
(
command
==
"pdos"
)
{
master
.
listPdos
(
slavePosition
,
quiet
);
master
.
listPdos
(
slavePosition
);
}
else
if
(
command
==
"sdos"
)
{
master
.
listSdos
(
slavePosition
,
quiet
);
master
.
listSdos
(
slavePosition
);
}
else
if
(
command
==
"sdo_download"
||
command
==
"sd"
)
{
master
.
sdoDownload
(
slavePosition
,
dataTypeStr
,
commandArgs
);
}
else
if
(
command
==
"sdo_upload"
||
command
==
"su"
)
{
master
.
sdoUpload
(
slavePosition
,
dataTypeStr
,
commandArgs
);
}
else
if
(
command
==
"slave"
||
command
==
"slaves"
||
command
==
"list"
||
command
==
"ls"
)
{
master
.
showSlaves
(
slavePosition
,
verbose
);
master
.
showSlaves
(
slavePosition
);
}
else
if
(
command
==
"sii_read"
||
command
==
"sr"
)
{
master
.
siiRead
(
slavePosition
);
}
else
if
(
command
==
"sii_write"
||
command
==
"sw"
)
{
...
...
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