Coupler information in slave info file, lines in lsec.
This commit is contained in:
parent
024460b94b
commit
46b98fdbb1
|
|
@ -530,8 +530,10 @@ size_t ec_slave_info(const ec_slave_t *slave, /**< EtherCAT slave */
|
|||
off += ec_state_string(slave->current_state, buffer + off);
|
||||
off += sprintf(buffer + off, "\nRing position: %i\n",
|
||||
slave->ring_position);
|
||||
off += sprintf(buffer + off, "Advanced position: %i:%i\n\n",
|
||||
off += sprintf(buffer + off, "Advanced position: %i:%i\n",
|
||||
slave->coupler_index, slave->coupler_subindex);
|
||||
off += sprintf(buffer + off, "Coupler: %s\n\n",
|
||||
ec_slave_is_coupler(slave) ? "yes" : "no");
|
||||
|
||||
off += sprintf(buffer + off, "Data link status:\n");
|
||||
for (i = 0; i < 4; i++) {
|
||||
|
|
|
|||
|
|
@ -37,20 +37,45 @@
|
|||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
require 'sys/ioctl.ph';
|
||||
|
||||
use strict;
|
||||
use Getopt::Std;
|
||||
|
||||
my $master_index;
|
||||
my $master_dir;
|
||||
my $term_width;
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
$term_width = &get_terminal_width;
|
||||
&get_options;
|
||||
&query_master;
|
||||
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";
|
||||
}
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
sub query_master
|
||||
{
|
||||
$master_dir = "/sys/ethercat" . $master_index;
|
||||
|
|
@ -94,6 +119,9 @@ sub query_slaves
|
|||
elsif ($line =~ /^State: (.+)$/) {
|
||||
$slave->{'state'} = $1;
|
||||
}
|
||||
elsif ($line =~ /^Coupler: ([a-z]+)$/) {
|
||||
$slave->{'coupler'} = $1;
|
||||
}
|
||||
}
|
||||
|
||||
close INFO;
|
||||
|
|
@ -106,10 +134,11 @@ sub query_slaves
|
|||
|
||||
print "EtherCAT bus listing for master $master_index:\n";
|
||||
for $slave (@slaves) {
|
||||
$abs = sprintf "%i", $slave->{'ring_position'};
|
||||
printf(" %3s %8s %-6s %s\n",
|
||||
$abs, $slave->{'advanced_position'},
|
||||
$slave->{'state'}, $slave->{'name'});
|
||||
print_line if $slave->{'coupler'} eq "yes";
|
||||
$abs = sprintf "%i", $slave->{'ring_position'};
|
||||
printf(" %3s %8s %-6s %s\n",
|
||||
$abs, $slave->{'advanced_position'},
|
||||
$slave->{'state'}, $slave->{'name'});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue