master/ioctl.h
changeset 2011 04fdb4abf120
parent 2009 b5391b329b5d
child 2042 8b358effa78b
child 2124 c4afc5fede19
equal deleted inserted replaced
2010:87de63b19e4c 2011:04fdb4abf120
    54 
    54 
    55 /** EtherCAT master ioctl() version magic.
    55 /** EtherCAT master ioctl() version magic.
    56  *
    56  *
    57  * Increment this when changing the ioctl interface!
    57  * Increment this when changing the ioctl interface!
    58  */
    58  */
    59 #define EC_IOCTL_VERSION_MAGIC 8
    59 #define EC_IOCTL_VERSION_MAGIC 11
    60 
    60 
    61 // Command-line tool
    61 // Command-line tool
    62 #define EC_IOCTL_MODULE                EC_IOR(0x00, ec_ioctl_module_t)
    62 #define EC_IOCTL_MODULE                EC_IOR(0x00, ec_ioctl_module_t)
    63 #define EC_IOCTL_MASTER                EC_IOR(0x01, ec_ioctl_master_t)
    63 #define EC_IOCTL_MASTER                EC_IOR(0x01, ec_ioctl_master_t)
    64 #define EC_IOCTL_SLAVE                EC_IOWR(0x02, ec_ioctl_slave_t)
    64 #define EC_IOCTL_SLAVE                EC_IOWR(0x02, ec_ioctl_slave_t)
    85 #define EC_IOCTL_SLAVE_SOE_WRITE      EC_IOWR(0x17, ec_ioctl_slave_soe_write_t)
    85 #define EC_IOCTL_SLAVE_SOE_WRITE      EC_IOWR(0x17, ec_ioctl_slave_soe_write_t)
    86 #define EC_IOCTL_CONFIG               EC_IOWR(0x18, ec_ioctl_config_t)
    86 #define EC_IOCTL_CONFIG               EC_IOWR(0x18, ec_ioctl_config_t)
    87 #define EC_IOCTL_CONFIG_PDO           EC_IOWR(0x19, ec_ioctl_config_pdo_t)
    87 #define EC_IOCTL_CONFIG_PDO           EC_IOWR(0x19, ec_ioctl_config_pdo_t)
    88 #define EC_IOCTL_CONFIG_PDO_ENTRY     EC_IOWR(0x1a, ec_ioctl_config_pdo_entry_t)
    88 #define EC_IOCTL_CONFIG_PDO_ENTRY     EC_IOWR(0x1a, ec_ioctl_config_pdo_entry_t)
    89 #define EC_IOCTL_CONFIG_SDO           EC_IOWR(0x1b, ec_ioctl_config_sdo_t)
    89 #define EC_IOCTL_CONFIG_SDO           EC_IOWR(0x1b, ec_ioctl_config_sdo_t)
       
    90 #define EC_IOCTL_CONFIG_IDN           EC_IOWR(0x1c, ec_ioctl_config_idn_t)
    90 #ifdef EC_EOE
    91 #ifdef EC_EOE
    91 #define EC_IOCTL_EOE_HANDLER          EC_IOWR(0x1c, ec_ioctl_eoe_handler_t)
    92 #define EC_IOCTL_EOE_HANDLER          EC_IOWR(0x1d, ec_ioctl_eoe_handler_t)
    92 #endif
    93 #endif
    93 
    94 
    94 // Application interface
    95 // Application interface
    95 #define EC_IOCTL_REQUEST                EC_IO(0x1d)
    96 #define EC_IOCTL_REQUEST                EC_IO(0x1e)
    96 #define EC_IOCTL_CREATE_DOMAIN          EC_IO(0x1e)
    97 #define EC_IOCTL_CREATE_DOMAIN          EC_IO(0x1f)
    97 #define EC_IOCTL_CREATE_SLAVE_CONFIG  EC_IOWR(0x1f, ec_ioctl_config_t)
    98 #define EC_IOCTL_CREATE_SLAVE_CONFIG  EC_IOWR(0x20, ec_ioctl_config_t)
    98 #define EC_IOCTL_ACTIVATE              EC_IOR(0x20, size_t)
    99 #define EC_IOCTL_ACTIVATE              EC_IOR(0x21, size_t)
    99 #define EC_IOCTL_DEACTIVATE             EC_IO(0x21)
   100 #define EC_IOCTL_DEACTIVATE             EC_IO(0x22)
   100 #define EC_IOCTL_SEND                   EC_IO(0x22)
   101 #define EC_IOCTL_SEND                   EC_IO(0x23)
   101 #define EC_IOCTL_RECEIVE                EC_IO(0x23)
   102 #define EC_IOCTL_RECEIVE                EC_IO(0x24)
   102 #define EC_IOCTL_MASTER_STATE          EC_IOR(0x24, ec_master_state_t)
   103 #define EC_IOCTL_MASTER_STATE          EC_IOR(0x25, ec_master_state_t)
   103 #define EC_IOCTL_APP_TIME              EC_IOW(0x25, ec_ioctl_app_time_t)
   104 #define EC_IOCTL_APP_TIME              EC_IOW(0x26, ec_ioctl_app_time_t)
   104 #define EC_IOCTL_SYNC_REF               EC_IO(0x26)
   105 #define EC_IOCTL_SYNC_REF               EC_IO(0x27)
   105 #define EC_IOCTL_SYNC_SLAVES            EC_IO(0x27)
   106 #define EC_IOCTL_SYNC_SLAVES            EC_IO(0x28)
   106 #define EC_IOCTL_SYNC_MON_QUEUE         EC_IO(0x28)
   107 #define EC_IOCTL_SYNC_MON_QUEUE         EC_IO(0x29)
   107 #define EC_IOCTL_SYNC_MON_PROCESS      EC_IOR(0x29, uint32_t)
   108 #define EC_IOCTL_SYNC_MON_PROCESS      EC_IOR(0x2a, uint32_t)
   108 #define EC_IOCTL_SC_SYNC               EC_IOW(0x2a, ec_ioctl_config_t)
   109 #define EC_IOCTL_RESET                  EC_IO(0x2b)
   109 #define EC_IOCTL_SC_WATCHDOG           EC_IOW(0x2b, ec_ioctl_config_t)
   110 #define EC_IOCTL_SC_SYNC               EC_IOW(0x2c, ec_ioctl_config_t)
   110 #define EC_IOCTL_SC_ADD_PDO            EC_IOW(0x2c, ec_ioctl_config_pdo_t)
   111 #define EC_IOCTL_SC_WATCHDOG           EC_IOW(0x2d, ec_ioctl_config_t)
   111 #define EC_IOCTL_SC_CLEAR_PDOS         EC_IOW(0x2d, ec_ioctl_config_pdo_t)
   112 #define EC_IOCTL_SC_ADD_PDO            EC_IOW(0x2e, ec_ioctl_config_pdo_t)
   112 #define EC_IOCTL_SC_ADD_ENTRY          EC_IOW(0x2e, ec_ioctl_add_pdo_entry_t)
   113 #define EC_IOCTL_SC_CLEAR_PDOS         EC_IOW(0x2f, ec_ioctl_config_pdo_t)
   113 #define EC_IOCTL_SC_CLEAR_ENTRIES      EC_IOW(0x2f, ec_ioctl_config_pdo_t)
   114 #define EC_IOCTL_SC_ADD_ENTRY          EC_IOW(0x30, ec_ioctl_add_pdo_entry_t)
   114 #define EC_IOCTL_SC_REG_PDO_ENTRY     EC_IOWR(0x20, ec_ioctl_reg_pdo_entry_t)
   115 #define EC_IOCTL_SC_CLEAR_ENTRIES      EC_IOW(0x31, ec_ioctl_config_pdo_t)
   115 #define EC_IOCTL_SC_DC                 EC_IOW(0x31, ec_ioctl_config_t)
   116 #define EC_IOCTL_SC_REG_PDO_ENTRY     EC_IOWR(0x32, ec_ioctl_reg_pdo_entry_t)
   116 #define EC_IOCTL_SC_SDO                EC_IOW(0x32, ec_ioctl_sc_sdo_t)
   117 #define EC_IOCTL_SC_DC                 EC_IOW(0x33, ec_ioctl_config_t)
   117 #define EC_IOCTL_SC_SDO_REQUEST       EC_IOWR(0x33, ec_ioctl_sdo_request_t)
   118 #define EC_IOCTL_SC_SDO                EC_IOW(0x34, ec_ioctl_sc_sdo_t)
   118 #define EC_IOCTL_SC_VOE               EC_IOWR(0x34, ec_ioctl_voe_t)
   119 #define EC_IOCTL_SC_SDO_REQUEST       EC_IOWR(0x35, ec_ioctl_sdo_request_t)
   119 #define EC_IOCTL_SC_STATE             EC_IOWR(0x35, ec_ioctl_sc_state_t)
   120 #define EC_IOCTL_SC_VOE               EC_IOWR(0x36, ec_ioctl_voe_t)
   120 #define EC_IOCTL_SC_IDN                EC_IOW(0x36, ec_ioctl_sc_idn_t)
   121 #define EC_IOCTL_SC_STATE             EC_IOWR(0x37, ec_ioctl_sc_state_t)
   121 #define EC_IOCTL_DOMAIN_OFFSET          EC_IO(0x37)
   122 #define EC_IOCTL_SC_IDN                EC_IOW(0x38, ec_ioctl_sc_idn_t)
   122 #define EC_IOCTL_DOMAIN_PROCESS         EC_IO(0x38)
   123 #define EC_IOCTL_DOMAIN_OFFSET          EC_IO(0x39)
   123 #define EC_IOCTL_DOMAIN_QUEUE           EC_IO(0x39)
   124 #define EC_IOCTL_DOMAIN_PROCESS         EC_IO(0x3a)
   124 #define EC_IOCTL_DOMAIN_STATE         EC_IOWR(0x3a, ec_ioctl_domain_state_t)
   125 #define EC_IOCTL_DOMAIN_QUEUE           EC_IO(0x3b)
   125 #define EC_IOCTL_SDO_REQUEST_TIMEOUT  EC_IOWR(0x3b, ec_ioctl_sdo_request_t)
   126 #define EC_IOCTL_DOMAIN_STATE         EC_IOWR(0x3c, ec_ioctl_domain_state_t)
   126 #define EC_IOCTL_SDO_REQUEST_STATE    EC_IOWR(0x3c, ec_ioctl_sdo_request_t)
   127 #define EC_IOCTL_SDO_REQUEST_TIMEOUT  EC_IOWR(0x3d, ec_ioctl_sdo_request_t)
   127 #define EC_IOCTL_SDO_REQUEST_READ     EC_IOWR(0x3d, ec_ioctl_sdo_request_t)
   128 #define EC_IOCTL_SDO_REQUEST_STATE    EC_IOWR(0x3e, ec_ioctl_sdo_request_t)
   128 #define EC_IOCTL_SDO_REQUEST_WRITE    EC_IOWR(0x3e, ec_ioctl_sdo_request_t)
   129 #define EC_IOCTL_SDO_REQUEST_READ     EC_IOWR(0x3f, ec_ioctl_sdo_request_t)
   129 #define EC_IOCTL_SDO_REQUEST_DATA     EC_IOWR(0x3f, ec_ioctl_sdo_request_t)
   130 #define EC_IOCTL_SDO_REQUEST_WRITE    EC_IOWR(0x40, ec_ioctl_sdo_request_t)
   130 #define EC_IOCTL_VOE_SEND_HEADER       EC_IOW(0x40, ec_ioctl_voe_t)
   131 #define EC_IOCTL_SDO_REQUEST_DATA     EC_IOWR(0x41, ec_ioctl_sdo_request_t)
   131 #define EC_IOCTL_VOE_REC_HEADER       EC_IOWR(0x41, ec_ioctl_voe_t)
   132 #define EC_IOCTL_VOE_SEND_HEADER       EC_IOW(0x42, ec_ioctl_voe_t)
   132 #define EC_IOCTL_VOE_READ              EC_IOW(0x42, ec_ioctl_voe_t)
   133 #define EC_IOCTL_VOE_REC_HEADER       EC_IOWR(0x43, ec_ioctl_voe_t)
   133 #define EC_IOCTL_VOE_READ_NOSYNC       EC_IOW(0x43, ec_ioctl_voe_t)
   134 #define EC_IOCTL_VOE_READ              EC_IOW(0x44, ec_ioctl_voe_t)
   134 #define EC_IOCTL_VOE_WRITE            EC_IOWR(0x44, ec_ioctl_voe_t)
   135 #define EC_IOCTL_VOE_READ_NOSYNC       EC_IOW(0x45, ec_ioctl_voe_t)
   135 #define EC_IOCTL_VOE_EXEC             EC_IOWR(0x45, ec_ioctl_voe_t)
   136 #define EC_IOCTL_VOE_WRITE            EC_IOWR(0x46, ec_ioctl_voe_t)
   136 #define EC_IOCTL_VOE_DATA             EC_IOWR(0x46, ec_ioctl_voe_t)
   137 #define EC_IOCTL_VOE_EXEC             EC_IOWR(0x47, ec_ioctl_voe_t)
   137 #define EC_IOCTL_SET_SEND_INTERVAL     EC_IOW(0x47, size_t)
   138 #define EC_IOCTL_VOE_DATA             EC_IOWR(0x48, ec_ioctl_voe_t)
       
   139 #define EC_IOCTL_SET_SEND_INTERVAL     EC_IOW(0x49, size_t)
   138 
   140 
   139 /*****************************************************************************/
   141 /*****************************************************************************/
   140 
   142 
   141 #define EC_IOCTL_STRING_SIZE 64
   143 #define EC_IOCTL_STRING_SIZE 64
   142 
   144 
   418     uint16_t idn;
   420     uint16_t idn;
   419     uint32_t mem_size;
   421     uint32_t mem_size;
   420     uint8_t *data;
   422     uint8_t *data;
   421 
   423 
   422     // outputs
   424     // outputs
   423     uint32_t data_size;
   425     size_t data_size;
   424     uint16_t error_code;
   426     uint16_t error_code;
   425 } ec_ioctl_slave_soe_read_t;
   427 } ec_ioctl_slave_soe_read_t;
   426 
   428 
   427 /*****************************************************************************/
   429 /*****************************************************************************/
   428 
   430 
   429 typedef struct {
   431 typedef struct {
   430     // inputs
   432     // inputs
   431     uint16_t slave_position;
   433     uint16_t slave_position;
   432     uint8_t drive_no;
   434     uint8_t drive_no;
   433     uint16_t idn;
   435     uint16_t idn;
   434     uint32_t data_size;
   436     size_t data_size;
   435     uint8_t *data;
   437     uint8_t *data;
   436 
   438 
   437     // outputs
   439     // outputs
   438     uint16_t error_code;
   440     uint16_t error_code;
   439 } ec_ioctl_slave_soe_write_t;
   441 } ec_ioctl_slave_soe_write_t;
   456         uint8_t config_this;
   458         uint8_t config_this;
   457     } syncs[EC_MAX_SYNC_MANAGERS];
   459     } syncs[EC_MAX_SYNC_MANAGERS];
   458     uint16_t watchdog_divider;
   460     uint16_t watchdog_divider;
   459     uint16_t watchdog_intervals;
   461     uint16_t watchdog_intervals;
   460     uint32_t sdo_count;
   462     uint32_t sdo_count;
       
   463     uint32_t idn_count;
   461     int32_t slave_position;
   464     int32_t slave_position;
   462     uint16_t dc_assign_activate;
   465     uint16_t dc_assign_activate;
   463     ec_sync_signal_t dc_sync[EC_SYNC_SIGNAL_COUNT];
   466     ec_sync_signal_t dc_sync[EC_SYNC_SIGNAL_COUNT];
   464 } ec_ioctl_config_t;
   467 } ec_ioctl_config_t;
   465 
   468 
   509     uint16_t index;
   512     uint16_t index;
   510     uint8_t subindex;
   513     uint8_t subindex;
   511     uint32_t size;
   514     uint32_t size;
   512     uint8_t data[EC_MAX_SDO_DATA_SIZE];
   515     uint8_t data[EC_MAX_SDO_DATA_SIZE];
   513 } ec_ioctl_config_sdo_t;
   516 } ec_ioctl_config_sdo_t;
       
   517 
       
   518 /*****************************************************************************/
       
   519 
       
   520 /** Maximum size for displayed IDN data.
       
   521  * \todo Make this dynamic.
       
   522  */
       
   523 #define EC_MAX_IDN_DATA_SIZE 1024
       
   524 
       
   525 typedef struct {
       
   526     // inputs
       
   527     uint32_t config_index;
       
   528     uint32_t idn_pos;
       
   529 
       
   530     // outputs
       
   531     uint8_t drive_no;
       
   532     uint16_t idn;
       
   533     ec_al_state_t state;
       
   534     size_t size;
       
   535     uint8_t data[EC_MAX_IDN_DATA_SIZE];
       
   536 } ec_ioctl_config_idn_t;
   514 
   537 
   515 /*****************************************************************************/
   538 /*****************************************************************************/
   516 
   539 
   517 #ifdef EC_EOE
   540 #ifdef EC_EOE
   518 
   541