Skip to content

Commit ac813f7

Browse files
mcbedyguel
authored andcommitted
fixed broken iomapping addressing
1 parent dec0c95 commit ac813f7

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

ethercat_master/ethercat_master_etherlab/src/ec_master_etherlab.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,12 +328,16 @@ void EtherlabMaster::update(uint32_t domain)
328328

329329
// read and write process data
330330
for (DomainInfo::Entry & entry : domain_info->entries) {
331+
int channel_counter = 0;
331332
for (auto mi = 0ul; mi < (entry.slave)->get_pdo_config().size(); mi++) {
332333
for (auto ci = 0ul; ci < (entry.slave)->get_pdo_config()[mi].pdo_channel_config.size();
333334
ci++)
334335
{
335336
if ((entry.slave)->get_pdo_config()[mi].pdo_channel_config[ci].index != 0x0000) {
336-
(entry.slave)->process_data(mi, ci, domain_info->domain_pd + entry.offset[mi + ci]);
337+
(entry.slave)->process_data(
338+
mi, ci,
339+
domain_info->domain_pd + entry.offset[channel_counter]);
340+
channel_counter++;
337341
}
338342
}
339343
}
@@ -373,12 +377,16 @@ bool EtherlabMaster::read_process_data()
373377

374378
// read and write process data
375379
for (DomainInfo::Entry & entry : domain_info->entries) {
380+
int channel_counter = 0;
376381
for (auto mi = 0ul; mi < (entry.slave)->get_pdo_config().size(); mi++) {
377382
for (auto ci = 0ul; ci < (entry.slave)->get_pdo_config()[mi].pdo_channel_config.size();
378383
ci++)
379384
{
380385
if ((entry.slave)->get_pdo_config()[mi].pdo_channel_config[ci].index != 0x0000) {
381-
(entry.slave)->process_data(mi, ci, domain_info->domain_pd + entry.offset[mi + ci]);
386+
(entry.slave)->process_data(
387+
mi, ci,
388+
domain_info->domain_pd + entry.offset[channel_counter]);
389+
channel_counter++;
382390
}
383391
}
384392
}
@@ -393,12 +401,16 @@ bool EtherlabMaster::write_process_data()
393401
DomainInfo * domain_info = domain_info_[0];
394402
// read and write process data
395403
for (DomainInfo::Entry & entry : domain_info->entries) {
404+
int channel_counter = 0;
396405
for (auto mi = 0ul; mi < (entry.slave)->get_pdo_config().size(); mi++) {
397406
for (auto ci = 0ul; ci < (entry.slave)->get_pdo_config()[mi].pdo_channel_config.size();
398407
ci++)
399408
{
400409
if ((entry.slave)->get_pdo_config()[mi].pdo_channel_config[ci].index != 0x0000) {
401-
(entry.slave)->process_data(mi, ci, domain_info->domain_pd + entry.offset[mi + ci]);
410+
(entry.slave)->process_data(
411+
mi, ci,
412+
domain_info->domain_pd + entry.offset[channel_counter]);
413+
channel_counter++;
402414
}
403415
}
404416
}

0 commit comments

Comments
 (0)