tool/MasterDevice.h
author Florian Pose <fp@igh-essen.com>
Tue, 22 Jul 2008 14:17:20 +0000
changeset 1126 b09fd81894cb
parent 1122 ee305a780a02
child 1136 a0982873d655
permissions -rw-r--r--
Moved every command into a separate file.
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
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
#ifndef __EC_MASTER_H__
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
#define __EC_MASTER_H__
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>
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
using namespace std;
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
#include "../include/ecrt.h"
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
#include "../master/ioctl.h"
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
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
class MasterDeviceException:
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
    public runtime_error
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
{
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
    public:
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
        /** Constructor with std::string parameter. */
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
        MasterDeviceException(
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
                const string &s /**< Message. */
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
                ): runtime_error(s) {}
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
};
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
/****************************************************************************/
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
class MasterDevice
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
    public:
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
        MasterDevice();
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
        ~MasterDevice();
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
        void setIndex(unsigned int);
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
        enum Permissions {Read, ReadWrite};
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
        void open(Permissions);
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
        void close();
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
        unsigned int slaveCount();
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
        void getMaster(ec_ioctl_master_t *);
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
        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
    46
        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
    47
                uint16_t);
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
        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
    49
                uint8_t, uint16_t, uint8_t);
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
        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
    51
        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
    52
        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
    53
        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
    54
                unsigned char *);
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
        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
    56
        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
    57
        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
    58
        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
    59
                uint8_t, uint8_t);
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
        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
    61
        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
    62
        void readSii(ec_ioctl_slave_sii_t *);
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
        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
    64
		void setDebug(unsigned int);
b09fd81894cb Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents: 1122
diff changeset
    65
		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
    66
		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
    67
		void requestState(uint16_t, uint8_t);
1122
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
    private:
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
        unsigned int index;
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
        int fd;
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
};
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
ee305a780a02 First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
/****************************************************************************/
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
#endif