tool/MasterDevice.h
author Florian Pose <fp@igh-essen.com>
Mon, 28 Jul 2008 12:11:50 +0000
changeset 1159 25cc77cf3993
parent 1141 7ffbca63fc72
child 1160 f02ff486b313
permissions -rw-r--r--
Improved alias/position addressing in case od duplicated aliases.
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:
1141
7ffbca63fc72 Minor fixes.
Florian Pose <fp@igh-essen.com>
parents: 1136
diff changeset
    25
        /** Constructor with stringstream parameter. */
1122
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
        MasterDeviceException(
1136
a0982873d655 Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents: 1126
diff changeset
    27
                const stringstream &s /**< Message. */
a0982873d655 Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents: 1126
diff changeset
    28
                ): runtime_error(s.str()) {}
1122
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
};
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
/****************************************************************************/
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
class MasterDevice
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
    public:
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
        MasterDevice();
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
        ~MasterDevice();
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
        void setIndex(unsigned int);
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
        enum Permissions {Read, ReadWrite};
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
        void open(Permissions);
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
        void close();
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
        unsigned int slaveCount();
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
        void getMaster(ec_ioctl_master_t *);
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
        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
    49
        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
    50
                uint16_t);
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
        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
    52
                uint8_t, uint16_t, uint8_t);
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
        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
    54
        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
    55
        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
    56
        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
    57
                unsigned char *);
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
        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
    59
        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
    60
        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
    61
        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
    62
                uint8_t, uint8_t);
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
        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
    64
        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
    65
        void readSii(ec_ioctl_slave_sii_t *);
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
        void writeSii(ec_ioctl_slave_sii_t *);
1126
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents: 1122
diff changeset
    67
		void setDebug(unsigned int);
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents: 1122
diff changeset
    68
		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
    69
		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
    70
		void requestState(uint16_t, uint8_t);
1122
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
    private:
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
        unsigned int index;
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
        int fd;
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
};
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
/****************************************************************************/
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
#endif