#include #include #include const char *usage = "Usage: slaveinfo [options]\n" "\n" "This helper script scans the ethercat bus and prints an xml file of the\n" "slaves on the bus.\n" "\n" "Options:\n" " -h, --help show this help message and exit\n" " -d, --dcs write dcs serial numbers instead of positional info\n"; int main(int argc, char ** argv) { int i; int dcs=0; for (i=1; i\n"); printf(" \n"); printf(" \n", master_info.slave_count, master_info.link_up); int n; for(n = 0; n < master_info.slave_count; n++) { ec_slave_info_t slave_info; if(ecrt_master_get_slave(master, n, &slave_info) != 0) { fprintf(stderr, "can't get info for slave %d\n", n); continue; } #if 0 printf("position: %d\n", slave_info.position); /**< Offset of the slave in the ring. */ printf("vendor_id: %d\n", slave_info.vendor_id); /**< Vendor-ID stored on the slave. */ printf("product_code: %d\n", slave_info.product_code); /**< Product-Code stored on the slave. */ printf("revision_number: %d\n", slave_info.revision_number); /**< Revision-Number stored on the slave. */ printf("serial_number: %d\n", slave_info.serial_number); /**< Serial-Number stored on the slave. */ printf("alias: %d\n", slave_info.alias); /**< The slaves alias if not equal to 0. */ printf("current_on_ebus: %d\n", slave_info.current_on_ebus); /**< Used current in mA. */ printf("al_state: %d\n", slave_info.al_state); /**< Current state of the slave. */ printf("error_flag: %d\n", slave_info.error_flag); /**< Error flag for that slave. */ printf("sync_count: %d\n", slave_info.sync_count); /**< Number of sync managers. */ printf("sdo_count: %d\n", slave_info.sdo_count); /**< Number of SDOs. */ printf("name: %s\n", slave_info.name); /**< Name of the slave. */ #endif /* slave.info name shows a whole name such as */ /* EL2024 4K. Dig. Ausgang 24V, 2A rev 0x00110000 */ /* trim to the first space. */ /* There's a special case for the national instruments backplane */ #define NI9144_NAME "NI 9144" char *name; if (strcmp(slave_info.name, NI9144_NAME) == 0) name = slave_info.name; else name = strtok(slave_info.name, " "); if(name == NULL) { name = "NAME ERROR"; } printf(" \n", name, slave_info.revision_number); } printf("\n"); return 0; }