#include <stdio.h>
#include <ethercat.h>
int main() {
if (ec_init("eth0") <= 0) {
fprintf(stderr, "Failed to initialize EtherCAT\n");
return 1;
}
if (ec_config_init(FALSE) <= 0) {
fprintf(stderr, "No EtherCAT slaves found\n");
ec_close();
return 1;
}
ec_config_map(&IOmap);
ec_configdc();
while (1) {
ec_send_processdata();
ec_receive_processdata(EC_TIMEOUTRET);
int torque = ec_slave[1].inputs[0];
printf("Torque: %d\n", torque);
usleep(500000);
}
ec_close();
return 0;
}
#include <stdio.h>
#include <ethercat.h>
int main() {
if (ec_init("eth0") <= 0) {
fprintf(stderr, "Failed to initialize EtherCAT\n");
return 1;
}
if (ec_config_init(FALSE) <= 0) {
fprintf(stderr, "No EtherCAT slaves found\n");
ec_close();
return 1;
}
ec_config_map(&IOmap);
ec_configdc();
while (1) {
ec_send_processdata();
ec_receive_processdata(EC_TIMEOUTRET);
int torque = ec_slave[1].inputs[0];
printf("Torque: %d\n", torque);
usleep(500000);
}
ec_close();
return 0;
}