script/lsec
changeset 835 23fd8b510803
parent 766 97e98cbd0cd2
equal deleted inserted replaced
834:0791aac03180 835:23fd8b510803
    81 
    81 
    82     while ($entry = readdir $dirhandle) {
    82     while ($entry = readdir $dirhandle) {
    83         next unless $entry =~ /^slave(\d+)$/;
    83         next unless $entry =~ /^slave(\d+)$/;
    84 
    84 
    85         $slave = {};
    85         $slave = {};
       
    86         $slave->{'current'} = 0;
    86         $slave_info_file = "$master_dir/$entry/info"; 
    87         $slave_info_file = "$master_dir/$entry/info"; 
    87         open INFO, $slave_info_file or die
    88         open INFO, $slave_info_file or die
    88             "ERROR: Failed to open $slave_info_file.";
    89             "ERROR: Failed to open $slave_info_file.";
    89 
    90 
    90         $category = "";
    91         $category = "";
   101                     $slave->{'ring_position'} = $1;
   102                     $slave->{'ring_position'} = $1;
   102                 } elsif ($line =~ /^State: (.+) /) {
   103                 } elsif ($line =~ /^State: (.+) /) {
   103                     $slave->{'state'} = $1;
   104                     $slave->{'state'} = $1;
   104                 } elsif ($line =~ /^Configured station alias: .* \((\d+)\)$/) {
   105                 } elsif ($line =~ /^Configured station alias: .* \((\d+)\)$/) {
   105                     $slave->{'alias'} = $1;
   106                     $slave->{'alias'} = $1;
   106                 } elsif ($line =~ /^Current consumption: (-?\d+) mA$/) {
       
   107                     $slave->{'current'} = $1;
       
   108                 }
   107                 }
   109             } elsif ($category eq "Identity") {
   108             } elsif ($category eq "Identity") {
   110                 if ($line =~ /Vendor ID: .* \((\d+)\)$/) {
   109                 if ($line =~ /Vendor ID: .* \((\d+)\)$/) {
   111                     $slave->{'vendor'} = $1;
   110                     $slave->{'vendor'} = $1;
   112                 } elsif ($line =~ /Product code: .* \((\d+)\)$/) {
   111                 } elsif ($line =~ /Product code: .* \((\d+)\)$/) {
   113                     $slave->{'product'} = $1;
   112                     $slave->{'product'} = $1;
   114                 }
   113                 }
   115             } elsif ($category eq "General") {
   114             } elsif ($category eq "General") {
   116                 if ($line =~ /Name: (.*)$/) {
   115                 if ($line =~ /Name: (.*)$/) {
   117                     $slave->{'name'} = $1;
   116                     $slave->{'name'} = $1;
       
   117                 } elsif ($line =~ /Current consumption: (-?\d+) mA$/) {
       
   118                     $slave->{'current'} = $1;
   118                 }
   119                 }
   119             }
   120             }
   120         }
   121         }
   121 
   122 
   122         close INFO;
   123         close INFO;