28 #define EC_TIMEOUTMON 500 40 int i,
j, oloop, iloop, wkc_count, chk;
44 printf(
"Starting simple test\n");
49 printf(
"ec_init on %s succeeded.\n",ifname);
61 printf(
"Slaves mapped, state to SAFE_OP.\n");
66 if ((oloop == 0) && (
ec_slave[0].Obits > 0)) oloop = 1;
67 if (oloop > 8) oloop = 8;
69 if ((iloop == 0) && (
ec_slave[0].Ibits > 0)) iloop = 1;
70 if (iloop > 8) iloop = 8;
74 printf(
"Request operational state for all slaves\n");
94 printf(
"Operational state reached for all slaves.\n");
98 for(i = 1; i <= 10000; i++)
105 printf(
"Processdata cycle %4d, WKC %d , O:", i,
wkc);
107 for(j = 0 ; j < oloop; j++)
109 printf(
" %2.2x", *(
ec_slave[0].outputs + j));
113 for(j = 0 ; j < iloop; j++)
115 printf(
" %2.2x", *(
ec_slave[0].inputs + j));
127 printf(
"Not all slaves reached operational state.\n");
133 printf(
"Slave %d State=0x%2.2x StatusCode=0x%4.4x : %s\n",
138 printf(
"\nRequest init state for all slaves\n");
145 printf(
"No slaves found!\n");
147 printf(
"End simple test, close socket\n");
153 printf(
"No socket connection on %s\nExcecute as root\n",ifname);
180 printf(
"ERROR : slave %d is in SAFE_OP + ERROR, attempting ack.\n", slave);
186 printf(
"WARNING : slave %d is in SAFE_OP, change to OPERATIONAL.\n", slave);
195 printf(
"MESSAGE : slave %d reconfigured\n",slave);
205 printf(
"ERROR : slave %d lost\n",slave);
216 printf(
"MESSAGE : slave %d recovered\n",slave);
222 printf(
"MESSAGE : slave %d found\n",slave);
227 printf(
"OK : all slaves resumed OPERATIONAL.\n");
233 int main(
int argc,
char *argv[])
236 printf(
"SOEM (Simple Open EtherCAT Master)\nSimple test\n");
241 iret1 = pthread_create( &
thread1, NULL, (
void *) &
ecatcheck, (
void*) &ctime);
247 printf(
"Usage: simple_test ifname1\nifname = eth0 for example\n");
250 printf(
"End program\n");
ec_groupt ec_group[EC_MAXGROUP]
int ec_reconfig_slave(uint16 slave, int timeout)
char * ec_ALstatuscode2string(uint16 ALstatuscode)
Headerfile for ethercatdc.c.
int ec_send_processdata(void)
PACKED_END ec_slavet ec_slave[EC_MAXSLAVE]
int ec_recover_slave(uint16 slave, int timeout)
int ec_receive_processdata(int timeout)
General typedefs and defines for EtherCAT.
void ecatcheck(void *ptr)
Headerfile for ethercatcoe.c.
int ec_config_map(void *pIOmap)
void simpletest(char *ifname)
int ec_init(char *ifname)
Headerfile for ethercatfoe.c.
int main(int argc, char *argv[])
int ec_writestate(uint16 slave)
Headerfile for ethercatbase.c.
boolean ec_configdc(void)
Headerfile for ethercatmain.c.
uint16 ec_statecheck(uint16 slave, uint16 reqstate, int timeout)
Headerfile for ethercatconfig.c.
int ec_config_init(uint8 usetable)
Headerfile for ethercatprint.c.