tool/MasterDevice.h
author Florian Pose <fp@igh-essen.com>
Fri, 17 Oct 2008 13:36:43 +0000
changeset 1279 6911450535b7
parent 1200 ce1a65f06efc
child 1327 4d179b06dd3c
permissions -rw-r--r--
merge -c1522 branches/stable-1.4: Fixed jace in jiffies timeout calculation.
1122
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/*****************************************************************************
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
 * $Id$
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
 ****************************************************************************/
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
1141
7ffbca63fc72 Minor fixes.
Florian Pose <fp@igh-essen.com>
parents: 1136
diff changeset
     7
#ifndef __MASTER_DEVICE_H__
7ffbca63fc72 Minor fixes.
Florian Pose <fp@igh-essen.com>
parents: 1136
diff changeset
     8
#define __MASTER_DEVICE_H__
1122
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
#include <stdexcept>
1136
a0982873d655 Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents: 1126
diff changeset
    11
#include <sstream>
1122
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
using namespace std;
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
#include "../include/ecrt.h"
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
#include "../master/ioctl.h"
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
/****************************************************************************/
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
class MasterDeviceException:
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
    public runtime_error
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
{
1136
a0982873d655 Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents: 1126
diff changeset
    22
    friend class MasterDevice;
a0982873d655 Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents: 1126
diff changeset
    23
    
a0982873d655 Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents: 1126
diff changeset
    24
    protected:
1184
75cd6681eb08 Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents: 1166
diff changeset
    25
        /** Constructor with string parameter. */
75cd6681eb08 Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents: 1166
diff changeset
    26
        MasterDeviceException(
75cd6681eb08 Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents: 1166
diff changeset
    27
                const string &s /**< Message. */
75cd6681eb08 Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents: 1166
diff changeset
    28
                ): runtime_error(s) {}
75cd6681eb08 Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents: 1166
diff changeset
    29
1141
7ffbca63fc72 Minor fixes.
Florian Pose <fp@igh-essen.com>
parents: 1136
diff changeset
    30
        /** Constructor with stringstream parameter. */
1122
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
        MasterDeviceException(
1136
a0982873d655 Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents: 1126
diff changeset
    32
                const stringstream &s /**< Message. */
a0982873d655 Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents: 1126
diff changeset
    33
                ): runtime_error(s.str()) {}
1122
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
};
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
/****************************************************************************/
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
1184
75cd6681eb08 Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents: 1166
diff changeset
    38
class MasterDeviceSdoAbortException:
75cd6681eb08 Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents: 1166
diff changeset
    39
    public MasterDeviceException 
75cd6681eb08 Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents: 1166
diff changeset
    40
{
75cd6681eb08 Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents: 1166
diff changeset
    41
    friend class MasterDevice;
75cd6681eb08 Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents: 1166
diff changeset
    42
75cd6681eb08 Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents: 1166
diff changeset
    43
    public:
75cd6681eb08 Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents: 1166
diff changeset
    44
        uint32_t abortCode;
75cd6681eb08 Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents: 1166
diff changeset
    45
    
75cd6681eb08 Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents: 1166
diff changeset
    46
    protected:
75cd6681eb08 Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents: 1166
diff changeset
    47
        /** Constructor with stringstream parameter. */
75cd6681eb08 Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents: 1166
diff changeset
    48
        MasterDeviceSdoAbortException(uint32_t code):
75cd6681eb08 Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents: 1166
diff changeset
    49
            MasterDeviceException("Sdo transfer aborted.") {
75cd6681eb08 Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents: 1166
diff changeset
    50
                abortCode = code;
75cd6681eb08 Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents: 1166
diff changeset
    51
            };
75cd6681eb08 Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents: 1166
diff changeset
    52
};
75cd6681eb08 Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents: 1166
diff changeset
    53
75cd6681eb08 Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents: 1166
diff changeset
    54
/****************************************************************************/
75cd6681eb08 Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents: 1166
diff changeset
    55
1122
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
class MasterDevice
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
{
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
    public:
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
        MasterDevice();
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
        ~MasterDevice();
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
        void setIndex(unsigned int);
1166
006244d53f68 Removed global variables.
Florian Pose <fp@igh-essen.com>
parents: 1160
diff changeset
    63
		unsigned int getIndex() const;
1122
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
        enum Permissions {Read, ReadWrite};
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
        void open(Permissions);
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
        void close();
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
        void getMaster(ec_ioctl_master_t *);
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
        void getConfig(ec_ioctl_config_t *, unsigned int);
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
        void getConfigPdo(ec_ioctl_config_pdo_t *, unsigned int, uint8_t,
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
                uint16_t);
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
        void getConfigPdoEntry(ec_ioctl_config_pdo_entry_t *, unsigned int,
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
                uint8_t, uint16_t, uint8_t);
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
        void getConfigSdo(ec_ioctl_config_sdo_t *, unsigned int, unsigned int);
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
        void getDomain(ec_ioctl_domain_t *, unsigned int);
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
        void getFmmu(ec_ioctl_domain_fmmu_t *, unsigned int, unsigned int);
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
        void getData(ec_ioctl_domain_data_t *, unsigned int, unsigned int,
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
                unsigned char *);
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
        void getSlave(ec_ioctl_slave_t *, uint16_t);
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
        void getSync(ec_ioctl_slave_sync_t *, uint16_t, uint8_t);
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
        void getPdo(ec_ioctl_slave_sync_pdo_t *, uint16_t, uint8_t, uint8_t);
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
        void getPdoEntry(ec_ioctl_slave_sync_pdo_entry_t *, uint16_t, uint8_t,
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
                uint8_t, uint8_t);
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
        void getSdo(ec_ioctl_slave_sdo_t *, uint16_t, uint16_t);
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
        void getSdoEntry(ec_ioctl_slave_sdo_entry_t *, uint16_t, int, uint8_t);
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    87
        void readSii(ec_ioctl_slave_sii_t *);
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    88
        void writeSii(ec_ioctl_slave_sii_t *);
1200
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents: 1184
diff changeset
    89
        void readPhy(ec_ioctl_slave_phy_t *);
ce1a65f06efc Added phy commands.
Florian Pose <fp@igh-essen.com>
parents: 1184
diff changeset
    90
        void writePhy(ec_ioctl_slave_phy_t *);
1126
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents: 1122
diff changeset
    91
		void setDebug(unsigned int);
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents: 1122
diff changeset
    92
		void sdoDownload(ec_ioctl_slave_sdo_download_t *);
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents: 1122
diff changeset
    93
		void sdoUpload(ec_ioctl_slave_sdo_upload_t *);
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents: 1122
diff changeset
    94
		void requestState(uint16_t, uint8_t);
1122
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    95
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    96
    private:
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    97
        unsigned int index;
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    98
        int fd;
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    99
};
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   100
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   101
/****************************************************************************/
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   102
1166
006244d53f68 Removed global variables.
Florian Pose <fp@igh-essen.com>
parents: 1160
diff changeset
   103
inline unsigned int MasterDevice::getIndex() const
006244d53f68 Removed global variables.
Florian Pose <fp@igh-essen.com>
parents: 1160
diff changeset
   104
{
006244d53f68 Removed global variables.
Florian Pose <fp@igh-essen.com>
parents: 1160
diff changeset
   105
	return index;
006244d53f68 Removed global variables.
Florian Pose <fp@igh-essen.com>
parents: 1160
diff changeset
   106
}
006244d53f68 Removed global variables.
Florian Pose <fp@igh-essen.com>
parents: 1160
diff changeset
   107
006244d53f68 Removed global variables.
Florian Pose <fp@igh-essen.com>
parents: 1160
diff changeset
   108
/****************************************************************************/
006244d53f68 Removed global variables.
Florian Pose <fp@igh-essen.com>
parents: 1160
diff changeset
   109
1122
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   110
#endif