Fixed 2 bugs in new Pdo mapping function.
--- a/include/ecrt.h Thu Feb 28 14:46:24 2008 +0000
+++ b/include/ecrt.h Thu Feb 28 15:28:10 2008 +0000
@@ -453,8 +453,8 @@
*/
int ecrt_slave_config_mapping(
ec_slave_config_t *sc, /**< Slave configuration. */
- unsigned int n_entries, /**< Number of Pdos in \a pdos to map. */
- const ec_pdo_info_t pdos[] /**< List with Pdo mapping. */
+ unsigned int n_infos, /**< Number of Pdo infos in \a pdo_infos. */
+ const ec_pdo_info_t pdo_infos[] /**< List with Pdo mapping. */
);
/** Registers a Pdo entry for process data exchange in a domain.
--- a/master/pdo_mapping.c Thu Feb 28 14:46:24 2008 +0000
+++ b/master/pdo_mapping.c Thu Feb 28 15:28:10 2008 +0000
@@ -122,8 +122,8 @@
*/
ec_pdo_t *ec_pdo_mapping_add_pdo(
ec_pdo_mapping_t *pm, /**< Pdo mapping. */
- uint16_t index, /**< Pdo index. */
- ec_direction_t dir /**< Direction. */
+ ec_direction_t dir, /**< Direction. */
+ uint16_t index /**< Pdo index. */
)
{
ec_pdo_t *pdo;
--- a/master/pdo_mapping.h Thu Feb 28 14:46:24 2008 +0000
+++ b/master/pdo_mapping.h Thu Feb 28 15:28:10 2008 +0000
@@ -64,8 +64,8 @@
void ec_pdo_mapping_clear_pdos(ec_pdo_mapping_t *);
-ec_pdo_t *ec_pdo_mapping_add_pdo(ec_pdo_mapping_t *, uint16_t,
- ec_direction_t);
+ec_pdo_t *ec_pdo_mapping_add_pdo(ec_pdo_mapping_t *, ec_direction_t,
+ uint16_t);
int ec_pdo_mapping_add_pdo_copy(ec_pdo_mapping_t *, const ec_pdo_t *);
int ec_pdo_mapping_copy(ec_pdo_mapping_t *, const ec_pdo_mapping_t *);
--- a/master/slave_config.c Thu Feb 28 14:46:24 2008 +0000
+++ b/master/slave_config.c Thu Feb 28 15:28:10 2008 +0000
@@ -512,7 +512,7 @@
EC_DBG("Adding Pdo 0x%04X to mapping for dir %u, config %u:%u.\n",
index, dir, sc->alias, sc->position);
- if (!(pdo = ec_pdo_mapping_add_pdo(pm, index, dir)))
+ if (!(pdo = ec_pdo_mapping_add_pdo(pm, dir, index)))
return -1;
ec_slave_config_load_default_pdo_config(sc, pdo);
@@ -557,16 +557,16 @@
/*****************************************************************************/
-int ecrt_slave_config_mapping(ec_slave_config_t *sc, unsigned int n_entries,
+int ecrt_slave_config_mapping(ec_slave_config_t *sc, unsigned int n_infos,
const ec_pdo_info_t pdo_infos[])
{
- unsigned int i;
+ unsigned int i, j;
const ec_pdo_info_t *pi;
ec_pdo_mapping_t *pm;
ec_pdo_t *pdo;
const ec_pdo_entry_info_t *ei;
- for (i = 0; i < n_entries; i++) {
+ for (i = 0; i < n_infos; i++) {
pi = &pdo_infos[i];
pm = &sc->mapping[pi->dir];
@@ -579,7 +579,8 @@
}
if (sc->master->debug_level)
- EC_DBG("Adding Pdo 0x%04X to mapping.\n", pi->index);
+ EC_DBG("Adding Pdo 0x%04X to mapping for dir %u, config %u:%u.\n",
+ pi->index, pi->dir, sc->alias, sc->position);
if (!(pdo = ec_pdo_mapping_add_pdo(pm, pi->dir, pi->index)))
return -1;
@@ -588,8 +589,8 @@
if (sc->master->debug_level)
EC_DBG(" Pdo configuration information provided.\n");
- for (i = 0; i < pi->n_entries; i++) {
- ei = &pi->entries[i];
+ for (j = 0; j < pi->n_entries; j++) {
+ ei = &pi->entries[j];
if (!ec_pdo_add_entry(pdo, ei->index, ei->subindex,
ei->bit_length))
return -1;