29 #define EC_TIMEOUTMON 500 77 uint16 type = ntohs(bp->etype);
78 printf(
"Frameno %d, type 0x%x complete\n",
rxframeno, type);
84 printf(
"Size differs, expected %d , received %d\n",
sizeof(
txbuf),
size_of_rx);
88 printf(
"Size OK, expected %d , received %d\n",
sizeof(
txbuf),
size_of_rx);
93 printf(
"memcmp result != 0\n");
97 printf(
"memcmp result == 0\n");
105 printf(
"Send a new frame\n");
110 printf(
"Skip type 0x%x\n", type);
142 printf(
"Unhandled mailbox response 0x%x\n", MbxHdr->mbxtype);
154 memset(&ipsettings, 0,
sizeof(ipsettings));
155 memset(&re_ipsettings, 0,
sizeof(re_ipsettings));
157 ipsettings.ip_set = 1;
158 ipsettings.subnet_set = 1;
159 ipsettings.default_gateway_set = 1;
174 printf(
"recieved IP (%d.%d.%d.%d)\n",
179 printf(
"recieved subnet (%d.%d.%d.%d)\n",
184 printf(
"recieved gateway (%d.%d.%d.%d)\n",
196 int i, oloop, iloop, chk;
200 printf(
"Starting eoe test\n");
205 printf(
"ec_init on %s succeeded.\n",ifname);
215 printf(
"Slaves mapped, state to SAFE_OP.\n");
220 if ((oloop == 0) && (
ec_slave[0].Obits > 0)) oloop = 1;
221 if (oloop > 8) oloop = 8;
223 if ((iloop == 0) && (
ec_slave[0].Ibits > 0)) iloop = 1;
224 if (iloop > 8) iloop = 8;
228 printf(
"Request operational state for all slaves\n");
230 printf(
"Calculated workcounter %d\n",
expectedWKC);
252 printf(
"Operational state reached for all slaves.\n");
256 for(i = 1; i <= 10000; i++)
260 #if PRINT_EOE_INFO_INSTEAD 264 printf(
"Processdata cycle %4d, WKC %d , O:", i,
globalwkc);
265 for(j = 0 ; j < oloop; j++)
267 printf(
" %2.2x", *(
ec_slave[0].outputs + j));
270 for(j = 0 ; j < iloop; j++)
272 printf(
" %2.2x", *(
ec_slave[0].inputs + j));
284 printf(
"Not all slaves reached operational state.\n");
290 printf(
"Slave %d State=0x%2.2x StatusCode=0x%4.4x : %s\n",
295 printf(
"\nRequest init state for all slaves\n");
302 printf(
"No slaves found!\n");
304 printf(
"End eoe test, close socket\n");
310 printf(
"No socket connection on %s\nExcecute as root\n",ifname);
325 printf(
"(wkc < expectedWKC) , globalwkc %d\n",
globalwkc);
329 printf(
"(ec_group[currentgroup].docheckstate)\n");
347 printf(
"ERROR : slave %d is in SAFE_OP + ERROR, attempting ack.\n", slave);
353 printf(
"WARNING : slave %d is in SAFE_OP, change to OPERATIONAL.\n", slave);
362 printf(
"MESSAGE : slave %d reconfigured\n",slave);
372 printf(
"ERROR : slave %d lost\n",slave);
383 printf(
"MESSAGE : slave %d recovered\n",slave);
389 printf(
"MESSAGE : slave %d found\n",slave);
394 printf(
"OK : all slaves resumed OPERATIONAL.\n");
400 int main(
int argc,
char *argv[])
402 printf(
"SOEM (Simple Open EtherCAT Master)\nEoE test\n");
415 printf(
"Usage: eoe_test ifname1\nifname = eth0 for example\n");
418 printf(
"End program\n");
int ecx_EOEsetIp(ecx_contextt *context, uint16 slave, uint8 port, eoe_param_t *ipparam, int timeout)
int ec_reconfig_slave(uint16 slave, int timeout)
char * ec_ALstatuscode2string(uint16 ALstatuscode)
int ecx_EOEreadfragment(ec_mbxbuft *MbxIn, uint8 *rxfragmentno, uint16 *rxframesize, uint16 *rxframeoffset, uint16 *rxframeno, int *psize, void *p)
int ec_send_processdata(void)
int ec_recover_slave(uint16 slave, int timeout)
Headerfile for all ethercat headers.
int ec_receive_processdata(int timeout)
PACKED_BEGIN struct PACKED ec_etherheadert
int ec_init(const char *ifname)
#define EOE_IP4_ADDR_TO_U32(ipaddr, a, b, c, d)
void teststarter(char *ifname)
int eoe_hook(ecx_contextt *context, uint16 slave, void *eoembx)
int ec_config_map(void *pIOmap)
#define OSAL_THREAD_HANDLE
int ecx_EOEgetIp(ecx_contextt *context, uint16 slave, uint8 port, eoe_param_t *ipparam, int timeout)
OSAL_THREAD_FUNC mailbox_reader(void *lpParam)
int osal_usleep(uint32 usec)
int ecx_mbxreceive(ecx_contextt *context, uint16 slave, ec_mbxbuft *mbx, int timeout)
int osal_thread_create(void *thandle, int stacksize, void *func, void *param)
int ecx_EOEsend(ecx_contextt *context, uint16 slave, uint8 port, int psize, void *p, int timeout)
OSAL_THREAD_HANDLE thread2
int main(int argc, char *argv[])
#define eoe_ip4_addr1(ipaddr)
#define eoe_ip4_addr3(ipaddr)
int ec_writestate(uint16 slave)
#define eoe_ip4_addr2(ipaddr)
void test_eoe(ecx_contextt *context)
PACKED_BEGIN struct PACKED ec_mbxheader ec_mbxheadert
boolean ec_configdc(void)
OSAL_THREAD_FUNC ecatcheck(void *ptr)
OSAL_THREAD_HANDLE thread1
PACKED_END struct eoe_param eoe_param_t
#define eoe_ip4_addr4(ipaddr)
uint16 ec_statecheck(uint16 slave, uint16 reqstate, int timeout)
void ec_setupheader(void *p)
int ec_config_init(uint8 usetable)
int ecx_EOEdefinehook(ecx_contextt *context, void *hook)
uint8 ec_mbxbuft[EC_MAXMBX+1]