Skip to content
Snippets Groups Projects
Commit cecf361f authored by Florian Pose's avatar Florian Pose
Browse files

Store PDO mapping source in sync manager.

parent 77d1c15d
No related branches found
No related tags found
No related merge requests found
......@@ -276,6 +276,7 @@ void ec_fsm_coe_map_action_next_pdo(
list_for_each_entry(pdo, &fsm->pdos, list) {
ec_sync_add_pdo(sync, pdo);
}
sync->mapping_source = EC_SYNC_MAPPING_COE;
ec_fsm_coe_map_clear_pdos(fsm);
// next sync manager
......
......@@ -576,6 +576,7 @@ int ec_slave_fetch_sii_pdos(
// if sync manager index is positive, the PDO is mapped by default
if (pdo->sync_index >= 0) {
ec_sync_t *sync;
ec_pdo_t *mapped_pdo;
if (pdo->sync_index >= slave->sii_sync_count) {
......@@ -583,6 +584,7 @@ int ec_slave_fetch_sii_pdos(
pdo->sync_index, pdo->index, slave->ring_position);
return -1;
}
sync = &slave->sii_syncs[pdo->sync_index];
if (!(mapped_pdo = kmalloc(sizeof(ec_pdo_t), GFP_KERNEL))) {
EC_ERR("Failed to allocate PDO memory.\n");
......@@ -595,8 +597,8 @@ int ec_slave_fetch_sii_pdos(
return -1;
}
list_add_tail(&mapped_pdo->list,
&slave->sii_syncs[pdo->sync_index].pdos);
list_add_tail(&mapped_pdo->list, &sync->pdos);
sync->mapping_source = EC_SYNC_MAPPING_SII;
}
}
......@@ -810,8 +812,12 @@ size_t ec_slave_info(const ec_slave_t *slave, /**< EtherCAT slave */
ec_sync_size(sync), sync->control_register,
sync->enable ? "enable" : "disable");
if (list_empty(&sync->pdos))
if (list_empty(&sync->pdos)) {
off += sprintf(buffer + off, " No PDOs mapped.\n");
} else if (sync->mapping_source != EC_SYNC_MAPPING_NONE) {
off += sprintf(buffer + off, " PDO mapping information from %s.\n",
sync->mapping_source == EC_SYNC_MAPPING_SII ? "SII" : "CoE");
}
list_for_each_entry(pdo, &sync->pdos, list) {
off += sprintf(buffer + off, " %s 0x%04X \"%s\"\n",
......@@ -830,7 +836,7 @@ size_t ec_slave_info(const ec_slave_t *slave, /**< EtherCAT slave */
// type-cast to avoid warnings on some compilers
if (!list_empty((struct list_head *) &slave->sii_pdos))
off += sprintf(buffer + off, "\nAvailable PDOs:\n");
off += sprintf(buffer + off, "\nAvailable PDOs from SII:\n");
list_for_each_entry(pdo, &slave->sii_pdos, list) {
off += sprintf(buffer + off, " %s 0x%04X \"%s\"",
......
......@@ -62,6 +62,7 @@ void ec_sync_init(
sync->est_length = 0;
INIT_LIST_HEAD(&sync->pdos);
sync->alt_mapping = 0;
sync->mapping_source = EC_SYNC_MAPPING_NONE;
}
/*****************************************************************************/
......
......@@ -53,6 +53,19 @@
/*****************************************************************************/
/**
* EtherCAT sync manager PDO mapping information source.
*/
typedef enum {
EC_SYNC_MAPPING_NONE, /**< No PDO mapping information */
EC_SYNC_MAPPING_SII, /**< PDO mapping information from SII */
EC_SYNC_MAPPING_COE /**< PDO mapping information from CoE dictionary */
}
ec_sync_mapping_source_t;
/*****************************************************************************/
/**
* Sync manager.
*/
......@@ -69,6 +82,7 @@ typedef struct
uint16_t est_length; /**< used to calculate the length via PDO ranges */
struct list_head pdos; /**< list of mapped PDOs */
unsigned int alt_mapping; /**< alternative mapping configured */
ec_sync_mapping_source_t mapping_source; /**< pdo mapping source */
}
ec_sync_t;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment