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
ba40d2ad
Commit
ba40d2ad
authored
16 years ago
by
Florian Pose
Browse files
Options
Downloads
Patches
Plain Diff
Added 'xml' command to generate a slave description file from a real
slave.
parent
0f64c18d
No related branches found
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
master/cdev.c
+2
-0
2 additions, 0 deletions
master/cdev.c
master/ioctl.h
+2
-0
2 additions, 0 deletions
master/ioctl.h
tools/Master.cpp
+113
-0
113 additions, 0 deletions
tools/Master.cpp
tools/Master.h
+2
-0
2 additions, 0 deletions
tools/Master.h
tools/main.cpp
+3
-1
3 additions, 1 deletion
tools/main.cpp
with
122 additions
and
1 deletion
master/cdev.c
+
2
−
0
View file @
ba40d2ad
...
...
@@ -165,6 +165,8 @@ long eccdev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
data
.
vendor_id
=
slave
->
sii
.
vendor_id
;
data
.
product_code
=
slave
->
sii
.
product_code
;
data
.
revision_number
=
slave
->
sii
.
revision_number
;
data
.
serial_number
=
slave
->
sii
.
serial_number
;
data
.
alias
=
slave
->
sii
.
alias
;
data
.
state
=
slave
->
current_state
;
...
...
This diff is collapsed.
Click to expand it.
master/ioctl.h
+
2
−
0
View file @
ba40d2ad
...
...
@@ -62,6 +62,8 @@ typedef struct {
// outputs
uint32_t
vendor_id
;
uint32_t
product_code
;
uint32_t
revision_number
;
uint32_t
serial_number
;
uint16_t
alias
;
uint8_t
state
;
uint8_t
sync_count
;
...
...
This diff is collapsed.
Click to expand it.
tools/Master.cpp
+
113
−
0
View file @
ba40d2ad
...
...
@@ -112,6 +112,21 @@ void Master::listPdos(int slavePosition)
/****************************************************************************/
void
Master
::
generateXml
(
int
slavePosition
)
{
if
(
slavePosition
==
-
1
)
{
unsigned
int
numSlaves
=
slaveCount
(),
i
;
for
(
i
=
0
;
i
<
numSlaves
;
i
++
)
{
generateSlaveXml
(
i
);
}
}
else
{
generateSlaveXml
(
slavePosition
);
}
}
/****************************************************************************/
void
Master
::
listSlavePdos
(
uint16_t
slavePosition
,
bool
printSlave
)
{
ec_ioctl_slave_t
slave
;
...
...
@@ -162,6 +177,104 @@ void Master::listSlavePdos(uint16_t slavePosition, bool printSlave)
/****************************************************************************/
void
Master
::
generateSlaveXml
(
uint16_t
slavePosition
)
{
ec_ioctl_slave_t
slave
;
ec_ioctl_sync_t
sync
;
ec_ioctl_pdo_t
pdo
;
ec_ioctl_pdo_entry_t
entry
;
unsigned
int
i
,
j
,
k
;
getSlave
(
&
slave
,
slavePosition
);
cout
<<
"<?xml version=
\"
1.0
\"
?>"
<<
endl
<<
" <EtherCATInfo>"
<<
endl
<<
" <!-- Slave "
<<
slave
.
position
<<
" -->"
<<
endl
<<
" <Vendor>"
<<
endl
<<
" <Id>"
<<
slave
.
vendor_id
<<
"</Id>"
<<
endl
<<
" </Vendor>"
<<
endl
<<
" <Descriptions>"
<<
endl
<<
" <Devices>"
<<
endl
<<
" <Device>"
<<
endl
<<
" <Type ProductCode=
\"
#x"
<<
hex
<<
setfill
(
'0'
)
<<
setw
(
8
)
<<
slave
.
product_code
<<
"
\"
RevisionNo=
\"
#x"
<<
hex
<<
setfill
(
'0'
)
<<
setw
(
8
)
<<
slave
.
revision_number
<<
"
\"
/>"
<<
endl
;
for
(
i
=
0
;
i
<
slave
.
sync_count
;
i
++
)
{
getSync
(
&
sync
,
slavePosition
,
i
);
for
(
j
=
0
;
j
<
sync
.
pdo_count
;
j
++
)
{
getPdo
(
&
pdo
,
slavePosition
,
i
,
j
);
cout
<<
" <"
<<
(
pdo
.
dir
?
"T"
:
"R"
)
<<
"xPdo>"
<<
endl
<<
" <Index>#x"
<<
hex
<<
setfill
(
'0'
)
<<
setw
(
4
)
<<
pdo
.
index
<<
"</Index>"
<<
endl
<<
" <Name>"
<<
pdo
.
name
<<
"</Name>"
<<
endl
;
for
(
k
=
0
;
k
<
pdo
.
entry_count
;
k
++
)
{
getPdoEntry
(
&
entry
,
slavePosition
,
i
,
j
,
k
);
cout
<<
" <Entry>"
<<
endl
<<
" <Index>#x"
<<
hex
<<
setfill
(
'0'
)
<<
setw
(
4
)
<<
entry
.
index
<<
"</Index>"
<<
endl
;
if
(
entry
.
index
)
cout
<<
" <SubIndex>"
<<
dec
<<
(
unsigned
int
)
entry
.
subindex
<<
"</SubIndex>"
<<
endl
;
cout
<<
" <BitLen>"
<<
(
unsigned
int
)
entry
.
bit_length
<<
"</BitLen>"
<<
endl
;
if
(
entry
.
index
)
{
cout
<<
" <Name>"
<<
entry
.
name
<<
"</Name>"
<<
endl
<<
" <DataType>"
;
if
(
entry
.
bit_length
==
1
)
{
cout
<<
"BOOL"
;
}
else
if
(
!
(
entry
.
bit_length
%
8
))
{
if
(
entry
.
bit_length
<=
64
)
cout
<<
"UINT"
<<
(
unsigned
int
)
entry
.
bit_length
;
else
cout
<<
"STRING("
<<
(
unsigned
int
)
(
entry
.
bit_length
/
8
)
<<
")"
;
}
else
{
cerr
<<
"Invalid bit length "
<<
(
unsigned
int
)
entry
.
bit_length
<<
endl
;
}
cout
<<
"</DataType>"
<<
endl
;
}
cout
<<
" </Entry>"
<<
endl
;
}
cout
<<
" </"
<<
(
pdo
.
dir
?
"T"
:
"R"
)
<<
"xPdo>"
<<
endl
;
}
}
cout
<<
" </Device>"
<<
endl
<<
" </Devices>"
<<
endl
<<
" </Descriptions>"
<<
endl
<<
"</EtherCATInfo>"
<<
endl
;
}
/****************************************************************************/
unsigned
int
Master
::
slaveCount
()
{
int
ret
;
...
...
This diff is collapsed.
Click to expand it.
tools/Master.h
+
2
−
0
View file @
ba40d2ad
...
...
@@ -42,9 +42,11 @@ class Master
void
listSlaves
();
void
listPdos
(
int
);
void
generateXml
(
int
);
protected:
void
listSlavePdos
(
uint16_t
,
bool
=
false
);
void
generateSlaveXml
(
uint16_t
);
unsigned
int
slaveCount
();
void
slaveSyncs
(
uint16_t
);
void
getSlave
(
ec_ioctl_slave_t
*
,
uint16_t
);
...
...
This diff is collapsed.
Click to expand it.
tools/main.cpp
+
3
−
1
View file @
ba40d2ad
...
...
@@ -31,6 +31,7 @@ void printUsage()
<<
"Commands:"
<<
endl
<<
" list (ls, slaves) List all slaves (former 'lsec')."
<<
endl
<<
" pdos List Pdo mapping of given slaves."
<<
endl
<<
" xml Generate slave information xml."
<<
endl
<<
"Global options:"
<<
endl
<<
" --master -m <master> Index of the master to use. Default: "
<<
DEFAULT_MASTER
<<
endl
...
...
@@ -121,9 +122,10 @@ int main(int argc, char **argv)
if
(
command
==
"list"
||
command
==
"ls"
||
command
==
"slaves"
)
{
master
.
listSlaves
();
}
else
if
(
command
==
"pdos"
)
{
master
.
listPdos
(
slavePosition
);
}
else
if
(
command
==
"xml"
)
{
master
.
generateXml
(
slavePosition
);
}
else
{
cerr
<<
"Unknown command "
<<
command
<<
"!"
<<
endl
;
printUsage
();
...
...
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