--- a/master/domain.c Tue Feb 02 14:10:52 2010 +0100
+++ b/master/domain.c Tue Feb 02 19:38:32 2010 +0100
@@ -203,6 +203,7 @@
unsigned int datagram_count;
unsigned int datagram_used[EC_DIR_COUNT];
ec_fmmu_config_t *fmmu;
+ ec_fmmu_config_t *fmmu_temp;
const ec_datagram_t *datagram;
int ret;
@@ -225,15 +226,21 @@
datagram_count = 0;
datagram_used[EC_DIR_OUTPUT] = 0;
datagram_used[EC_DIR_INPUT] = 0;
-
+ list_for_each_entry(fmmu_temp, &domain->fmmu_configs, list) {
+ ec_slave_config_t *sc = (ec_slave_config_t *)fmmu_temp->sc; // we have to remove the constness, sorry
+ sc->used_for_fmmu_datagram[fmmu_temp->dir] = 0;
+ }
list_for_each_entry(fmmu, &domain->fmmu_configs, list) {
// Correct logical FMMU address
fmmu->logical_start_address += base_address;
// Increment Input/Output counter to determine datagram types
// and calculate expected working counters
- datagram_used[fmmu->dir]++;
-
+ if (fmmu->sc->used_for_fmmu_datagram[fmmu->dir] == 0) {
+ ec_slave_config_t *sc = (ec_slave_config_t *)fmmu->sc;
+ datagram_used[fmmu->dir]++;
+ sc->used_for_fmmu_datagram[fmmu->dir] = 1;
+ }
// If the current FMMU's data do not fit in the current datagram,
// allocate a new one.
if (datagram_size + fmmu->data_size > EC_MAX_DATA_SIZE) {
@@ -248,6 +255,10 @@
datagram_count++;
datagram_used[EC_DIR_OUTPUT] = 0;
datagram_used[EC_DIR_INPUT] = 0;
+ list_for_each_entry(fmmu_temp, &domain->fmmu_configs, list) {
+ ec_slave_config_t *sc = (ec_slave_config_t *)fmmu_temp->sc;
+ sc->used_for_fmmu_datagram[fmmu_temp->dir] = 0;
+ }
}
datagram_size += fmmu->data_size;
--- a/master/slave_config.c Tue Feb 02 14:10:52 2010 +0100
+++ b/master/slave_config.c Tue Feb 02 19:38:32 2010 +0100
@@ -75,7 +75,8 @@
ec_sync_config_init(&sc->sync_configs[i]);
sc->used_fmmus = 0;
-
+ sc->used_for_fmmu_datagram[EC_DIR_INPUT] = 0;
+ sc->used_for_fmmu_datagram[EC_DIR_OUTPUT] = 0;
sc->dc_assign_activate = 0x0000;
sc->dc_sync[0].cycle_time = 0x00000000;
sc->dc_sync[1].cycle_time = 0x00000000;
--- a/master/slave_config.h Tue Feb 02 14:10:52 2010 +0100
+++ b/master/slave_config.h Tue Feb 02 19:38:32 2010 +0100
@@ -70,7 +70,7 @@
configurations. */
ec_fmmu_config_t fmmu_configs[EC_MAX_FMMUS]; /**< FMMU configurations. */
uint8_t used_fmmus; /**< Number of FMMUs used. */
-
+ unsigned int used_for_fmmu_datagram[EC_DIR_COUNT];
uint16_t dc_assign_activate; /**< Vendor-specific AssignActivate word. */
ec_sync_signal_t dc_sync[EC_SYNC_SIGNAL_COUNT]; /**< DC sync signals. */
--- a/master/sync.c Tue Feb 02 14:10:52 2010 +0100
+++ b/master/sync.c Tue Feb 02 19:38:32 2010 +0100
@@ -99,8 +99,10 @@
uint8_t *data /**> Configuration memory. */
)
{
- // enable only if SII enable is set and size is > 0.
- uint16_t enable = sync->enable && data_size;
+ // enable only if SII enable is set and size is > 0 and SM is not virtual
+ uint16_t enable = (sync->enable & 0x01)
+ && data_size
+ && ((sync->enable & 0x04) == 0);
uint8_t control = sync->control_register;
if (sync_config) {