equal
deleted
inserted
replaced
1 /****************************************************************************** |
1 /****************************************************************************** |
2 * |
2 * |
3 * $Id$ |
3 * $Id$ |
4 * |
4 * |
5 * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH |
5 * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH |
6 * |
6 * |
7 * This file is part of the IgH EtherCAT master userspace library. |
7 * This file is part of the IgH EtherCAT master userspace library. |
8 * |
8 * |
9 * The IgH EtherCAT master userspace library is free software; you can |
9 * The IgH EtherCAT master userspace library is free software; you can |
10 * redistribute it and/or modify it under the terms of the GNU Lesser General |
10 * redistribute it and/or modify it under the terms of the GNU Lesser General |
11 * Public License as published by the Free Software Foundation; version 2.1 |
11 * Public License as published by the Free Software Foundation; version 2.1 |
12 * of the License. |
12 * of the License. |
13 * |
13 * |
17 * GNU Lesser General Public License for more details. |
17 * GNU Lesser General Public License for more details. |
18 * |
18 * |
19 * You should have received a copy of the GNU Lesser General Public License |
19 * You should have received a copy of the GNU Lesser General Public License |
20 * along with the IgH EtherCAT master userspace library. If not, see |
20 * along with the IgH EtherCAT master userspace library. If not, see |
21 * <http://www.gnu.org/licenses/>. |
21 * <http://www.gnu.org/licenses/>. |
22 * |
22 * |
23 * --- |
23 * --- |
24 * |
24 * |
25 * The license mentioned above concerns the source code only. Using the |
25 * The license mentioned above concerns the source code only. Using the |
26 * EtherCAT technology and brand is only permitted in compliance with the |
26 * EtherCAT technology and brand is only permitted in compliance with the |
27 * industrial property and similar rights of Beckhoff Automation GmbH. |
27 * industrial property and similar rights of Beckhoff Automation GmbH. |
28 * |
28 * |
29 *****************************************************************************/ |
29 *****************************************************************************/ |
61 domain = malloc(sizeof(ec_domain_t)); |
61 domain = malloc(sizeof(ec_domain_t)); |
62 if (!domain) { |
62 if (!domain) { |
63 fprintf(stderr, "Failed to allocate memory.\n"); |
63 fprintf(stderr, "Failed to allocate memory.\n"); |
64 return 0; |
64 return 0; |
65 } |
65 } |
66 |
66 |
67 index = ioctl(master->fd, EC_IOCTL_CREATE_DOMAIN, NULL); |
67 index = ioctl(master->fd, EC_IOCTL_CREATE_DOMAIN, NULL); |
68 if (index == -1) { |
68 if (index == -1) { |
69 fprintf(stderr, "Failed to create domain: %s\n", strerror(errno)); |
69 fprintf(stderr, "Failed to create domain: %s\n", strerror(errno)); |
70 free(domain); |
70 free(domain); |
71 return 0; |
71 return 0; |
72 } |
72 } |
73 |
73 |
74 domain->index = (unsigned int) index; |
74 domain->index = (unsigned int) index; |
75 domain->master = master; |
75 domain->master = master; |
76 domain->process_data = NULL; |
76 domain->process_data = NULL; |
90 sc = malloc(sizeof(ec_slave_config_t)); |
90 sc = malloc(sizeof(ec_slave_config_t)); |
91 if (!sc) { |
91 if (!sc) { |
92 fprintf(stderr, "Failed to allocate memory.\n"); |
92 fprintf(stderr, "Failed to allocate memory.\n"); |
93 return 0; |
93 return 0; |
94 } |
94 } |
95 |
95 |
96 data.alias = alias; |
96 data.alias = alias; |
97 data.position = position; |
97 data.position = position; |
98 data.vendor_id = vendor_id; |
98 data.vendor_id = vendor_id; |
99 data.product_code = product_code; |
99 data.product_code = product_code; |
100 |
100 |
101 if (ioctl(master->fd, EC_IOCTL_CREATE_SLAVE_CONFIG, &data) == -1) { |
101 if (ioctl(master->fd, EC_IOCTL_CREATE_SLAVE_CONFIG, &data) == -1) { |
102 fprintf(stderr, "Failed to create slave config: %s\n", |
102 fprintf(stderr, "Failed to create slave config: %s\n", |
103 strerror(errno)); |
103 strerror(errno)); |
104 free(sc); |
104 free(sc); |
105 return 0; |
105 return 0; |
106 } |
106 } |
107 |
107 |
108 sc->master = master; |
108 sc->master = master; |
109 sc->index = data.config_index; |
109 sc->index = data.config_index; |
110 sc->alias = alias; |
110 sc->alias = alias; |
150 slave_info->product_code = data.product_code; |
150 slave_info->product_code = data.product_code; |
151 slave_info->revision_number = data.revision_number; |
151 slave_info->revision_number = data.revision_number; |
152 slave_info->serial_number = data.serial_number; |
152 slave_info->serial_number = data.serial_number; |
153 slave_info->alias = data.alias; |
153 slave_info->alias = data.alias; |
154 slave_info->current_on_ebus = data.current_on_ebus; |
154 slave_info->current_on_ebus = data.current_on_ebus; |
|
155 strncpy((char*) slave_info->ports, (char*) data.ports, sizeof(slave_info->ports)); |
155 slave_info->al_state = data.al_state; |
156 slave_info->al_state = data.al_state; |
156 slave_info->error_flag = data.error_flag; |
157 slave_info->error_flag = data.error_flag; |
157 slave_info->sync_count = data.sync_count; |
158 slave_info->sync_count = data.sync_count; |
158 slave_info->sdo_count = data.sdo_count; |
159 slave_info->sdo_count = data.sdo_count; |
159 strncpy(slave_info->name, data.name, EC_MAX_STRING_LENGTH); |
160 strncpy(slave_info->name, data.name, EC_MAX_STRING_LENGTH); |