fp@1122: /***************************************************************************** fp@1122: * fp@1363: * $Id$ fp@1363: * fp@1363: * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH fp@1363: * fp@1363: * This file is part of the IgH EtherCAT Master. fp@1363: * fp@1363: * The IgH EtherCAT Master is free software; you can redistribute it and/or fp@1363: * modify it under the terms of the GNU General Public License version 2, as fp@1363: * published by the Free Software Foundation. fp@1363: * fp@1363: * The IgH EtherCAT Master is distributed in the hope that it will be useful, fp@1363: * but WITHOUT ANY WARRANTY; without even the implied warranty of fp@1363: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General fp@1363: * Public License for more details. fp@1363: * fp@1363: * You should have received a copy of the GNU General Public License along fp@1363: * with the IgH EtherCAT Master; if not, write to the Free Software fp@1363: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA fp@1363: * fp@1363: * --- fp@1363: * fp@1363: * The license mentioned above concerns the source code only. Using the fp@1363: * EtherCAT technology and brand is only permitted in compliance with the fp@1363: * industrial property and similar rights of Beckhoff Automation GmbH. fp@1122: * fp@1122: ****************************************************************************/ fp@1122: fp@1141: #ifndef __MASTER_DEVICE_H__ fp@1141: #define __MASTER_DEVICE_H__ fp@1122: fp@1122: #include fp@1136: #include fp@1122: using namespace std; fp@1122: fp@1835: #include "ecrt.h" fp@1835: #include "ioctl.h" fp@1122: fp@1122: /****************************************************************************/ fp@1122: fp@1122: class MasterDeviceException: fp@1122: public runtime_error fp@1122: { fp@1136: friend class MasterDevice; fp@1136: fp@1136: protected: fp@1184: /** Constructor with string parameter. */ fp@1184: MasterDeviceException( fp@1184: const string &s /**< Message. */ fp@1184: ): runtime_error(s) {} fp@1184: fp@1141: /** Constructor with stringstream parameter. */ fp@1122: MasterDeviceException( fp@1136: const stringstream &s /**< Message. */ fp@1136: ): runtime_error(s.str()) {} fp@1122: }; fp@1122: fp@1122: /****************************************************************************/ fp@1122: fp@1184: class MasterDeviceSdoAbortException: fp@1184: public MasterDeviceException fp@1184: { fp@1184: friend class MasterDevice; fp@1184: fp@1184: public: fp@1184: uint32_t abortCode; fp@1184: fp@1184: protected: fp@1831: /** Constructor with abort code parameter. */ fp@1184: MasterDeviceSdoAbortException(uint32_t code): fp@1327: MasterDeviceException("SDO transfer aborted.") { fp@1184: abortCode = code; fp@1184: }; fp@1184: }; fp@1184: fp@1184: /****************************************************************************/ fp@1184: fp@1831: class MasterDeviceSoeException: fp@1831: public MasterDeviceException fp@1831: { fp@1831: friend class MasterDevice; fp@1831: fp@1831: public: fp@1831: uint16_t errorCode; fp@1831: fp@1831: protected: fp@1831: /** Constructor with error code parameter. */ fp@1831: MasterDeviceSoeException(uint16_t code): fp@1831: MasterDeviceException("SoE transfer aborted.") { fp@1831: errorCode = code; fp@1831: }; fp@1831: }; fp@1831: fp@1831: /****************************************************************************/ fp@1831: fp@1122: class MasterDevice fp@1122: { fp@1122: public: fp@1826: MasterDevice(unsigned int = 0U); fp@1122: ~MasterDevice(); fp@1122: fp@1122: void setIndex(unsigned int); fp@1804: unsigned int getIndex() const; fp@1122: fp@1122: enum Permissions {Read, ReadWrite}; fp@1122: void open(Permissions); fp@1122: void close(); fp@1122: fp@1826: void getModule(ec_ioctl_module_t *); fp@1826: fp@1122: void getMaster(ec_ioctl_master_t *); fp@1122: void getConfig(ec_ioctl_config_t *, unsigned int); fp@1122: void getConfigPdo(ec_ioctl_config_pdo_t *, unsigned int, uint8_t, fp@1122: uint16_t); fp@1122: void getConfigPdoEntry(ec_ioctl_config_pdo_entry_t *, unsigned int, fp@1122: uint8_t, uint16_t, uint8_t); fp@1122: void getConfigSdo(ec_ioctl_config_sdo_t *, unsigned int, unsigned int); fp@1966: void getConfigIdn(ec_ioctl_config_idn_t *, unsigned int, unsigned int); fp@1122: void getDomain(ec_ioctl_domain_t *, unsigned int); fp@1122: void getFmmu(ec_ioctl_domain_fmmu_t *, unsigned int, unsigned int); fp@1122: void getData(ec_ioctl_domain_data_t *, unsigned int, unsigned int, fp@1122: unsigned char *); fp@1122: void getSlave(ec_ioctl_slave_t *, uint16_t); fp@1122: void getSync(ec_ioctl_slave_sync_t *, uint16_t, uint8_t); fp@1122: void getPdo(ec_ioctl_slave_sync_pdo_t *, uint16_t, uint8_t, uint8_t); fp@1122: void getPdoEntry(ec_ioctl_slave_sync_pdo_entry_t *, uint16_t, uint8_t, fp@1122: uint8_t, uint8_t); fp@1122: void getSdo(ec_ioctl_slave_sdo_t *, uint16_t, uint16_t); fp@1122: void getSdoEntry(ec_ioctl_slave_sdo_entry_t *, uint16_t, int, uint8_t); fp@1122: void readSii(ec_ioctl_slave_sii_t *); fp@1122: void writeSii(ec_ioctl_slave_sii_t *); fp@1388: void readReg(ec_ioctl_slave_reg_t *); fp@1388: void writeReg(ec_ioctl_slave_reg_t *); fp@1804: void setDebug(unsigned int); fp@1961: void rescan(); fp@1804: void sdoDownload(ec_ioctl_slave_sdo_download_t *); fp@1804: void sdoUpload(ec_ioctl_slave_sdo_upload_t *); fp@1804: void requestState(uint16_t, uint8_t); fp@1804: void readFoe(ec_ioctl_slave_foe_t *); fp@1335: void writeFoe(ec_ioctl_slave_foe_t *); fp@1516: #ifdef EC_EOE fp@1485: void getEoeHandler(ec_ioctl_eoe_handler_t *, uint16_t); fp@1516: #endif fp@1837: void readSoe(ec_ioctl_slave_soe_read_t *); fp@1837: void writeSoe(ec_ioctl_slave_soe_write_t *); fp@1122: fp@1826: unsigned int getMasterCount() const {return masterCount;} fp@1826: fp@1122: private: fp@1122: unsigned int index; fp@1826: unsigned int masterCount; fp@1122: int fd; fp@1122: }; fp@1122: fp@1122: /****************************************************************************/ fp@1122: fp@1166: inline unsigned int MasterDevice::getIndex() const fp@1166: { fp@1804: return index; fp@1166: } fp@1166: fp@1166: /****************************************************************************/ fp@1166: fp@1122: #endif