master/ioctl.h
changeset 2004 be807e224b0e
parent 1995 7d748d9cf9e8
parent 1972 c1b564299829
child 2005 02580c044c32
equal deleted inserted replaced
2003:a7ff6c28a432 2004:be807e224b0e
    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 10
    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(0x10, 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_SC_SYNC               EC_IOW(0x2b, ec_ioctl_config_t)
   109 #define EC_IOCTL_SC_WATCHDOG           EC_IOW(0x2b, ec_ioctl_config_t)
   110 #define EC_IOCTL_SC_WATCHDOG           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_ADD_PDO            EC_IOW(0x2d, ec_ioctl_config_pdo_t)
   111 #define EC_IOCTL_SC_CLEAR_PDOS         EC_IOW(0x2d, ec_ioctl_config_pdo_t)
   112 #define EC_IOCTL_SC_CLEAR_PDOS         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_ADD_ENTRY          EC_IOW(0x2f, ec_ioctl_add_pdo_entry_t)
   113 #define EC_IOCTL_SC_CLEAR_ENTRIES      EC_IOW(0x2f, ec_ioctl_config_pdo_t)
   114 #define EC_IOCTL_SC_CLEAR_ENTRIES      EC_IOW(0x20, ec_ioctl_config_pdo_t)
   114 #define EC_IOCTL_SC_REG_PDO_ENTRY     EC_IOWR(0x20, ec_ioctl_reg_pdo_entry_t)
   115 #define EC_IOCTL_SC_REG_PDO_ENTRY     EC_IOWR(0x21, ec_ioctl_reg_pdo_entry_t)
   115 #define EC_IOCTL_SC_DC                 EC_IOW(0x31, ec_ioctl_config_t)
   116 #define EC_IOCTL_SC_DC                 EC_IOW(0x32, ec_ioctl_config_t)
   116 #define EC_IOCTL_SC_SDO                EC_IOW(0x32, ec_ioctl_sc_sdo_t)
   117 #define EC_IOCTL_SC_SDO                EC_IOW(0x33, ec_ioctl_sc_sdo_t)
   117 #define EC_IOCTL_SC_SDO_REQUEST       EC_IOWR(0x33, ec_ioctl_sdo_request_t)
   118 #define EC_IOCTL_SC_SDO_REQUEST       EC_IOWR(0x34, ec_ioctl_sdo_request_t)
   118 #define EC_IOCTL_SC_VOE               EC_IOWR(0x34, ec_ioctl_voe_t)
   119 #define EC_IOCTL_SC_VOE               EC_IOWR(0x35, ec_ioctl_voe_t)
   119 #define EC_IOCTL_SC_STATE             EC_IOWR(0x35, ec_ioctl_sc_state_t)
   120 #define EC_IOCTL_SC_STATE             EC_IOWR(0x36, ec_ioctl_sc_state_t)
   120 #define EC_IOCTL_SC_IDN                EC_IOW(0x36, ec_ioctl_sc_idn_t)
   121 #define EC_IOCTL_SC_IDN                EC_IOW(0x37, ec_ioctl_sc_idn_t)
   121 #define EC_IOCTL_DOMAIN_OFFSET          EC_IO(0x37)
   122 #define EC_IOCTL_DOMAIN_OFFSET          EC_IO(0x38)
   122 #define EC_IOCTL_DOMAIN_PROCESS         EC_IO(0x38)
   123 #define EC_IOCTL_DOMAIN_PROCESS         EC_IO(0x39)
   123 #define EC_IOCTL_DOMAIN_QUEUE           EC_IO(0x39)
   124 #define EC_IOCTL_DOMAIN_QUEUE           EC_IO(0x3a)
   124 #define EC_IOCTL_DOMAIN_STATE         EC_IOWR(0x3a, ec_ioctl_domain_state_t)
   125 #define EC_IOCTL_DOMAIN_STATE         EC_IOWR(0x3b, ec_ioctl_domain_state_t)
   125 #define EC_IOCTL_SDO_REQUEST_TIMEOUT  EC_IOWR(0x3b, ec_ioctl_sdo_request_t)
   126 #define EC_IOCTL_SDO_REQUEST_TIMEOUT  EC_IOWR(0x3c, ec_ioctl_sdo_request_t)
   126 #define EC_IOCTL_SDO_REQUEST_STATE    EC_IOWR(0x3c, ec_ioctl_sdo_request_t)
   127 #define EC_IOCTL_SDO_REQUEST_STATE    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_READ     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_WRITE    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_DATA     EC_IOWR(0x30, ec_ioctl_sdo_request_t)
   130 #define EC_IOCTL_VOE_SEND_HEADER       EC_IOW(0x40, ec_ioctl_voe_t)
   131 #define EC_IOCTL_VOE_SEND_HEADER       EC_IOW(0x41, ec_ioctl_voe_t)
   131 #define EC_IOCTL_VOE_REC_HEADER       EC_IOWR(0x41, ec_ioctl_voe_t)
   132 #define EC_IOCTL_VOE_REC_HEADER       EC_IOWR(0x42, ec_ioctl_voe_t)
   132 #define EC_IOCTL_VOE_READ              EC_IOW(0x42, ec_ioctl_voe_t)
   133 #define EC_IOCTL_VOE_READ              EC_IOW(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_NOSYNC       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_WRITE            EC_IOWR(0x45, ec_ioctl_voe_t)
   135 #define EC_IOCTL_VOE_EXEC             EC_IOWR(0x45, ec_ioctl_voe_t)
   136 #define EC_IOCTL_VOE_EXEC             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_DATA             EC_IOWR(0x47, ec_ioctl_voe_t)
   137 #define EC_IOCTL_SET_SEND_INTERVAL     EC_IOW(0x47, size_t)
   138 #define EC_IOCTL_SET_SEND_INTERVAL     EC_IOW(0x48, size_t)
   138 #define EC_IOCTL_MASTER_SC_STATE        EC_IOR(0x47, ec_master_state_t)
   139 #define EC_IOCTL_MASTER_SC_STATE        EC_IOR(0x47, ec_master_state_t)
   139 #define EC_IOCTL_SC_OVERLAPPING_IO      EC_IOW(0x48, ec_ioctl_config_t)
   140 #define EC_IOCTL_SC_OVERLAPPING_IO      EC_IOW(0x48, ec_ioctl_config_t)
   140 
   141 
   141 /*****************************************************************************/
   142 /*****************************************************************************/
   142 
   143 
   422     uint16_t idn;
   423     uint16_t idn;
   423     uint32_t mem_size;
   424     uint32_t mem_size;
   424     uint8_t *data;
   425     uint8_t *data;
   425 
   426 
   426     // outputs
   427     // outputs
   427     uint32_t data_size;
   428     size_t data_size;
   428     uint16_t error_code;
   429     uint16_t error_code;
   429 } ec_ioctl_slave_soe_read_t;
   430 } ec_ioctl_slave_soe_read_t;
   430 
   431 
   431 /*****************************************************************************/
   432 /*****************************************************************************/
   432 
   433 
   433 typedef struct {
   434 typedef struct {
   434     // inputs
   435     // inputs
   435     uint16_t slave_position;
   436     uint16_t slave_position;
   436     uint8_t drive_no;
   437     uint8_t drive_no;
   437     uint16_t idn;
   438     uint16_t idn;
   438     uint32_t data_size;
   439     size_t data_size;
   439     uint8_t *data;
   440     uint8_t *data;
   440 
   441 
   441     // outputs
   442     // outputs
   442     uint16_t error_code;
   443     uint16_t error_code;
   443 } ec_ioctl_slave_soe_write_t;
   444 } ec_ioctl_slave_soe_write_t;
   461     } syncs[EC_MAX_SYNC_MANAGERS];
   462     } syncs[EC_MAX_SYNC_MANAGERS];
   462     uint16_t watchdog_divider;
   463     uint16_t watchdog_divider;
   463     uint16_t watchdog_intervals;
   464     uint16_t watchdog_intervals;
   464     uint8_t allow_overlapping_pdos;
   465     uint8_t allow_overlapping_pdos;
   465     uint32_t sdo_count;
   466     uint32_t sdo_count;
       
   467     uint32_t idn_count;
   466     int32_t slave_position;
   468     int32_t slave_position;
   467     uint16_t dc_assign_activate;
   469     uint16_t dc_assign_activate;
   468     ec_sync_signal_t dc_sync[EC_SYNC_SIGNAL_COUNT];
   470     ec_sync_signal_t dc_sync[EC_SYNC_SIGNAL_COUNT];
   469 } ec_ioctl_config_t;
   471 } ec_ioctl_config_t;
   470 
   472 
   514     uint16_t index;
   516     uint16_t index;
   515     uint8_t subindex;
   517     uint8_t subindex;
   516     uint32_t size;
   518     uint32_t size;
   517     uint8_t data[EC_MAX_SDO_DATA_SIZE];
   519     uint8_t data[EC_MAX_SDO_DATA_SIZE];
   518 } ec_ioctl_config_sdo_t;
   520 } ec_ioctl_config_sdo_t;
       
   521 
       
   522 /*****************************************************************************/
       
   523 
       
   524 /** Maximum size for displayed IDN data.
       
   525  * \todo Make this dynamic.
       
   526  */
       
   527 #define EC_MAX_IDN_DATA_SIZE 1024
       
   528 
       
   529 typedef struct {
       
   530     // inputs
       
   531     uint32_t config_index;
       
   532     uint32_t idn_pos;
       
   533 
       
   534     // outputs
       
   535     uint8_t drive_no;
       
   536     uint16_t idn;
       
   537     ec_al_state_t state;
       
   538     size_t size;
       
   539     uint8_t data[EC_MAX_IDN_DATA_SIZE];
       
   540 } ec_ioctl_config_idn_t;
   519 
   541 
   520 /*****************************************************************************/
   542 /*****************************************************************************/
   521 
   543 
   522 #ifdef EC_EOE
   544 #ifdef EC_EOE
   523 
   545