21 |
21 |
22 // Optional features |
22 // Optional features |
23 #define CONFIGURE_PDOS %(configure_pdos)d |
23 #define CONFIGURE_PDOS %(configure_pdos)d |
24 |
24 |
25 // process data |
25 // process data |
26 static uint8_t *domain1_pd = NULL; |
26 uint8_t *domain1_pd = NULL; |
27 %(used_pdo_entry_offset_variables_declaration)s |
27 %(used_pdo_entry_offset_variables_declaration)s |
28 |
28 |
29 const static ec_pdo_entry_reg_t domain1_regs[] = { |
29 const static ec_pdo_entry_reg_t domain1_regs[] = { |
30 %(used_pdo_entry_configuration)s |
30 %(used_pdo_entry_configuration)s |
31 {} |
31 {} |
47 %(slaves_declaration)s |
47 %(slaves_declaration)s |
48 |
48 |
49 /* Beremiz plugin functions */ |
49 /* Beremiz plugin functions */ |
50 int __init_%(location)s(int argc,char **argv) |
50 int __init_%(location)s(int argc,char **argv) |
51 { |
51 { |
52 int rtstatus; |
52 uint32_t abort_code; |
53 |
53 int rtstatus; |
|
54 |
54 MstrAttach.masterindex = %(master_number)d; |
55 MstrAttach.masterindex = %(master_number)d; |
55 |
56 |
56 master = ecrt_request_master(MstrAttach.masterindex); |
57 master = ecrt_request_master(MstrAttach.masterindex); |
57 if (!master) return -1; |
58 if (!master) return -1; |
58 |
59 |
59 domain1 = ecrt_master_create_domain(master); |
60 domain1 = ecrt_master_create_domain(master); |
60 if (!domain1) return -1; |
61 if (!domain1) return -1; |
61 |
62 |
62 #if CONFIGURE_PDOS |
63 #if CONFIGURE_PDOS |
|
64 fprintf(stdout, "Configure PDOs...\n"); |
63 %(slaves_configuration)s |
65 %(slaves_configuration)s |
64 #endif |
66 #endif |
65 |
67 |
66 if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs)) { |
68 if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs)) { |
67 fprintf(stderr, "PDO entry registration failed!\n"); |
69 fprintf(stderr, "PDO entry registration failed!\n"); |
68 return -1; |
70 return -1; |
69 } |
71 } |
70 |
72 |
|
73 %(slaves_initialization)s |
|
74 |
71 sprintf(&rt_dev_file[0],"%%s%%u",EC_RTDM_DEV_FILE_NAME,0); |
75 sprintf(&rt_dev_file[0],"%%s%%u",EC_RTDM_DEV_FILE_NAME,0); |
72 rt_fd = rt_dev_open( &rt_dev_file[0], 0); |
76 rt_fd = rt_dev_open( &rt_dev_file[0], 0); |
73 if (rt_fd < 0) { |
77 if (rt_fd < 0) { |
74 printf("Can't open %%s\n", &rt_dev_file[0]); |
78 fprintf(stderr, "Can't open %%s\n", &rt_dev_file[0]); |
75 return -1; |
79 return -1; |
76 } |
80 } |
77 |
81 |
78 // attach the master over rtdm driver |
82 // attach the master over rtdm driver |
79 MstrAttach.domainindex = ecrt_domain_index(domain1); |
83 MstrAttach.domainindex = ecrt_domain_index(domain1); |
80 rtstatus = ecrt_rtdm_master_attach(rt_fd, &MstrAttach); |
84 rtstatus = ecrt_rtdm_master_attach(rt_fd, &MstrAttach); |
81 if (rtstatus < 0) { |
85 if (rtstatus < 0) { |
82 printf("Cannot attach to master over rtdm\n"); |
86 fprintf(stderr, "Cannot attach to master over rtdm\n"); |
83 return -1; |
87 return -1; |
84 } |
88 } |
85 |
89 |
86 if (ecrt_master_activate(master)) |
90 if (ecrt_master_activate(master)) |
87 return -1; |
91 return -1; |