etherlab/plc_etherlab.c
changeset 2117 accc4cbca8d3
parent 2116 2b1980a038b1
child 2123 68beaf825a20
equal deleted inserted replaced
2116:2b1980a038b1 2117:accc4cbca8d3
    45 int __init_%(location)s(int argc,char **argv)
    45 int __init_%(location)s(int argc,char **argv)
    46 {
    46 {
    47     uint32_t abort_code;
    47     uint32_t abort_code;
    48     size_t result_size;
    48     size_t result_size;
    49     
    49     
    50 	master = ecrt_request_master(%(master_number)d);
    50     master = ecrt_request_master(%(master_number)d);
    51 	if (!master) {
    51     if (!master) {
    52         SLOGF(LOG_CRITICAL, "EtherCAT master request failed!");
    52         SLOGF(LOG_CRITICAL, "EtherCAT master request failed!");
    53         return -1;
    53         return -1;
    54     }
    54     }
    55 
    55 
    56 	if(!(domain1 = ecrt_master_create_domain(master))){
    56     if(!(domain1 = ecrt_master_create_domain(master))){
    57         SLOGF(LOG_CRITICAL, "EtherCAT Domain Creation failed!");
    57         SLOGF(LOG_CRITICAL, "EtherCAT Domain Creation failed!");
    58         goto ecat_failed;
    58         goto ecat_failed;
    59     }
    59     }
    60 
    60 
    61     // slaves PDO configuration
    61     // slaves PDO configuration
    64     if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs)) {
    64     if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs)) {
    65         SLOGF(LOG_CRITICAL, "EtherCAT PDO registration failed!");
    65         SLOGF(LOG_CRITICAL, "EtherCAT PDO registration failed!");
    66         goto ecat_failed;
    66         goto ecat_failed;
    67     }
    67     }
    68 
    68 
    69 	ecrt_master_set_send_interval(master, common_ticktime__);
    69     ecrt_master_set_send_interval(master, common_ticktime__);
    70 
    70 
    71     // slaves initialization
    71     // slaves initialization
    72 %(slaves_initialization)s
    72 %(slaves_initialization)s
    73 
    73 
    74     // extracting default value for not mapped entry in output PDOs
    74     // extracting default value for not mapped entry in output PDOs
    89     first_sent = 0;
    89     first_sent = 0;
    90 
    90 
    91     return 0;
    91     return 0;
    92 
    92 
    93 ecat_failed:
    93 ecat_failed:
    94 	ecrt_release_master(master);
    94     ecrt_release_master(master);
    95     return -1;
    95     return -1;
    96 
    96 
    97 }
    97 }
    98 
    98 
    99 void __cleanup_%(location)s(void)
    99 void __cleanup_%(location)s(void)
   100 {
   100 {
   101 	//release master
   101     //release master
   102 	ecrt_release_master(master);
   102     ecrt_release_master(master);
   103     first_sent = 0;
   103     first_sent = 0;
   104 }
   104 }
   105 
   105 
   106 void __retrieve_%(location)s(void)
   106 void __retrieve_%(location)s(void)
   107 {
   107 {