fp@1485: /***************************************************************************** fp@1485: * fp@1524: * $Id$ fp@1485: * fp@1485: * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH fp@1485: * fp@1485: * This file is part of the IgH EtherCAT Master. fp@1485: * fp@1485: * The IgH EtherCAT Master is free software; you can redistribute it and/or fp@1485: * modify it under the terms of the GNU General Public License version 2, as fp@1485: * published by the Free Software Foundation. fp@1485: * fp@1485: * The IgH EtherCAT Master is distributed in the hope that it will be useful, fp@1485: * but WITHOUT ANY WARRANTY; without even the implied warranty of fp@1485: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General fp@1485: * Public License for more details. fp@1485: * fp@1485: * You should have received a copy of the GNU General Public License along fp@1485: * with the IgH EtherCAT Master; if not, write to the Free Software fp@1485: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA fp@1485: * fp@1485: * --- fp@1485: * fp@1485: * The license mentioned above concerns the source code only. Using the fp@1485: * EtherCAT technology and brand is only permitted in compliance with the fp@1485: * industrial property and similar rights of Beckhoff Automation GmbH. fp@1485: * fp@1485: ****************************************************************************/ fp@1485: fp@1485: #include fp@1485: #include fp@1485: #include fp@1485: #include fp@1485: using namespace std; fp@1485: fp@1485: #include "CommandEoe.h" fp@1485: fp@1485: /*****************************************************************************/ fp@1485: fp@1485: CommandEoe::CommandEoe(): fp@1485: Command("eoe", "Display Ethernet over EtherCAT statictics.") fp@1485: { fp@1485: } fp@1485: fp@1485: /*****************************************************************************/ fp@1485: fp@1485: string CommandEoe::helpString() const fp@1485: { fp@1485: stringstream str; fp@1485: fp@1485: str << getName() << endl fp@1485: << endl fp@1485: << getBriefDescription() << endl fp@1485: << endl fp@1485: << "The TxRate and RxRate are displayed in Byte/s." << endl fp@1485: << endl; fp@1485: fp@1485: return str.str(); fp@1485: } fp@1485: fp@1485: /****************************************************************************/ fp@1485: fp@1485: void CommandEoe::execute(MasterDevice &m, const StringVector &args) fp@1485: { fp@1485: ec_ioctl_master_t master; fp@1485: unsigned int i; fp@1485: ec_ioctl_eoe_handler_t eoe; fp@1485: fp@1485: if (args.size()) { fp@1485: stringstream err; fp@1485: err << "'" << getName() << "' takes no arguments!"; fp@1485: throwInvalidUsageException(err); fp@1485: } fp@1485: fp@1485: m.open(MasterDevice::Read); fp@1485: m.getMaster(&master); fp@1485: fp@1485: cout << "Interface Slave State " fp@1485: << "RxBytes RxRate " fp@1485: << "TxBytes TxRate TxQueue" fp@1485: << endl; fp@1485: fp@1485: for (i = 0; i < master.eoe_handler_count; i++) { fp@1485: stringstream queue; fp@1485: fp@1485: m.getEoeHandler(&eoe, i); fp@1485: fp@1485: queue << eoe.tx_queued_frames << "/" << eoe.tx_queue_size; fp@1485: fp@1485: cout fp@1485: << setw(9) << eoe.name << " " fp@1485: << setw(5) << dec << eoe.slave_position << " " fp@1485: << setw(5) << (eoe.open ? "up" : "down") << " " fp@1485: << setw(7) << eoe.rx_bytes << " " fp@1485: << setw(6) << eoe.rx_rate << " " fp@1485: << setw(7) << eoe.tx_bytes << " " fp@1485: << setw(6) << eoe.tx_rate << " " fp@1485: << setw(7) << queue.str() fp@1485: << endl; fp@1485: } fp@1485: } fp@1485: fp@1485: /*****************************************************************************/