--- a/TODO Wed Jul 02 12:19:25 2008 +0000
+++ b/TODO Wed Jul 02 14:06:10 2008 +0000
@@ -8,8 +8,6 @@
Version 1.4.0:
-* Race in jiffies frame timeout.
-* Move EC_NUM_SYNCS define to ecrt.h.
* Read Pdo mapping for unknown Pdos before configuring them.
* Attach Pdo names from SII or Coe dictioary to Pdos read via CoE.
* Make scanning and configuration run parallel (each).
@@ -21,6 +19,8 @@
* Allow master requesting when in ORPHANED phase
* Get original driver for r8169.
* Distributed clocks.
+* Fix datagram errors on application loading/unloading.
+* Race in jiffies frame timeout?
Future issues:
--- a/examples/mini/mini.c Wed Jul 02 12:19:25 2008 +0000
+++ b/examples/mini/mini.c Wed Jul 02 14:06:10 2008 +0000
@@ -320,7 +320,7 @@
#ifdef CONFIGURE_PDOS
printk(KERN_INFO PFX "Configuring Pdos...\n");
- if (ecrt_slave_config_sync_managers(sc_ana_in, EC_END, el3162_syncs)) {
+ if (ecrt_slave_config_pdos(sc_ana_in, EC_END, el3162_syncs)) {
printk(KERN_ERR PFX "Failed to configure Pdos.\n");
goto out_release_master;
}
@@ -331,7 +331,7 @@
goto out_release_master;
}
- if (ecrt_slave_config_sync_managers(sc, EC_END, el2004_syncs)) {
+ if (ecrt_slave_config_pdos(sc, EC_END, el2004_syncs)) {
printk(KERN_ERR PFX "Failed to configure Pdos.\n");
goto out_release_master;
}
--- a/examples/rtai/rtai_sample.c Wed Jul 02 12:19:25 2008 +0000
+++ b/examples/rtai/rtai_sample.c Wed Jul 02 14:06:10 2008 +0000
@@ -300,7 +300,7 @@
#ifdef CONFIGURE_PDOS
printk(KERN_INFO PFX "Configuring Pdos...\n");
- if (ecrt_slave_config_sync_managers(sc_ana_in, EC_END, el3162_syncs)) {
+ if (ecrt_slave_config_pdos(sc_ana_in, EC_END, el3162_syncs)) {
printk(KERN_ERR PFX "Failed to configure Pdos.\n");
goto out_release_master;
}
@@ -310,7 +310,7 @@
goto out_release_master;
}
- if (ecrt_slave_config_sync_managers(sc, EC_END, el2004_syncs)) {
+ if (ecrt_slave_config_pdos(sc, EC_END, el2004_syncs)) {
printk(KERN_ERR PFX "Failed to configure Pdos.\n");
goto out_release_master;
}
--- a/include/ecrt.h Wed Jul 02 12:19:25 2008 +0000
+++ b/include/ecrt.h Wed Jul 02 14:06:10 2008 +0000
@@ -125,12 +125,16 @@
/*****************************************************************************/
-/** End of the Pdo entry list.
- *
- * This is used in ecrt_slave_config_pdos().
+/** End of list marker.
+ *
+ * This can be used with ecrt_slave_config_pdos().
*/
#define EC_END ~0U
+/** Maximum number of sync managers per slave.
+ */
+#define EC_MAX_SYNC_MANAGERS 16
+
/******************************************************************************
* Data types
*****************************************************************************/
@@ -232,7 +236,7 @@
*
* This is the data type of the \a entries field in ec_pdo_info_t.
*
- * \see ecrt_slave_config_sync_managers().
+ * \see ecrt_slave_config_pdos().
*/
typedef struct {
uint16_t index; /**< Pdo entry index. */
@@ -246,11 +250,11 @@
*
* This is the data type of the \a pdos field in ec_sync_info_t.
*
- * \see ecrt_slave_config_sync_managers().
+ * \see ecrt_slave_config_pdos().
*/
typedef struct {
uint16_t index; /**< Pdo index. */
- uint8_t n_entries; /**< Number of Pdo entries in \a entries to map.
+ unsigned int n_entries; /**< Number of Pdo entries in \a entries to map.
Zero means, that the default mapping shall be
used (this can only be done if the slave is
present at bus configuration time). */
@@ -265,12 +269,12 @@
*
* This can be use to configure multiple sync managers including the Pdo
* assignment and Pdo mapping. It is used as an input parameter type in
- * ecrt_slave_config_sync_managers().
+ * ecrt_slave_config_pdos().
*/
typedef struct {
uint8_t index; /**< Sync manager index. */
ec_direction_t dir; /**< Sync manager direction. */
- uint16_t n_pdos; /**< Number of Pdos in \a pdos. */
+ unsigned int n_pdos; /**< Number of Pdos in \a pdos. */
ec_pdo_info_t *pdos; /**< Array with Pdos to assign. This must contain
at least \a n_pdos Pdos. */
} ec_sync_info_t;
@@ -447,20 +451,21 @@
/** Configure a sync manager.
*
- * Sets the direction of a sync manager. The direction bits from the default
- * control register from SII will be overriden, when this function is called.
+ * Sets the direction of a sync manager. This overrides the direction bits
+ * from the default control register from SII.
*
* \return zero on success, else non-zero
*/
int ecrt_slave_config_sync_manager(
ec_slave_config_t *sc, /**< Slave configuration. */
- uint8_t sync_index, /**< Sync manager index. */
+ uint8_t sync_index, /**< Sync manager index. Must ba less
+ than #EC_MAX_SYNC_MANAGERS. */
ec_direction_t dir /**< Input/Output. */
);
/** Add a Pdo to a sync manager's Pdo assignment.
*
- * \see ecrt_slave_config_sync_managers()
+ * \see ecrt_slave_config_pdos()
* \return zero on success, else non-zero
*/
int ecrt_slave_config_pdo_assign_add(
@@ -475,7 +480,7 @@
* ecrt_slave_config_pdo_assign_add(), to clear the default assignment of a
* sync manager.
*
- * \see ecrt_slave_config_sync_managers()
+ * \see ecrt_slave_config_pdos()
*/
void ecrt_slave_config_pdo_assign_clear(
ec_slave_config_t *sc, /**< Slave configuration. */
@@ -484,7 +489,7 @@
/** Add a Pdo entry to the given Pdo's mapping.
*
- * \see ecrt_slave_config_sync_managers()
+ * \see ecrt_slave_config_pdos()
* \return zero on success, else non-zero
*/
int ecrt_slave_config_pdo_mapping_add(
@@ -502,7 +507,7 @@
* This can be called before mapping Pdo entries via
* ecrt_slave_config_pdo_mapping_add(), to clear the default mapping.
*
- * \see ecrt_slave_config_sync_managers()
+ * \see ecrt_slave_config_pdos()
*/
void ecrt_slave_config_pdo_mapping_clear(
ec_slave_config_t *sc, /**< Slave configuration. */
@@ -523,27 +528,30 @@
* configuration time:
*
* \code
- * const ec_pdo_entry_info_t el3162_channel1[] = {
+ * ec_pdo_entry_info_t el3162_channel1[] = {
* {0x3101, 1, 8}, // status
* {0x3101, 2, 16} // value
* };
*
- * const ec_pdo_entry_info_t el3162_channel2[] = {
+ * ec_pdo_entry_info_t el3162_channel2[] = {
* {0x3102, 1, 8}, // status
* {0x3102, 2, 16} // value
* };
*
- * const ec_pdo_info_t el3162_pdos[] = {
+ * ec_pdo_info_t el3162_pdos[] = {
* {0x1A00, 2, el3162_channel1},
- * {0x1A01, 2, el3162_channel2},
+ * {0x1A01, 2, el3162_channel2}
* };
*
- * const ec_pdo_info_t el3162_syncs[] = {
- * {2, EC_DIR_INPUT, 2, el3162_el3162_pdos},
+ * ec_sync_info_t el3162_syncs[] = {
+ * {2, EC_DIR_OUTPUT},
+ * {3, EC_DIR_INPUT, 2, el3162_pdos},
+ * {0xff}
* };
*
- * if (ecrt_slave_config_syncs(sc, 1, el3162_syncs))
- * return -1; // error
+ * if (ecrt_slave_config_pdos(sc_ana_in, EC_END, el3162_syncs)) {
+ * // handle error
+ * }
* \endcode
*
* The next example shows, how to configure the Pdo assignment only. The
@@ -552,17 +560,18 @@
* configuration is left empty and the slave is offline.
*
* \code
- * const ec_pdo_info_t pdos[] = {
+ * ec_pdo_info_t pdos[] = {
* {0x1600}, // Channel 1
* {0x1601} // Channel 2
* };
*
- * const ec_sync_info_t syncs[] = {
- * {2, EC_DIR_INPUT, 2, pdos},
+ * ec_sync_info_t syncs[] = {
+ * {3, EC_DIR_INPUT, 2, pdos},
* };
*
- * if (ecrt_slave_config_pdos(slave_config_ana_in, 2, syncs))
- * return -1; // error
+ * if (ecrt_slave_config_pdos(slave_config_ana_in, 1, syncs)) {
+ * // handle error
+ * }
* \endcode
*
* Processing of \a syncs will stop, if
@@ -573,7 +582,7 @@
*
* \return zero on success, else non-zero
*/
-int ecrt_slave_config_sync_managers(
+int ecrt_slave_config_pdos(
ec_slave_config_t *sc, /**< Slave configuration. */
unsigned int n_syncs, /**< Number of sync manager configurations in
\a syncs. */
--- a/master/cdev.c Wed Jul 02 12:19:25 2008 +0000
+++ b/master/cdev.c Wed Jul 02 14:06:10 2008 +0000
@@ -1000,7 +1000,7 @@
data.position = sc->position;
data.vendor_id = sc->vendor_id;
data.product_code = sc->product_code;
- for (i = 0; i < EC_MAX_SYNCS; i++) {
+ for (i = 0; i < EC_MAX_SYNC_MANAGERS; i++) {
data.syncs[i].dir = sc->sync_configs[i].dir;
data.syncs[i].pdo_count =
ec_pdo_list_count(&sc->sync_configs[i].pdos);
@@ -1035,7 +1035,7 @@
return -EFAULT;
}
- if (data.sync_index >= EC_MAX_SYNCS) {
+ if (data.sync_index >= EC_MAX_SYNC_MANAGERS) {
EC_ERR("Invalid sync manager index %u!\n",
data.sync_index);
return -EINVAL;
@@ -1095,7 +1095,7 @@
return -EFAULT;
}
- if (data.sync_index >= EC_MAX_SYNCS) {
+ if (data.sync_index >= EC_MAX_SYNC_MANAGERS) {
EC_ERR("Invalid sync manager index %u!\n",
data.sync_index);
return -EINVAL;
--- a/master/fsm_coe_map.c Wed Jul 02 12:19:25 2008 +0000
+++ b/master/fsm_coe_map.c Wed Jul 02 14:06:10 2008 +0000
@@ -157,7 +157,7 @@
fsm->sync_index++;
- for (; fsm->sync_index < EC_MAX_SYNCS; fsm->sync_index++) {
+ for (; fsm->sync_index < EC_MAX_SYNC_MANAGERS; fsm->sync_index++) {
if (!(fsm->sync = ec_slave_get_sync(slave, fsm->sync_index)))
continue;
--- a/master/fsm_pdo_assign.c Wed Jul 02 12:19:25 2008 +0000
+++ b/master/fsm_pdo_assign.c Wed Jul 02 14:06:10 2008 +0000
@@ -166,7 +166,7 @@
{
fsm->sync_index++;
- for (; fsm->sync_index < EC_MAX_SYNCS; fsm->sync_index++) {
+ for (; fsm->sync_index < EC_MAX_SYNC_MANAGERS; fsm->sync_index++) {
fsm->pdos = &fsm->slave->config->sync_configs[fsm->sync_index].pdos;
if (!(fsm->sync = ec_slave_get_sync(fsm->slave, fsm->sync_index))) {
--- a/master/fsm_pdo_mapping.c Wed Jul 02 12:19:25 2008 +0000
+++ b/master/fsm_pdo_mapping.c Wed Jul 02 14:06:10 2008 +0000
@@ -165,7 +165,7 @@
const ec_pdo_list_t *pdos;
const ec_pdo_t *pdo, *assigned_pdo;
- for (sync_index = 0; sync_index < EC_MAX_SYNCS; sync_index++) {
+ for (sync_index = 0; sync_index < EC_MAX_SYNC_MANAGERS; sync_index++) {
pdos = &fsm->slave->config->sync_configs[sync_index].pdos;
list_for_each_entry(pdo, &pdos->list, list) {
--- a/master/globals.h Wed Jul 02 12:19:25 2008 +0000
+++ b/master/globals.h Wed Jul 02 14:06:10 2008 +0000
@@ -93,9 +93,6 @@
/** Maximum number of slave ports. */
#define EC_MAX_PORTS 4
-/** Maximum number of sync managers per slave. */
-#define EC_MAX_SYNCS 16
-
/** Size of a sync manager configuration page. */
#define EC_SYNC_PAGE_SIZE 8
--- a/master/ioctl.h Wed Jul 02 12:19:25 2008 +0000
+++ b/master/ioctl.h Wed Jul 02 14:06:10 2008 +0000
@@ -47,6 +47,8 @@
/*****************************************************************************/
+/** \cond */
+
#define EC_IOCTL_TYPE 0xa4
#define EC_IO(nr) _IO(EC_IOCTL_TYPE, nr)
@@ -294,11 +296,10 @@
struct {
ec_direction_t dir;
uint32_t pdo_count;
- } syncs[16];
+ } syncs[EC_MAX_SYNC_MANAGERS];
uint32_t sdo_count;
uint8_t attached : 1,
operational : 1;
-
} ec_ioctl_config_t;
/*****************************************************************************/
@@ -347,4 +348,6 @@
/*****************************************************************************/
+/** \endcond */
+
#endif
--- a/master/master.c Wed Jul 02 12:19:25 2008 +0000
+++ b/master/master.c Wed Jul 02 14:06:10 2008 +0000
@@ -1122,6 +1122,9 @@
/*****************************************************************************/
+/** Common implementation for ec_master_find_domain() and
+ * ec_master_find_domain_const().
+ */
#define EC_FIND_DOMAIN \
do { \
list_for_each_entry(domain, &master->domains, list) { \
@@ -1142,8 +1145,6 @@
EC_FIND_DOMAIN;
}
-/*****************************************************************************/
-
const ec_domain_t *ec_master_find_domain_const(
const ec_master_t *master, /**< EtherCAT master. */
unsigned int index /**< Domain index. */
--- a/master/slave.c Wed Jul 02 12:19:25 2008 +0000
+++ b/master/slave.c Wed Jul 02 14:06:10 2008 +0000
@@ -365,7 +365,7 @@
if (count) {
total_count = count + slave->sii.sync_count;
- if (total_count > EC_MAX_SYNCS) {
+ if (total_count > EC_MAX_SYNC_MANAGERS) {
EC_ERR("Exceeded maximum number of sync managers!\n");
return -1;
}
--- a/master/slave_config.c Wed Jul 02 12:19:25 2008 +0000
+++ b/master/slave_config.c Wed Jul 02 14:06:10 2008 +0000
@@ -70,7 +70,7 @@
sc->product_code = product_code;
sc->slave = NULL;
- for (i = 0; i < EC_MAX_SYNCS; i++)
+ for (i = 0; i < EC_MAX_SYNC_MANAGERS; i++)
ec_sync_config_init(&sc->sync_configs[i]);
INIT_LIST_HEAD(&sc->sdo_configs);
@@ -95,7 +95,7 @@
ec_slave_config_detach(sc);
// Free sync managers
- for (i = 0; i < EC_MAX_SYNCS; i++)
+ for (i = 0; i < EC_MAX_SYNC_MANAGERS; i++)
ec_sync_config_clear(&sc->sync_configs[i]);
// free all Sdo configurations
@@ -242,7 +242,7 @@
if (!sc->slave)
return;
- for (sync_index = 0; sync_index < EC_MAX_SYNCS; sync_index++) {
+ for (sync_index = 0; sync_index < EC_MAX_SYNC_MANAGERS; sync_index++) {
sync_config = &sc->sync_configs[sync_index];
if ((sync = ec_slave_get_sync(sc->slave, sync_index))) {
sync_config->dir = ec_sync_default_direction(sync);
@@ -361,7 +361,7 @@
EC_DBG("ecrt_slave_config_sync_manager(sc = 0x%x, sync_index = %u, "
"dir = %u)\n", (u32) sc, sync_index, dir);
- if (sync_index >= EC_MAX_SYNCS) {
+ if (sync_index >= EC_MAX_SYNC_MANAGERS) {
EC_ERR("Invalid sync manager index %u!\n", sync_index);
return -1;
}
@@ -387,7 +387,7 @@
EC_DBG("ecrt_slave_config_pdo_assign_add(sc = 0x%x, sync_index = %u, "
"pdo_index = 0x%04X)\n", (u32) sc, sync_index, pdo_index);
- if (sync_index >= EC_MAX_SYNCS) {
+ if (sync_index >= EC_MAX_SYNC_MANAGERS) {
EC_ERR("Invalid sync manager index %u!\n", sync_index);
return -1;
}
@@ -416,7 +416,7 @@
EC_DBG("ecrt_slave_config_pdo_assign_clear(sc = 0x%x, "
"sync_index = %u)\n", (u32) sc, sync_index);
- if (sync_index >= EC_MAX_SYNCS) {
+ if (sync_index >= EC_MAX_SYNC_MANAGERS) {
EC_ERR("Invalid sync manager index %u!\n", sync_index);
return;
}
@@ -443,7 +443,7 @@
(u32) sc, pdo_index, entry_index, entry_subindex,
entry_bit_length);
- for (sync_index = 0; sync_index < EC_MAX_SYNCS; sync_index++)
+ for (sync_index = 0; sync_index < EC_MAX_SYNC_MANAGERS; sync_index++)
if ((pdo = ec_pdo_list_find_pdo(
&sc->sync_configs[sync_index].pdos, pdo_index)))
break;
@@ -473,7 +473,7 @@
EC_DBG("ecrt_slave_config_pdo_mapping_clear(sc = 0x%x, "
"pdo_index = 0x%04X)\n", (u32) sc, pdo_index);
- for (sync_index = 0; sync_index < EC_MAX_SYNCS; sync_index++)
+ for (sync_index = 0; sync_index < EC_MAX_SYNC_MANAGERS; sync_index++)
if ((pdo = ec_pdo_list_find_pdo(
&sc->sync_configs[sync_index].pdos, pdo_index)))
break;
@@ -490,7 +490,7 @@
/*****************************************************************************/
-int ecrt_slave_config_sync_managers(ec_slave_config_t *sc,
+int ecrt_slave_config_pdos(ec_slave_config_t *sc,
unsigned int n_syncs, const ec_sync_info_t syncs[])
{
unsigned int i, j, k;
@@ -499,7 +499,7 @@
const ec_pdo_entry_info_t *entry_info;
if (sc->master->debug_level)
- EC_DBG("ecrt_slave_config_sync_managers(sc = 0x%x, n_syncs = %u, "
+ EC_DBG("ecrt_slave_config_pdos(sc = 0x%x, n_syncs = %u, "
"syncs = 0x%x)\n", (u32) sc, n_syncs, (u32) syncs);
if (!syncs)
@@ -511,7 +511,7 @@
if (sync_info->index == 0xff)
break;
- if (sync_info->index >= EC_MAX_SYNCS) {
+ if (sync_info->index >= EC_MAX_SYNC_MANAGERS) {
EC_ERR("Invalid sync manager index %u!\n", sync_info->index);
return -1;
}
@@ -572,7 +572,7 @@
"subindex = 0x%02X, domain = 0x%x, bit_position = 0x%x)\n",
(u32) sc, index, subindex, (u32) domain, (u32) bit_position);
- for (sync_index = 0; sync_index < EC_MAX_SYNCS; sync_index++) {
+ for (sync_index = 0; sync_index < EC_MAX_SYNC_MANAGERS; sync_index++) {
sync_config = &sc->sync_configs[sync_index];
bit_offset = 0;
@@ -731,7 +731,7 @@
EXPORT_SYMBOL(ecrt_slave_config_pdo_assign_clear);
EXPORT_SYMBOL(ecrt_slave_config_pdo_mapping_add);
EXPORT_SYMBOL(ecrt_slave_config_pdo_mapping_clear);
-EXPORT_SYMBOL(ecrt_slave_config_sync_managers);
+EXPORT_SYMBOL(ecrt_slave_config_pdos);
EXPORT_SYMBOL(ecrt_slave_config_reg_pdo_entry);
EXPORT_SYMBOL(ecrt_slave_config_sdo);
EXPORT_SYMBOL(ecrt_slave_config_sdo8);
--- a/master/slave_config.h Wed Jul 02 12:19:25 2008 +0000
+++ b/master/slave_config.h Wed Jul 02 14:06:10 2008 +0000
@@ -67,7 +67,7 @@
ec_slave_t *slave; /**< Slave pointer. This is \a NULL, if the slave is
offline. */
- ec_sync_config_t sync_configs[EC_MAX_SYNCS]; /**< Sync manager
+ ec_sync_config_t sync_configs[EC_MAX_SYNC_MANAGERS]; /**< Sync manager
configurations. */
ec_fmmu_config_t fmmu_configs[EC_MAX_FMMUS]; /**< FMMU configurations. */
uint8_t used_fmmus; /**< Number of FMMUs used. */
--- a/tools/Master.cpp Wed Jul 02 12:19:25 2008 +0000
+++ b/tools/Master.cpp Wed Jul 02 14:06:10 2008 +0000
@@ -1001,7 +1001,7 @@
<< "Attached: " << (config.attached ? "yes" : "no") << endl
<< "Operational: " << (config.operational ? "yes" : "no") << endl;
- for (j = 0; j < 16; j++) {
+ for (j = 0; j < EC_MAX_SYNC_MANAGERS; j++) {
if (config.syncs[j].pdo_count) {
cout << "SM" << dec << j << " ("
<< (config.syncs[j].dir == EC_DIR_INPUT