Removed a few old scripts.
authorFlorian Pose <fp@igh-essen.com>
Fri, 01 Aug 2008 15:01:45 +0000
changeset 1192 693ca2af5bec
parent 1191 c816f8416cfc
child 1193 e6d4134796c4
Removed a few old scripts.
script/Makefile.am
script/lsec
script/slaveinfo2xml.py
--- a/script/Makefile.am	Fri Aug 01 12:57:33 2008 +0000
+++ b/script/Makefile.am	Fri Aug 01 15:01:45 2008 +0000
@@ -37,8 +37,6 @@
 
 SUBDIRS = init.d sysconfig
 
-bin_SCRIPTS = lsec
-
-EXTRA_DIST = lsec ifup-eoe.sh
+EXTRA_DIST = ifup-eoe.sh
 
 #------------------------------------------------------------------------------
--- a/script/lsec	Fri Aug 01 12:57:33 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,236 +0,0 @@
-#!/usr/bin/perl
-
-#------------------------------------------------------------------------------
-#
-#  l s e c  -  List EtherCAT
-#
-#  Userspace tool for listing EtherCAT slaves.
-#
-#  $Id$
-#
-#  Copyright (C) 2006  Florian Pose, Ingenieurgemeinschaft IgH
-#
-#  This file is part of the IgH EtherCAT Master.
-#
-#  The IgH EtherCAT Master is free software; you can redistribute it
-#  and/or modify it under the terms of the GNU General Public License
-#  as published by the Free Software Foundation; either version 2 of the
-#  License, or (at your option) any later version.
-#
-#  The IgH EtherCAT Master is distributed in the hope that it will be
-#  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU General Public License for more details.
-#
-#  You should have received a copy of the GNU General Public License
-#  along with the IgH EtherCAT Master; if not, write to the Free Software
-#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-#
-#  The right to use EtherCAT Technology is granted and comes free of
-#  charge under condition of compatibility of product made by
-#  Licensee. People intending to distribute/sell products based on the
-#  code, have to sign an agreement to guarantee that products using
-#  software based on IgH EtherCAT master stay compatible with the actual
-#  EtherCAT specification (which are released themselves as an open
-#  standard) as the (only) precondition to have the right to use EtherCAT
-#  Technology, IP and trade marks.
-#
-#------------------------------------------------------------------------------
-
-require 'sys/ioctl.ph';
-
-use strict;
-use Getopt::Std;
-
-my %opt;
-my $master_index;
-my $term_width;
-
-#------------------------------------------------------------------------------
-
-$term_width = &get_terminal_width;
-&get_options;
-&query;
-exit 0;
-
-#------------------------------------------------------------------------------
-
-sub query
-{
-    my $master_dir;
-    my $dirhandle;
-    my $entry;
-    my $slave_info_file;
-    my @slaves;
-    my $slave;
-    my $line;
-    my $ring_col_width;
-    my $alias_col_width;
-    my $fmt;
-    my $width;
-    my $last_alias;
-    my $alias_index;
-    my $category;
-
-    $master_dir = "/sys/ethercat/master" . $master_index;
-
-    unless (opendir $dirhandle, $master_dir) {
-        print "Failed to open directory \"$master_dir\".\n";
-        exit 1;
-    }
-
-    while ($entry = readdir $dirhandle) {
-        next unless $entry =~ /^slave(\d+)$/;
-
-        $slave = {};
-        $slave->{'current'} = 0;
-        $slave_info_file = "$master_dir/$entry/info"; 
-        open INFO, $slave_info_file or die
-            "ERROR: Failed to open $slave_info_file.";
-
-        $category = "";
-        while ($line = <INFO>) {
-            # remember category
-            if ($line =~ /^([^\s][^:]*):$/) {
-                $category = $1;
-            } elsif ($line =~ /^\s*$/) {
-                $category = "";
-            }
-
-            if ($category eq "") {
-                if ($line =~ /^Ring position: (\d+)$/) {
-                    $slave->{'ring_position'} = $1;
-                } elsif ($line =~ /^State: (.+) /) {
-                    $slave->{'state'} = $1;
-                } elsif ($line =~ /^Configured station alias: .* \((\d+)\)$/) {
-                    $slave->{'alias'} = $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;
-                } elsif ($line =~ /Current consumption: (-?\d+) mA$/) {
-                    $slave->{'current'} = $1;
-                }
-            }
-        }
-
-        close INFO;
-        push @slaves, $slave;
-    }
-    closedir $dirhandle;
-
-    @slaves = sort { $a->{'ring_position'} <=> $b->{'ring_position'} } @slaves;
-
-    # create field addresses and calculate column widths
-    $ring_col_width = 0;
-    $alias_col_width = 0;
-    $last_alias = "";
-    for $slave (@slaves) {
-        if ($slave->{'alias'}) {
-            $last_alias = $slave->{'alias'};
-            $alias_index = 0;
-        }
-        if ($last_alias) {
-            $slave->{'field_address'} = "#" . $last_alias . ":" . $alias_index;
-            $width = length $slave->{'field_address'};
-            $alias_col_width = $width if ($width > $alias_col_width);
-        }
-        $width = length $slave->{'ring_position'};
-        $ring_col_width = $width if ($width > $ring_col_width);
-        $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
-        $fmt = sprintf " %%%is  %%%is  %%6i  %%6i  %%s\n",
-            $ring_col_width, $alias_col_width;
-
-        my $current_sum = 0;
-        for $slave (@slaves) {
-            &print_line if $slave->{'alias'} and !defined $opt{n};
-            $current_sum = 0 if $slave->{'current'} < 0;
-            $current_sum -= $slave->{'current'};
-            printf($fmt, $slave->{'ring_position'}, $slave->{'field_address'},
-                    $slave->{'current'}, $current_sum, $slave->{'name'});
-        }
-    }
-    else { # normal display
-        $fmt = sprintf " %%%is  %%%is  %%-6s  %%s\n",
-            $ring_col_width, $alias_col_width;
-
-        for $slave (@slaves) {
-            &print_line if $slave->{'alias'} and !defined $opt{n};
-            printf($fmt, $slave->{'ring_position'}, $slave->{'field_address'},
-                    $slave->{'state'}, $slave->{'name'});
-        }
-    }
-}
-
-#------------------------------------------------------------------------------
-
-sub get_options
-{
-    my $optret = getopts "m:cnh", \%opt;
-
-    &print_usage if defined $opt{h} or $#ARGV > -1 or !$optret;
-
-    if (defined $opt{m}) {
-        $master_index = $opt{m};
-    }
-    else {
-        $master_index = 0;
-    }
-}
-
-#------------------------------------------------------------------------------
-
-sub print_usage
-{
-    my $cmd = `basename $0`;
-    chomp $cmd;
-    print "Usage: $cmd [OPTIONS]\n";
-    print "        -m <IDX>    Query master <IDX>.\n";
-    print "        -c          Display current [mA] ";
-    print "(3: consumption, 4: remaining).\n";
-    print "        -n          Do not display lines before aliased slaves.\n";
-    print "        -h          Show this help.\n";
-    exit 0;
-}
-
-#------------------------------------------------------------------------------
-
-sub get_terminal_width
-{
-    my $winsize;
-    die "no TIOCGWINSZ " unless defined &TIOCGWINSZ;
-    open(TTY, "+</dev/tty") or die "No tty: $!";
-    unless (ioctl(TTY, &TIOCGWINSZ, $winsize='')) {
-        die sprintf "$0: ioctl TIOCGWINSZ (%08x: $!)\n", &TIOCGWINSZ;
-    }
-    (my $row, my $col, my $xpixel, my $ypixel) = unpack('S4', $winsize);
-    return $col;
-}
-#------------------------------------------------------------------------------
-
-sub print_line
-{
-    for (my $i = 0; $i < $term_width; $i++) {
-        print "-";
-    }
-    print "\n";
-}
-
-#------------------------------------------------------------------------------
--- a/script/slaveinfo2xml.py	Fri Aug 01 12:57:33 2008 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,222 +0,0 @@
-#!/usr/bin/python
-
-#-----------------------------------------------------------------------------
-#
-# $Id$
-#
-# Convert a slave information file to a slave description Xml.
-#
-#-----------------------------------------------------------------------------
-
-from xml.dom.minidom import Document
-import sys
-import re
-import os
-import getopt
-
-#-----------------------------------------------------------------------------
-
-infoFileName = 'info'
-
-#-----------------------------------------------------------------------------
-
-class PdoEntry:
-    def __init__(self, index, subindex, name, bitlength):
-        self.index = index
-        self.subindex = subindex
-        self.name = name
-        self.bitlength = bitlength
-
-    def toXml(self, doc, element):
-        entryElement = doc.createElement('Entry')
-
-        indexElement = doc.createElement('Index')
-        indexText = doc.createTextNode('#x%04x' % self.index)
-        indexElement.appendChild(indexText)
-        entryElement.appendChild(indexElement)
-
-        if (self.index != 0):
-            subIndexElement = doc.createElement('SubIndex')
-            subIndexText = doc.createTextNode(str(self.subindex))
-            subIndexElement.appendChild(subIndexText)
-            entryElement.appendChild(subIndexElement)
-
-        lengthElement = doc.createElement('BitLen')
-        lengthText = doc.createTextNode(str(self.bitlength))
-        lengthElement.appendChild(lengthText)
-        entryElement.appendChild(lengthElement)
-
-        if (self.index != 0):
-            nameElement = doc.createElement('Name')
-            nameText = doc.createTextNode(self.name)
-            nameElement.appendChild(nameText)
-            entryElement.appendChild(nameElement)
-
-            dataTypeElement = doc.createElement('DataType')
-            dataTypeText = doc.createTextNode(self.dataType())
-            dataTypeElement.appendChild(dataTypeText)
-            entryElement.appendChild(dataTypeElement)
-
-        element.appendChild(entryElement)
-
-    def dataType(self):
-        if self.bitlength == 1:
-            return 'BOOL'
-        elif self.bitlength % 8 == 0:
-            if self.bitlength <= 64:
-                return 'UINT%u' % self.bitlength
-            else:
-                return 'STRING(%u)' % (self.bitlength / 8)
-        else:
-            assert False, 'Invalid bit length %u' % self.bitlength 
-
-#-----------------------------------------------------------------------------
-
-class Pdo:
-    def __init__(self, dir, index):
-        self.dir = dir
-        self.index = index
-        self.entries = []
-
-    def appendEntry(self, entry):
-        self.entries.append(entry)
-
-    def toXml(self, doc, element):
-        pdoElement = doc.createElement('%sxPdo' % self.dir)
-
-        indexElement = doc.createElement('Index')
-        indexText = doc.createTextNode('#x%04x' % self.index)
-        indexElement.appendChild(indexText)
-        pdoElement.appendChild(indexElement)
-
-        nameElement = doc.createElement('Name')
-        pdoElement.appendChild(nameElement)
-
-        for e in self.entries:
-            e.toXml(doc, pdoElement)
-
-        element.appendChild(pdoElement)
-
-#-----------------------------------------------------------------------------
-
-class Device:
-    def __init__(self):
-        self.vendor = 0
-        self.product = 0
-        self.revision = 0
-        self.pdos = []
-
-    def parseInfoFile(self, fileName):
-        reVendor = re.compile('Vendor ID:.*\((\d+)\)')
-        reProduct = re.compile('Product code:.*\((\d+)\)')
-        reRevision = re.compile('Revision number:.*\((\d+)\)')
-        rePdo = re.compile('([RT])xPdo\s+0x([0-9A-F]+)')
-        rePdoEntry = \
-            re.compile('0x([0-9A-F]+):([0-9A-F]+),\s+(\d+) bit,\s+"([^"]*)"')
-        pdo = None
-        f = open(fileName, 'r')
-        while True:
-            line = f.readline()
-            if not line: break
-
-            match = reVendor.search(line)
-            if match:
-                self.vendor = int(match.group(1))
-
-            match = reProduct.search(line)
-            if match:
-                self.product = int(match.group(1))
-
-            match = reRevision.search(line)
-            if match:
-                self.revision = int(match.group(1))
-
-            match = rePdo.search(line)
-            if match:
-                pdo = Pdo(match.group(1), int(match.group(2), 16))
-                self.pdos.append(pdo)
-
-            match = rePdoEntry.search(line)
-            if match:
-                pdoEntry = PdoEntry(int(match.group(1), 16), \
-                    int(match.group(2), 16), match.group(4), \
-                    int(match.group(3)))
-                pdo.appendEntry(pdoEntry)
-
-        f.close()
-
-    def toXmlDocument(self):
-        doc = Document()
-
-        rootElement = doc.createElement('EtherCATInfo')
-        doc.appendChild(rootElement)
-
-        vendorElement = doc.createElement('Vendor')
-        rootElement.appendChild(vendorElement)
-
-        vendorIdElement = doc.createElement('Id')
-
-        idText = doc.createTextNode(str(self.vendor))
-        vendorIdElement.appendChild(idText)
-
-        vendorElement.appendChild(vendorIdElement)
-
-        descriptionsElement = doc.createElement('Descriptions')
-        rootElement.appendChild(descriptionsElement)
-
-        devicesElement = doc.createElement('Devices')
-        descriptionsElement.appendChild(devicesElement)
-
-        deviceElement = doc.createElement('Device')
-        devicesElement.appendChild(deviceElement)
-
-        typeElement = doc.createElement('Type')
-        typeElement.setAttribute('ProductCode', '#x%08x' % self.product)
-        typeElement.setAttribute('RevisionNo', '#x%08x' % self.revision)
-        deviceElement.appendChild(typeElement)
-
-        for p in self.pdos:
-            p.toXml(doc, deviceElement)
-
-        return doc
-
-#-----------------------------------------------------------------------------
-
-def usage():
-    print """slaveinfo2xml.py [OPTIONS] [FILE]
-    File defaults to 'info'.
-    Options:
-        -h Print this help."""
-
-#-----------------------------------------------------------------------------
-
-try:
-    opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])
-except getopt.GetoptError, err:
-    print str(err)
-    usage()
-    sys.exit(2)
-
-if len(args) > 1:
-    print "Only one argument allowed!"
-    usage()
-    sys.exit(2)
-elif len(args) == 1:
-    infoFileName = args[0]
-
-for o, a in opts:
-    if o in ("-h", "--help"):
-        usage()
-        sys.exit()
-    else:
-        assert False, "unhandled option"
-
-d = Device()
-d.parseInfoFile(infoFileName)
-doc = d.toXmlDocument()
-
-# Print our newly created XML
-print doc.toprettyxml(indent='  ')
-
-#-----------------------------------------------------------------------------
-