master/domain.c
branchstable-1.2
changeset 1739 5fcbd29151d2
parent 1732 1cc865ba17c2
child 1744 7bc131b92039
equal deleted inserted replaced
1738:bc89e3fba1a5 1739:5fcbd29151d2
   477 }
   477 }
   478 
   478 
   479 /*****************************************************************************/
   479 /*****************************************************************************/
   480 
   480 
   481 /**
   481 /**
   482    Places all process data datagrams in the masters datagram queue.
       
   483 */
       
   484 
       
   485 void ec_domain_queue_datagrams(ec_domain_t *domain /**< EtherCAT domain */)
       
   486 {
       
   487     ec_datagram_t *datagram;
       
   488 
       
   489     list_for_each_entry(datagram, &domain->datagrams, list) {
       
   490         ec_master_queue_datagram(domain->master, datagram);
       
   491     }
       
   492 }
       
   493 
       
   494 /*****************************************************************************/
       
   495 
       
   496 /**
       
   497    Formats attribute data for SysFS reading.
   482    Formats attribute data for SysFS reading.
   498    \return number of bytes to read
   483    \return number of bytes to read
   499 */
   484 */
   500 
   485 
   501 ssize_t ec_show_domain_attribute(struct kobject *kobj, /**< kobject */
   486 ssize_t ec_show_domain_attribute(struct kobject *kobj, /**< kobject */
   516  *  Realtime interface
   501  *  Realtime interface
   517  *****************************************************************************/
   502  *****************************************************************************/
   518 
   503 
   519 /**
   504 /**
   520    Registers a PDO in a domain.
   505    Registers a PDO in a domain.
   521    - If \a data_ptr is NULL, the slave is only validated.
       
   522    \return pointer to the slave on success, else NULL
   506    \return pointer to the slave on success, else NULL
   523    \ingroup RealtimeInterface
   507    \ingroup RealtimeInterface
   524 */
   508 */
   525 
   509 
   526 ec_slave_t *ecrt_domain_register_pdo(ec_domain_t *domain,
   510 ec_slave_t *ecrt_domain_register_pdo(ec_domain_t *domain,
   550 
   534 
   551     // translate address and validate slave
   535     // translate address and validate slave
   552     if (!(slave = ecrt_master_get_slave(master, address))) return NULL;
   536     if (!(slave = ecrt_master_get_slave(master, address))) return NULL;
   553     if (ec_slave_validate(slave, vendor_id, product_code)) return NULL;
   537     if (ec_slave_validate(slave, vendor_id, product_code)) return NULL;
   554 
   538 
   555     if (!data_ptr) return slave;
       
   556 
       
   557     list_for_each_entry(pdo, &slave->sii_pdos, list) {
   539     list_for_each_entry(pdo, &slave->sii_pdos, list) {
   558         list_for_each_entry(entry, &pdo->entries, list) {
   540         list_for_each_entry(entry, &pdo->entries, list) {
   559             if (entry->index != pdo_index
   541             if (entry->index != pdo_index
   560                 || entry->subindex != pdo_subindex) continue;
   542                 || entry->subindex != pdo_subindex) continue;
   561 
   543 
   574 
   556 
   575 /*****************************************************************************/
   557 /*****************************************************************************/
   576 
   558 
   577 /**
   559 /**
   578    Registeres a bunch of data fields.
   560    Registeres a bunch of data fields.
   579    Caution! The list has to be terminated with a NULL structure ({})!
   561    \attention The list has to be terminated with a NULL structure ({})!
   580    \return 0 in case of success, else < 0
   562    \return 0 in case of success, else < 0
   581    \ingroup RealtimeInterface
   563    \ingroup RealtimeInterface
   582 */
   564 */
   583 
   565 
   584 int ecrt_domain_register_pdo_list(ec_domain_t *domain,
   566 int ecrt_domain_register_pdo_list(ec_domain_t *domain,
   603 
   585 
   604 /*****************************************************************************/
   586 /*****************************************************************************/
   605 
   587 
   606 /**
   588 /**
   607    Registers a PDO range in a domain.
   589    Registers a PDO range in a domain.
   608    - If \a data_ptr is NULL, the slave is only validated.
       
   609    \return pointer to the slave on success, else NULL
   590    \return pointer to the slave on success, else NULL
   610    \ingroup RealtimeInterface
   591    \ingroup RealtimeInterface
   611 */
   592 */
   612 
   593 
   613 ec_slave_t *ecrt_domain_register_pdo_range(ec_domain_t *domain,
   594 ec_slave_t *ecrt_domain_register_pdo_range(ec_domain_t *domain,
   637 
   618 
   638     // translate address and validate slave
   619     // translate address and validate slave
   639     if (!(slave = ecrt_master_get_slave(master, address))) return NULL;
   620     if (!(slave = ecrt_master_get_slave(master, address))) return NULL;
   640     if (ec_slave_validate(slave, vendor_id, product_code)) return NULL;
   621     if (ec_slave_validate(slave, vendor_id, product_code)) return NULL;
   641 
   622 
   642     if (!data_ptr) return slave;
       
   643 
       
   644     if (ec_domain_reg_pdo_range(domain, slave,
   623     if (ec_domain_reg_pdo_range(domain, slave,
   645                                 direction, offset, length, data_ptr)) {
   624                                 direction, offset, length, data_ptr)) {
   646         return NULL;
   625         return NULL;
   647     }
   626     }
   648 
   627 
   689                     domain->index, domain->working_counter_changes,
   668                     domain->index, domain->working_counter_changes,
   690                     domain->response_count);
   669                     domain->response_count);
   691         }
   670         }
   692         domain->working_counter_changes = 0;
   671         domain->working_counter_changes = 0;
   693     }
   672     }
   694 
   673 }
   695     ec_domain_queue_datagrams(domain);
   674 
       
   675 /*****************************************************************************/
       
   676 
       
   677 /**
       
   678    Places all process data datagrams in the masters datagram queue.
       
   679    \ingroup RealtimeInterface
       
   680 */
       
   681 
       
   682 void ecrt_domain_queue(ec_domain_t *domain /**< EtherCAT domain */)
       
   683 {
       
   684     ec_datagram_t *datagram;
       
   685 
       
   686     list_for_each_entry(datagram, &domain->datagrams, list) {
       
   687         ec_master_queue_datagram(domain->master, datagram);
       
   688     }
   696 }
   689 }
   697 
   690 
   698 /*****************************************************************************/
   691 /*****************************************************************************/
   699 
   692 
   700 /**
   693 /**
   714 
   707 
   715 EXPORT_SYMBOL(ecrt_domain_register_pdo);
   708 EXPORT_SYMBOL(ecrt_domain_register_pdo);
   716 EXPORT_SYMBOL(ecrt_domain_register_pdo_list);
   709 EXPORT_SYMBOL(ecrt_domain_register_pdo_list);
   717 EXPORT_SYMBOL(ecrt_domain_register_pdo_range);
   710 EXPORT_SYMBOL(ecrt_domain_register_pdo_range);
   718 EXPORT_SYMBOL(ecrt_domain_process);
   711 EXPORT_SYMBOL(ecrt_domain_process);
       
   712 EXPORT_SYMBOL(ecrt_domain_queue);
   719 EXPORT_SYMBOL(ecrt_domain_state);
   713 EXPORT_SYMBOL(ecrt_domain_state);
   720 
   714 
   721 /** \endcond */
   715 /** \endcond */
   722 
   716 
   723 /*****************************************************************************/
   717 /*****************************************************************************/