27 #define EC_TIMEOUTMON 500 39 void CALLBACK
RTthread(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2)
56 uint16 map_1c12[4] = {0x0003, 0x1601, 0x1602, 0x1604};
57 uint16 map_1c13[3] = {0x0002, 0x1a01, 0x1a03};
81 printf(
"EL7031 slave %d set, retval = %d\n", slave, retval);
121 printf(
"AEP slave %d set, retval = %d\n", slave, retval);
127 int i,
j, oloop, iloop, wkc_count, chk, slc;
133 printf(
"Starting simple test\n");
138 printf(
"ec_init on %s succeeded.\n",ifname);
151 if((
ec_slave[slc].eep_man == 0x00000002) && (
ec_slave[slc].eep_id == 0x1b773052))
153 printf(
"Found %s at position %d\n",
ec_slave[slc].name, slc);
158 if((
ec_slave[slc].eep_man == 0x000000ab) && (
ec_slave[slc].eep_id == 0x00000380))
160 printf(
"Found %s at position %d\n",
ec_slave[slc].name, slc);
172 printf(
"Slaves mapped, state to SAFE_OP.\n");
177 if ((oloop == 0) && (
ec_slave[0].Obits > 0)) oloop = 1;
178 if (oloop > 8) oloop = 8;
180 if ((iloop == 0) && (
ec_slave[0].Ibits > 0)) iloop = 1;
181 if (iloop > 8) iloop = 8;
185 printf(
"Request operational state for all slaves\n");
187 printf(
"Calculated workcounter %d\n",
expectedWKC);
194 mmResult = timeSetEvent(1, 0,
RTthread, 0, TIME_PERIODIC);
207 printf(
"Operational state reached for all slaves.\n");
213 for(i = 1; i <= 500; i++)
217 printf(
"Processdata cycle %4d, WKC %d , O:",
rtcnt,
wkc);
219 for(j = 0 ; j < oloop; j++)
221 printf(
" %2.2x", *(
ec_slave[0].outputs + j));
225 for(j = 0 ; j < iloop; j++)
227 printf(
" %2.2x", *(
ec_slave[0].inputs + j));
239 printf(
"Not all slaves reached operational state.\n");
245 printf(
"Slave %d State=0x%2.2x StatusCode=0x%4.4x : %s\n",
252 timeKillEvent(mmResult);
254 printf(
"\nRequest init state for all slaves\n");
261 printf(
"No slaves found!\n");
263 printf(
"End simple test, close socket\n");
269 printf(
"No socket connection on %s\nExcecute as root\n",ifname);
296 printf(
"ERROR : slave %d is in SAFE_OP + ERROR, attempting ack.\n", slave);
302 printf(
"WARNING : slave %d is in SAFE_OP, change to OPERATIONAL.\n", slave);
311 printf(
"MESSAGE : slave %d reconfigured\n",slave);
321 printf(
"ERROR : slave %d lost\n",slave);
332 printf(
"MESSAGE : slave %d recovered\n",slave);
338 printf(
"MESSAGE : slave %d found\n",slave);
343 printf(
"OK : all slaves resumed OPERATIONAL.\n");
353 int main(
int argc,
char *argv[])
356 printf(
"SOEM (Simple Open EtherCAT Master)\nSimple test\n");
363 strcpy(
ifbuf, argv[1]);
369 printf(
"Usage: simple_test ifname1\n");
371 printf (
"Available adapters\n");
373 while (adapter != NULL)
375 printf (
"Description : %s, Device to use for wpcap: %s\n", adapter->
desc,adapter->
name);
376 adapter = adapter->
next;
380 printf(
"End program\n");
ec_groupt ec_group[EC_MAXGROUP]
int ec_reconfig_slave(uint16 slave, int timeout)
char * ec_ALstatuscode2string(uint16 ALstatuscode)
void CALLBACK RTthread(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2)
Headerfile for ethercatdc.c.
int ec_send_processdata(void)
PACKED_END ec_slavet ec_slave[EC_MAXSLAVE]
int main(int argc, char *argv[])
char name[EC_MAXLEN_ADAPTERNAME]
int(* PO2SOconfig)(uint16 slave)
int ec_recover_slave(uint16 slave, int timeout)
int ec_receive_processdata(int timeout)
char * ec_elist2string(void)
General typedefs and defines for EtherCAT.
Headerfile for ethercatcoe.c.
int ec_config_map(void *pIOmap)
char desc[EC_MAXLEN_ADAPTERNAME]
int ec_init(char *ifname)
void simpletest(char *ifname)
Headerfile for ethercatfoe.c.
int EL7031setup(uint16 slave)
int ec_writestate(uint16 slave)
Headerfile for ethercatbase.c.
boolean ec_configdc(void)
Headerfile for ethercatmain.c.
ec_adaptert * ec_find_adapters(void)
int osal_usleep(uint32 usec)
int AEPsetup(uint16 slave)
uint16 ec_statecheck(uint16 slave, uint16 reqstate, int timeout)
Headerfile for ethercatconfig.c.
int ec_SDOwrite(uint16 Slave, uint16 Index, uint8 SubIndex, boolean CA, int psize, void *p, int Timeout)
int ec_config_init(uint8 usetable)
DWORD WINAPI ecatcheck(LPVOID lpParam)
Headerfile for ethercatprint.c.