mirror of
https://gitlab.com/etherlab.org/ethercat.git
synced 2026-09-28 15:56:14 +08:00
Implemented EoE Set IP parameter request via command-line tool.
This commit is contained in:
committed by
Bjarne von Horn
parent
0e25f6d80f
commit
4d47f0b328
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,55 @@
|
||||
/*****************************************************************************
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2006-2014 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 version 2, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* 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 license mentioned above concerns the source code only. Using the
|
||||
* EtherCAT technology and brand is only permitted in compliance with the
|
||||
* industrial property and similar rights of Beckhoff Automation GmbH.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __COMMANDIP_H__
|
||||
#define __COMMANDIP_H__
|
||||
|
||||
#include "Command.h"
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
class CommandIp:
|
||||
public Command
|
||||
{
|
||||
public:
|
||||
CommandIp();
|
||||
|
||||
string helpString(const string &) const;
|
||||
void execute(const StringVector &);
|
||||
|
||||
protected:
|
||||
void parseMac(unsigned char [6], const string &);
|
||||
void parseIpv4Prefix(ec_ioctl_slave_eoe_ip_t *,
|
||||
const string &);
|
||||
void resolveIpv4(uint32_t *, const string &);
|
||||
};
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
#endif
|
||||
@@ -49,6 +49,7 @@ ethercat_SOURCES = \
|
||||
CommandFoeRead.cpp \
|
||||
CommandFoeWrite.cpp \
|
||||
CommandGraph.cpp \
|
||||
CommandIp.cpp \
|
||||
CommandMaster.cpp \
|
||||
CommandPdos.cpp \
|
||||
CommandRegRead.cpp \
|
||||
@@ -92,6 +93,7 @@ noinst_HEADERS = \
|
||||
CommandFoeRead.h \
|
||||
CommandFoeWrite.h \
|
||||
CommandGraph.h \
|
||||
CommandIp.h \
|
||||
CommandMaster.h \
|
||||
CommandPdos.h \
|
||||
CommandRegRead.h \
|
||||
|
||||
@@ -607,4 +607,19 @@ void MasterDevice::writeSoe(ec_ioctl_slave_soe_write_t *data)
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
void MasterDevice::setIpParam(ec_ioctl_slave_eoe_ip_t *data)
|
||||
{
|
||||
if (ioctl(fd, EC_IOCTL_SLAVE_EOE_IP_PARAM, data) < 0) {
|
||||
if (errno == EIO && data->result) {
|
||||
throw MasterDeviceEoeException(data->result);
|
||||
} else {
|
||||
stringstream err;
|
||||
err << "Failed to set IP parameters: " << strerror(errno);
|
||||
throw MasterDeviceException(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
@@ -94,6 +94,23 @@ class MasterDeviceSoeException:
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
class MasterDeviceEoeException:
|
||||
public MasterDeviceException
|
||||
{
|
||||
friend class MasterDevice;
|
||||
|
||||
public:
|
||||
uint16_t result;
|
||||
|
||||
protected:
|
||||
/** Constructor with error code parameter. */
|
||||
MasterDeviceEoeException(uint16_t result):
|
||||
MasterDeviceException("EoE set IP parameter failed."),
|
||||
result(result) {};
|
||||
};
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
class MasterDevice
|
||||
{
|
||||
public:
|
||||
@@ -146,6 +163,7 @@ class MasterDevice
|
||||
#endif
|
||||
void readSoe(ec_ioctl_slave_soe_read_t *);
|
||||
void writeSoe(ec_ioctl_slave_soe_write_t *);
|
||||
void setIpParam(ec_ioctl_slave_eoe_ip_t *);
|
||||
|
||||
unsigned int getMasterCount() const {return masterCount;}
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ using namespace std;
|
||||
#include "CommandFoeRead.h"
|
||||
#include "CommandFoeWrite.h"
|
||||
#include "CommandGraph.h"
|
||||
#include "CommandIp.h"
|
||||
#include "CommandMaster.h"
|
||||
#include "CommandPdos.h"
|
||||
#include "CommandRegRead.h"
|
||||
@@ -290,6 +291,7 @@ int main(int argc, char **argv)
|
||||
commandList.push_back(new CommandFoeRead());
|
||||
commandList.push_back(new CommandFoeWrite());
|
||||
commandList.push_back(new CommandGraph());
|
||||
commandList.push_back(new CommandIp());
|
||||
commandList.push_back(new CommandMaster());
|
||||
commandList.push_back(new CommandPdos());
|
||||
commandList.push_back(new CommandRegRead());
|
||||
|
||||
Reference in New Issue
Block a user