master/slave_config.c
changeset 926 6bb33c6ec770
parent 925 939f3e9bba1e
child 927 ffb7d1876ce0
equal deleted inserted replaced
925:939f3e9bba1e 926:6bb33c6ec770
   257                 buf += sprintf(buf, "  %s 0x%04X \"%s\"\n",
   257                 buf += sprintf(buf, "  %s 0x%04X \"%s\"\n",
   258                         pdo->dir == EC_DIR_OUTPUT ? "RxPdo" : "TxPdo",
   258                         pdo->dir == EC_DIR_OUTPUT ? "RxPdo" : "TxPdo",
   259                         pdo->index, pdo->name ? pdo->name : "???");
   259                         pdo->index, pdo->name ? pdo->name : "???");
   260 
   260 
   261                 list_for_each_entry(entry, &pdo->entries, list) {
   261                 list_for_each_entry(entry, &pdo->entries, list) {
   262                     buf += sprintf(buf, "    0x%04X:%X \"%s\", %u bit\n",
   262                     buf += sprintf(buf, "    0x%04X:%02X \"%s\", %u bit\n",
   263                             entry->index, entry->subindex,
   263                             entry->index, entry->subindex,
   264                             entry->name ? entry->name : "???",
   264                             entry->name ? entry->name : "???",
   265                             entry->bit_length);
   265                             entry->bit_length);
   266                 }
   266                 }
   267             }
   267             }
   277                 case 1: sprintf(str, "%u", EC_READ_U8(req->data)); break;
   277                 case 1: sprintf(str, "%u", EC_READ_U8(req->data)); break;
   278                 case 2: sprintf(str, "%u", EC_READ_U16(req->data)); break;
   278                 case 2: sprintf(str, "%u", EC_READ_U16(req->data)); break;
   279                 case 4: sprintf(str, "%u", EC_READ_U32(req->data)); break;
   279                 case 4: sprintf(str, "%u", EC_READ_U32(req->data)); break;
   280                 default: sprintf(str, "(invalid size)"); break;
   280                 default: sprintf(str, "(invalid size)"); break;
   281             }
   281             }
   282             buf += sprintf(buf, "  0x%04X:%-3i -> %s\n",
   282             buf += sprintf(buf, "  0x%04X:%02X -> %s\n",
   283                     req->index, req->subindex, str);
   283                     req->index, req->subindex, str);
   284         }
   284         }
   285         buf += sprintf(buf, "\n");
   285         buf += sprintf(buf, "\n");
   286     }
   286     }
   287 
   287 
   288     // type-cast to avoid warnings on some compilers
   288     // type-cast to avoid warnings on some compilers
   289     if (!list_empty((struct list_head *) &sc->sdo_requests)) {
   289     if (!list_empty((struct list_head *) &sc->sdo_requests)) {
   290         buf += sprintf(buf, "\nSdo requests:\n");
   290         buf += sprintf(buf, "\nSdo requests:\n");
   291 
   291 
   292         list_for_each_entry(req, &sc->sdo_requests, list) {
   292         list_for_each_entry(req, &sc->sdo_requests, list) {
   293             buf += sprintf(buf, "  0x%04X:%u\n", req->index, req->subindex);
   293             buf += sprintf(buf, "  0x%04X:%02X\n", req->index, req->subindex);
   294         }
   294         }
   295         buf += sprintf(buf, "\n");
   295         buf += sprintf(buf, "\n");
   296     }
   296     }
   297 
   297 
   298     return buf - buffer;
   298     return buf - buffer;
   460             return;
   460             return;
   461 
   461 
   462         if (sc->master->debug_level) {
   462         if (sc->master->debug_level) {
   463             const ec_pdo_entry_t *entry;
   463             const ec_pdo_entry_t *entry;
   464             list_for_each_entry(entry, &pdo->entries, list) {
   464             list_for_each_entry(entry, &pdo->entries, list) {
   465                 EC_DBG("    Entry 0x%04X:%u.\n",
   465                 EC_DBG("    Entry 0x%04X:%02X.\n",
   466                         entry->index, entry->subindex);
   466                         entry->index, entry->subindex);
   467             }
   467             }
   468         }
   468         }
   469     }
   469     }
   470 }
   470 }
   510 {
   510 {
   511     ec_direction_t dir;
   511     ec_direction_t dir;
   512     ec_pdo_t *pdo;
   512     ec_pdo_t *pdo;
   513     
   513     
   514     if (sc->master->debug_level)
   514     if (sc->master->debug_level)
   515         EC_DBG("Adding Pdo entry 0x%04X:%u (%u bit) to mapping of Pdo"
   515         EC_DBG("Adding Pdo entry 0x%04X:%02X (%u bit) to mapping of Pdo"
   516                 " 0x%04X, config %u:%u.\n", entry_index, entry_subindex,
   516                 " 0x%04X, config %u:%u.\n", entry_index, entry_subindex,
   517                 entry_bit_length, pdo_index, sc->alias, sc->position);
   517                 entry_bit_length, pdo_index, sc->alias, sc->position);
   518 
   518 
   519     for (dir = EC_DIR_OUTPUT; dir <= EC_DIR_INPUT; dir++)
   519     for (dir = EC_DIR_OUTPUT; dir <= EC_DIR_INPUT; dir++)
   520         if ((pdo = ec_pdo_list_find_pdo(&sc->pdos[dir], pdo_index)))
   520         if ((pdo = ec_pdo_list_find_pdo(&sc->pdos[dir], pdo_index)))
   630                 }
   630                 }
   631             }
   631             }
   632         }
   632         }
   633     }
   633     }
   634 
   634 
   635     EC_ERR("Pdo entry 0x%04X:%u is not mapped in slave config %u:%u.\n",
   635     EC_ERR("Pdo entry 0x%04X:%02X is not mapped in slave config %u:%u.\n",
   636            index, subindex, sc->alias, sc->position);
   636            index, subindex, sc->alias, sc->position);
   637     return -1;
   637     return -1;
   638 
   638 
   639 found:
   639 found:
   640     sync_offset = ec_slave_config_prepare_fmmu(sc, domain, dir);
   640     sync_offset = ec_slave_config_prepare_fmmu(sc, domain, dir);
   643 
   643 
   644     bit_pos = bit_offset % 8;
   644     bit_pos = bit_offset % 8;
   645     if (bit_position) {
   645     if (bit_position) {
   646         *bit_position = bit_pos;
   646         *bit_position = bit_pos;
   647     } else if (bit_pos) {
   647     } else if (bit_pos) {
   648         EC_ERR("Pdo entry 0x%04X:%X does not byte-align in config %u:%u.\n",
   648         EC_ERR("Pdo entry 0x%04X:%02X does not byte-align in config %u:%u.\n",
   649                 index, subindex, sc->alias, sc->position);
   649                 index, subindex, sc->alias, sc->position);
   650         return -3;
   650         return -3;
   651     }
   651     }
   652 
   652 
   653     return sync_offset + bit_offset / 8;
   653     return sync_offset + bit_offset / 8;