author | Florian Pose <fp@igh-essen.com> |
Wed, 30 Apr 2008 09:55:58 +0000 | |
branch | stable-1.3 |
changeset 1755 | 18141b8631be |
parent 1751 | b6cfd85db58e |
child 1760 | 036f19bde00b |
permissions | -rwxr-xr-x |
1740
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/perl |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
|
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3 |
#------------------------------------------------------------------------------ |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
4 |
# |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
5 |
# l s e c - List EtherCAT |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
6 |
# |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
7 |
# Userspace tool for listing EtherCAT slaves. |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
8 |
# |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
9 |
# $Id$ |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
10 |
# |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
11 |
# Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
12 |
# |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
13 |
# This file is part of the IgH EtherCAT Master. |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
14 |
# |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
15 |
# The IgH EtherCAT Master is free software; you can redistribute it |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
16 |
# and/or modify it under the terms of the GNU General Public License |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
17 |
# as published by the Free Software Foundation; either version 2 of the |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
18 |
# License, or (at your option) any later version. |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
19 |
# |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
20 |
# The IgH EtherCAT Master is distributed in the hope that it will be |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
21 |
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
22 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
23 |
# GNU General Public License for more details. |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
24 |
# |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
25 |
# You should have received a copy of the GNU General Public License |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
26 |
# along with the IgH EtherCAT Master; if not, write to the Free Software |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
27 |
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
28 |
# |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
29 |
# The right to use EtherCAT Technology is granted and comes free of |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
30 |
# charge under condition of compatibility of product made by |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
31 |
# Licensee. People intending to distribute/sell products based on the |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
32 |
# code, have to sign an agreement to guarantee that products using |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
# software based on IgH EtherCAT master stay compatible with the actual |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
34 |
# EtherCAT specification (which are released themselves as an open |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
35 |
# standard) as the (only) precondition to have the right to use EtherCAT |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
36 |
# Technology, IP and trade marks. |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
37 |
# |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
38 |
#------------------------------------------------------------------------------ |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
39 |
|
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
40 |
require 'sys/ioctl.ph'; |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
41 |
|
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
42 |
use strict; |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
use Getopt::Std; |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
44 |
|
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
45 |
my %opt; |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
46 |
my $master_index; |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
47 |
my $term_width; |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
48 |
|
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
49 |
#------------------------------------------------------------------------------ |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
50 |
|
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
51 |
$term_width = &get_terminal_width; |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
52 |
&get_options; |
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
53 |
&query; |
1740
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
54 |
exit 0; |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
55 |
|
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
56 |
#------------------------------------------------------------------------------ |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
57 |
|
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
58 |
sub query |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
59 |
{ |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
60 |
my $master_dir; |
1740
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
61 |
my $dirhandle; |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
62 |
my $entry; |
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
63 |
my $slave_info_file; |
1740
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
64 |
my @slaves; |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
65 |
my $slave; |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
66 |
my $line; |
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
67 |
my $ring_col_width; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
68 |
my $alias_col_width; |
1740
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
69 |
my $fmt; |
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
70 |
my $width; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
71 |
my $last_alias; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
72 |
my $alias_index; |
1751
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
73 |
my $category; |
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
74 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
75 |
$master_dir = "/sys/ethercat/master" . $master_index; |
1740
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
76 |
|
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
77 |
unless (opendir $dirhandle, $master_dir) { |
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
78 |
print "Failed to open directory \"$master_dir\".\n"; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
79 |
exit 1; |
1740
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
80 |
} |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
81 |
|
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
82 |
while ($entry = readdir $dirhandle) { |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
83 |
next unless $entry =~ /^slave(\d+)$/; |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
84 |
|
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
85 |
$slave = {}; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
86 |
$slave_info_file = "$master_dir/$entry/info"; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
87 |
open INFO, $slave_info_file or die |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
88 |
"ERROR: Failed to open $slave_info_file."; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
89 |
|
1751
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
90 |
$category = ""; |
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
91 |
while ($line = <INFO>) { |
1751
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
92 |
# remember category |
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
93 |
if ($line =~ /^([^\s][^:]*):$/) { |
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
94 |
$category = $1; |
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
95 |
} elsif ($line =~ /^\s*$/) { |
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
96 |
$category = ""; |
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
97 |
} |
1751
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
98 |
|
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
99 |
if ($category eq "") { |
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
100 |
if ($line =~ /^Ring position: (\d+)$/) { |
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
101 |
$slave->{'ring_position'} = $1; |
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
102 |
} elsif ($line =~ /^State: (.+) /) { |
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
103 |
$slave->{'state'} = $1; |
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
104 |
} elsif ($line =~ /^Configured station alias: .* \((\d+)\)$/) { |
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
105 |
$slave->{'alias'} = $1; |
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
106 |
} elsif ($line =~ /^Current consumption: (-?\d+) mA$/) { |
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
107 |
$slave->{'current'} = $1; |
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
108 |
} |
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
109 |
} elsif ($category eq "Identity") { |
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
110 |
if ($line =~ /Vendor ID: .* \((\d+)\)$/) { |
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
111 |
$slave->{'vendor'} = $1; |
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
112 |
} elsif ($line =~ /Product code: .* \((\d+)\)$/) { |
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
113 |
$slave->{'product'} = $1; |
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
114 |
} |
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
115 |
} elsif ($category eq "General") { |
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
116 |
if ($line =~ /Name: (.*)$/) { |
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
117 |
$slave->{'name'} = $1; |
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
118 |
} |
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
119 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
120 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
121 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
122 |
close INFO; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
123 |
push @slaves, $slave; |
1740
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
124 |
} |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
125 |
closedir $dirhandle; |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
126 |
|
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
127 |
@slaves = sort { $a->{'ring_position'} <=> $b->{'ring_position'} } @slaves; |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
128 |
|
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
129 |
# create field addresses and calculate column widths |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
130 |
$ring_col_width = 0; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
131 |
$alias_col_width = 0; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
132 |
$last_alias = ""; |
1740
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
133 |
for $slave (@slaves) { |
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
134 |
if ($slave->{'alias'}) { |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
135 |
$last_alias = $slave->{'alias'}; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
136 |
$alias_index = 0; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
137 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
138 |
if ($last_alias) { |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
139 |
$slave->{'field_address'} = "#" . $last_alias . ":" . $alias_index; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
140 |
$width = length $slave->{'field_address'}; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
141 |
$alias_col_width = $width if ($width > $alias_col_width); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
142 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
143 |
$width = length $slave->{'ring_position'}; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
144 |
$ring_col_width = $width if ($width > $ring_col_width); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
145 |
$alias_index++; |
1740
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
146 |
} |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
147 |
|
1751
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
148 |
# replace empty name with vendor id and product code |
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
149 |
for $slave (@slaves) { |
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
150 |
unless (defined $slave->{'name'}) { |
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
151 |
$slave->{'name'} = sprintf("0x%08X:0x%08X", $slave->{'vendor'}, |
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
152 |
$slave->{'product'}); |
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
153 |
} |
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
154 |
} |
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
155 |
|
1740
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
156 |
if (defined $opt{'c'}) { # display power consumtion |
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
157 |
$fmt = sprintf " %%%is %%%is %%6i %%6i %%s\n", |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
158 |
$ring_col_width, $alias_col_width; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
159 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
160 |
my $current_sum = 0; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
161 |
for $slave (@slaves) { |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
162 |
&print_line if $slave->{'alias'} and !defined $opt{n}; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
163 |
$current_sum = 0 if $slave->{'current'} < 0; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
164 |
$current_sum -= $slave->{'current'}; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
165 |
printf($fmt, $slave->{'ring_position'}, $slave->{'field_address'}, |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
166 |
$slave->{'current'}, $current_sum, $slave->{'name'}); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
167 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
168 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
169 |
else { # normal display |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
170 |
$fmt = sprintf " %%%is %%%is %%-6s %%s\n", |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
171 |
$ring_col_width, $alias_col_width; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
172 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
173 |
for $slave (@slaves) { |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
174 |
&print_line if $slave->{'alias'} and !defined $opt{n}; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
175 |
printf($fmt, $slave->{'ring_position'}, $slave->{'field_address'}, |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
176 |
$slave->{'state'}, $slave->{'name'}); |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
177 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
178 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
179 |
} |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
180 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
181 |
#------------------------------------------------------------------------------ |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
182 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
183 |
sub get_options |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
184 |
{ |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
185 |
my $optret = getopts "m:cnh", \%opt; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
186 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
187 |
&print_usage if defined $opt{h} or $#ARGV > -1 or !$optret; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
188 |
|
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
189 |
if (defined $opt{m}) { |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
190 |
$master_index = $opt{m}; |
1740
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
191 |
} |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
192 |
else { |
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
193 |
$master_index = 0; |
1740
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
194 |
} |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
195 |
} |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
196 |
|
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
197 |
#------------------------------------------------------------------------------ |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
198 |
|
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
199 |
sub print_usage |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
200 |
{ |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
201 |
my $cmd = `basename $0`; |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
202 |
chomp $cmd; |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
203 |
print "Usage: $cmd [OPTIONS]\n"; |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
204 |
print " -m <IDX> Query master <IDX>.\n"; |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
205 |
print " -c Display current [mA] "; |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
206 |
print "(3: consumption, 4: remaining).\n"; |
1751
b6cfd85db58e
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
Florian Pose <fp@igh-essen.com>
parents:
1744
diff
changeset
|
207 |
print " -n Do not display lines before aliased slaves.\n"; |
1740
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
208 |
print " -h Show this help.\n"; |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
209 |
exit 0; |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
210 |
} |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
211 |
|
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
212 |
#------------------------------------------------------------------------------ |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
213 |
|
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
214 |
sub get_terminal_width |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
215 |
{ |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
216 |
my $winsize; |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
217 |
die "no TIOCGWINSZ " unless defined &TIOCGWINSZ; |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
218 |
open(TTY, "+</dev/tty") or die "No tty: $!"; |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
219 |
unless (ioctl(TTY, &TIOCGWINSZ, $winsize='')) { |
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
220 |
die sprintf "$0: ioctl TIOCGWINSZ (%08x: $!)\n", &TIOCGWINSZ; |
1740
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
221 |
} |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
222 |
(my $row, my $col, my $xpixel, my $ypixel) = unpack('S4', $winsize); |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
223 |
return $col; |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
224 |
} |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
225 |
#------------------------------------------------------------------------------ |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
226 |
|
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
227 |
sub print_line |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
228 |
{ |
1744
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
229 |
for (my $i = 0; $i < $term_width; $i++) { |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
230 |
print "-"; |
7bc131b92039
MERGE trunk -r770:907 -> branches-1.3 (1.3 changes)
Florian Pose <fp@igh-essen.com>
parents:
1740
diff
changeset
|
231 |
} |
1740
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
232 |
print "\n"; |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
233 |
} |
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
234 |
|
fa0af75bfbe9
MERGE -r759:762 trunk -> branches/stable-1.2 (release 1.2, part two).
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
235 |
#------------------------------------------------------------------------------ |