157 printf(
"Starting slaveinfo\n");
162 printf(
"ec_init on %s succeeded.\n",ifname);
166 for (ctx_count = 0; ctx_count < 2; ctx_count++)
171 printf(
"%d slaves found and configured.\n",*(
ctx[ctx_count].slavecount));
173 printf(
"Calculated workcounter %d\n",
expectedWKC[ctx_count]);
178 printf(
"Not all slaves reached safe operational state.\n");
184 printf(
"Slave %d State=%2x StatusCode=%4x : %s\n",
193 printf(
"\nSlave:%d\n Name:%s\n Output size: %dbits\n Input size: %dbits\n State: %d\n Delay: %d[ns]\n Has DC: %d\n",
194 cnt,
ctx[ctx_count].slavelist[cnt].name,
ctx[ctx_count].slavelist[cnt].Obits,
ctx[ctx_count].slavelist[cnt].Ibits,
195 ctx[ctx_count].slavelist[cnt].state,
ctx[ctx_count].slavelist[cnt].pdelay,
ctx[ctx_count].slavelist[cnt].hasdc);
196 if (
ctx[ctx_count].slavelist[cnt].hasdc)
198 printf(
" DCParentport:%d\n",
ctx[ctx_count].slavelist[cnt].parentport);
200 printf(
" Activeports:%d.%d.%d.%d\n", (
ctx[ctx_count].slavelist[cnt].activeports & 0x01) > 0 ,
201 (
ctx[ctx_count].slavelist[cnt].activeports & 0x02) > 0 ,
202 (
ctx[ctx_count].slavelist[cnt].activeports & 0x04) > 0 ,
203 (
ctx[ctx_count].slavelist[cnt].activeports & 0x08) > 0 );
204 printf(
" Configured address: %4.4x\n",
ctx[ctx_count].slavelist[cnt].configadr);
205 printf(
" Man: %8.8x ID: %8.8x Rev: %8.8x\n", (
int)
ctx[ctx_count].slavelist[cnt].eep_man,
206 (
int)
ctx[ctx_count].slavelist[cnt].eep_id, (
int)
ctx[ctx_count].slavelist[cnt].eep_rev);
207 for(nSM = 0 ; nSM <
EC_MAXSM ; nSM++)
209 if(
ctx[ctx_count].slavelist[cnt].SM[nSM].StartAddr > 0)
210 printf(
" SM%1d A:%4.4x L:%4d F:%8.8x Type:%d\n",nSM,
ctx[ctx_count].slavelist[cnt].SM[nSM].StartAddr,
211 ctx[ctx_count].slavelist[cnt].SM[nSM].SMlength,(
int)
ctx[ctx_count].slavelist[cnt].SM[nSM].SMflags,
212 ctx[ctx_count].slavelist[cnt].SMtype[nSM]);
216 printf(
" FMMU%1d Ls:%8.8x Ll:%4d Lsb:%d Leb:%d Ps:%4.4x Psb:%d Ty:%2.2x Act:%2.2x\n",
j,
217 (
int)
ctx[ctx_count].slavelist[cnt].FMMU[
j].LogStart,
ctx[ctx_count].slavelist[cnt].FMMU[
j].LogLength,
218 ctx[ctx_count].slavelist[cnt].FMMU[
j].LogStartbit,
ctx[ctx_count].slavelist[cnt].FMMU[
j].LogEndbit,
219 ctx[ctx_count].slavelist[cnt].FMMU[
j].PhysStart,
ctx[ctx_count].slavelist[cnt].FMMU[
j].PhysStartBit,
220 ctx[ctx_count].slavelist[cnt].FMMU[
j].FMMUtype,
ctx[ctx_count].slavelist[cnt].FMMU[
j].FMMUactive);
222 printf(
" FMMUfunc 0:%d 1:%d 2:%d 3:%d\n",
223 ctx[ctx_count].slavelist[cnt].FMMU0func,
ctx[ctx_count].slavelist[cnt].FMMU1func,
ctx[ctx_count].slavelist[cnt].FMMU2func,
224 ctx[ctx_count].slavelist[cnt].FMMU3func);
225 printf(
" MBX length wr: %d rd: %d MBX protocols : %2.2x\n",
ctx[ctx_count].slavelist[cnt].mbx_l,
226 ctx[ctx_count].slavelist[cnt].mbx_rl,
ctx[ctx_count].slavelist[cnt].mbx_proto);
244 printf(
" CoE details: %2.2x FoE details: %2.2x EoE details: %2.2x SoE details: %2.2x\n",
245 ctx[ctx_count].slavelist[cnt].CoEdetails,
ctx[ctx_count].slavelist[cnt].FoEdetails,
ctx[ctx_count].slavelist[cnt].EoEdetails,
ctx[ctx_count].slavelist[cnt].SoEdetails);
246 printf(
" Ebus current: %d[mA]\n only LRD/LWR:%d\n",
247 ctx[ctx_count].slavelist[cnt].Ebuscurrent,
ctx[ctx_count].slavelist[cnt].blockLRW);
253 printf(
"Request operational state for all slaves\n");
256 printf(
"Calculated workcounter master 1 %d\n",
expectedWKC[0]);
257 printf(
"Calculated workcounter master 2 %d\n",
expectedWKC[1]);
287 printf(
"Operational state reached for all slaves.\n");
292 for(i = 1; i <= 10000; i++)
294 for (ctx_count = 0; ctx_count < 2; ctx_count++)
297 log_RT_event(
'R',(WORD)(1 + ctx_count * 10));
299 log_RT_event(
'R',(WORD)(99 + ctx_count * 100));
301 for (ctx_count = 0; ctx_count < 2; ctx_count++)
304 log_RT_event(
'S',(WORD)(1 + ctx_count * 10));
307 printf (
" Frame no: %d on master %d,Not sentOK\n", i,ctx_count);
309 log_RT_event(
'S',(WORD)(99 + ctx_count * 100));
313 for (ctx_count = 0; ctx_count < 2; ctx_count++)
320 printf (
" Frame no: %d on master %d , wc not wkc >= expectedWKC, %d\n",i, ctx_count,
wkc[ctx_count]);
331 printf(
"No slaves found!\n");
333 printf(
"End slaveinfo, close socket\n");
340 printf(
"No socket connection on %s\nExcecute as root\n",ifname);
345 void main(
int argc,
char* argv[])
347 printf(
"SOEM (Simple Open EtherCAT Master)\nSlaveinfo\n");
356 printf(
"Usage: slaveinfo ifname [options]\nifname = eth0 for example\nOptions :\n -sdo : print SDO info\n -map : print mapping\n");
359 printf(
"End program\n");