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
c5dc1aa2
Commit
c5dc1aa2
authored
17 years ago
by
Florian Pose
Browse files
Options
Downloads
Patches
Plain Diff
Fixed lsec script.
parent
bc7a5454
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
script/lsec
+37
-15
37 additions, 15 deletions
script/lsec
with
37 additions
and
15 deletions
script/lsec
+
37
−
15
View file @
c5dc1aa2
...
@@ -63,7 +63,6 @@ sub query
...
@@ -63,7 +63,6 @@ sub query
my
$slave_info_file
;
my
$slave_info_file
;
my
@slaves
;
my
@slaves
;
my
$slave
;
my
$slave
;
my
$abs
;
my
$line
;
my
$line
;
my
$ring_col_width
;
my
$ring_col_width
;
my
$alias_col_width
;
my
$alias_col_width
;
...
@@ -71,6 +70,7 @@ sub query
...
@@ -71,6 +70,7 @@ sub query
my
$width
;
my
$width
;
my
$last_alias
;
my
$last_alias
;
my
$alias_index
;
my
$alias_index
;
my
$category
;
$master_dir
=
"
/sys/ethercat/master
"
.
$master_index
;
$master_dir
=
"
/sys/ethercat/master
"
.
$master_index
;
...
@@ -87,21 +87,35 @@ sub query
...
@@ -87,21 +87,35 @@ sub query
open
INFO
,
$slave_info_file
or
die
open
INFO
,
$slave_info_file
or
die
"
ERROR: Failed to open
$slave_info_file
.
";
"
ERROR: Failed to open
$slave_info_file
.
";
$category
=
"";
while
(
$line
=
<
INFO
>
)
{
while
(
$line
=
<
INFO
>
)
{
if
(
$line
=~
/^Name: (.*)$/
)
{
# remember category
$slave
->
{'
name
'}
=
$
1
;
if
(
$line
=~
/^([^\s][^:]*):$/
)
{
$category
=
$
1
;
}
elsif
(
$line
=~
/^\s*$/
)
{
$category
=
"";
}
}
elsif
(
$line
=~
/^Ring position: (\d+)$/
)
{
$slave
->
{'
ring_position
'}
=
$
1
;
if
(
$category
eq
"")
{
}
if
(
$line
=~
/^Ring position: (\d+)$/
)
{
elsif
(
$line
=~
/Configured station alias: .* \((\d+)\)$/
)
{
$slave
->
{'
ring_position
'}
=
$
1
;
$slave
->
{'
alias
'}
=
$
1
;
}
elsif
(
$line
=~
/^State: (.+) /
)
{
}
$slave
->
{'
state
'}
=
$
1
;
elsif
(
$line
=~
/^State: (.+) /
)
{
}
elsif
(
$line
=~
/^Configured station alias: .* \((\d+)\)$/
)
{
$slave
->
{'
state
'}
=
$
1
;
$slave
->
{'
alias
'}
=
$
1
;
}
}
elsif
(
$line
=~
/^Current consumption: (-?\d+) mA$/
)
{
elsif
(
$line
=~
/^Current consumption: (-?\d+) mA$/
)
{
$slave
->
{'
current
'}
=
$
1
;
$slave
->
{'
current
'}
=
$
1
;
}
}
elsif
(
$category
eq
"
Identity
")
{
if
(
$line
=~
/Vendor ID: .* \((\d+)\)$/
)
{
$slave
->
{'
vendor
'}
=
$
1
;
}
elsif
(
$line
=~
/Product code: .* \((\d+)\)$/
)
{
$slave
->
{'
product
'}
=
$
1
;
}
}
elsif
(
$category
eq
"
General
")
{
if
(
$line
=~
/Name: (.*)$/
)
{
$slave
->
{'
name
'}
=
$
1
;
}
}
}
}
}
...
@@ -131,6 +145,14 @@ sub query
...
@@ -131,6 +145,14 @@ sub query
$alias_index
++
;
$alias_index
++
;
}
}
# replace empty name with vendor id and product code
for
$slave
(
@slaves
)
{
unless
(
defined
$slave
->
{'
name
'})
{
$slave
->
{'
name
'}
=
sprintf
("
0x%08X:0x%08X
",
$slave
->
{'
vendor
'},
$slave
->
{'
product
'});
}
}
if
(
defined
$opt
{'
c
'})
{
# display power consumtion
if
(
defined
$opt
{'
c
'})
{
# display power consumtion
$fmt
=
sprintf
"
%%%is %%%is %%6i %%6i %%s
\n
",
$fmt
=
sprintf
"
%%%is %%%is %%6i %%6i %%s
\n
",
$ring_col_width
,
$alias_col_width
;
$ring_col_width
,
$alias_col_width
;
...
@@ -182,7 +204,7 @@ sub print_usage
...
@@ -182,7 +204,7 @@ sub print_usage
print
"
-m <IDX> Query master <IDX>.
\n
";
print
"
-m <IDX> Query master <IDX>.
\n
";
print
"
-c Display current [mA]
";
print
"
-c Display current [mA]
";
print
"
(3: consumption, 4: remaining).
\n
";
print
"
(3: consumption, 4: remaining).
\n
";
print
"
-n D
isplay no coupler lin
es.
\n
";
print
"
-n D
o not display lines before aliased slav
es.
\n
";
print
"
-h Show this help.
\n
";
print
"
-h Show this help.
\n
";
exit
0
;
exit
0
;
}
}
...
...
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