19 #define EC_TIMEOUTMON 500 31 void CALLBACK
RTthread(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2)
47 uint16 map_1c12[4] = {0x0003, 0x1601, 0x1602, 0x1604};
48 uint16 map_1c13[3] = {0x0002, 0x1a01, 0x1a03};
72 printf(
"EL7031 slave %d set, retval = %d\n", slave, retval);
112 printf(
"AEP slave %d set, retval = %d\n", slave, retval);
118 int i,
j, oloop, iloop, wkc_count, chk, slc;
124 printf(
"Starting simple test\n");
129 printf(
"ec_init on %s succeeded.\n",ifname);
142 if((
ec_slave[slc].eep_man == 0x00000002) && (
ec_slave[slc].eep_id == 0x1b773052))
144 printf(
"Found %s at position %d\n",
ec_slave[slc].name, slc);
149 if((
ec_slave[slc].eep_man == 0x000000ab) && (
ec_slave[slc].eep_id == 0x00000380))
151 printf(
"Found %s at position %d\n",
ec_slave[slc].name, slc);
163 printf(
"Slaves mapped, state to SAFE_OP.\n");
168 if ((oloop == 0) && (
ec_slave[0].Obits > 0)) oloop = 1;
169 if (oloop > 8) oloop = 8;
171 if ((iloop == 0) && (
ec_slave[0].Ibits > 0)) iloop = 1;
172 if (iloop > 8) iloop = 8;
176 printf(
"Request operational state for all slaves\n");
178 printf(
"Calculated workcounter %d\n",
expectedWKC);
185 mmResult = timeSetEvent(1, 0,
RTthread, 0, TIME_PERIODIC);
198 printf(
"Operational state reached for all slaves.\n");
204 for(i = 1; i <= 500; i++)
208 printf(
"Processdata cycle %4d, WKC %d , O:",
rtcnt,
wkc);
210 for(j = 0 ; j < oloop; j++)
212 printf(
" %2.2x", *(
ec_slave[0].outputs + j));
216 for(j = 0 ; j < iloop; j++)
218 printf(
" %2.2x", *(
ec_slave[0].inputs + j));
230 printf(
"Not all slaves reached operational state.\n");
236 printf(
"Slave %d State=0x%2.2x StatusCode=0x%4.4x : %s\n",
243 timeKillEvent(mmResult);
245 printf(
"\nRequest init state for all slaves\n");
252 printf(
"No slaves found!\n");
254 printf(
"End simple test, close socket\n");
260 printf(
"No socket connection on %s\nExcecute as root\n",ifname);
288 printf(
"ERROR : slave %d is in SAFE_OP + ERROR, attempting ack.\n", slave);
294 printf(
"WARNING : slave %d is in SAFE_OP, change to OPERATIONAL.\n", slave);
303 printf(
"MESSAGE : slave %d reconfigured\n",slave);
313 printf(
"ERROR : slave %d lost\n",slave);
324 printf(
"MESSAGE : slave %d recovered\n",slave);
330 printf(
"MESSAGE : slave %d found\n",slave);
335 printf(
"OK : all slaves resumed OPERATIONAL.\n");
345 int main(
int argc,
char *argv[])
348 printf(
"SOEM (Simple Open EtherCAT Master)\nSimple test\n");
354 strcpy(
ifbuf, argv[1]);
360 printf(
"Usage: simple_test ifname1\n");
362 printf (
"Available adapters\n");
364 while (adapter != NULL)
366 printf (
"Description : %s, Device to use for wpcap: %s\n", adapter->
desc,adapter->
name);
367 adapter = adapter->
next;
371 printf(
"End program\n");
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)
int ec_send_processdata(void)
int main(int argc, char *argv[])
char name[EC_MAXLEN_ADAPTERNAME]
int ec_recover_slave(uint16 slave, int timeout)
Headerfile for all ethercat headers.
int ec_receive_processdata(int timeout)
int ec_init(const char *ifname)
char * ec_elist2string(void)
int ec_config_map(void *pIOmap)
#define OSAL_THREAD_HANDLE
char desc[EC_MAXLEN_ADAPTERNAME]
OSAL_THREAD_FUNC ecatcheck(void *lpParam)
void simpletest(char *ifname)
int osal_usleep(uint32 usec)
int osal_thread_create(void *thandle, int stacksize, void *func, void *param)
int EL7031setup(uint16 slave)
int ec_writestate(uint16 slave)
int(* PO2SOconfig)(uint16 slave)
boolean ec_configdc(void)
OSAL_THREAD_HANDLE thread1
ec_adaptert * ec_find_adapters(void)
int AEPsetup(uint16 slave)
uint16 ec_statecheck(uint16 slave, uint16 reqstate, int timeout)
int ec_SDOwrite(uint16 Slave, uint16 Index, uint8 SubIndex, boolean CA, int psize, void *p, int Timeout)
int ec_config_init(uint8 usetable)