157 printf(
"Starting slaveinfo\n");
162 printf(
"ec_init on %s succeeded.\n",ifname);
166 for (ctx_count = 0; ctx_count < 2; ctx_count++)
170 while(*(ctx[ctx_count].ecaterror)) printf(
"%s",
ecx_elist2string(&ctx[ctx_count]));
171 printf(
"%d slaves found and configured.\n",*(ctx[ctx_count].slavecount));
172 expectedWKC[ctx_count] = ( ctx[ctx_count].
grouplist[0].
outputsWKC * 2) + ctx[ctx_count].grouplist[0].inputsWKC;
173 printf(
"Calculated workcounter %d\n", expectedWKC[ctx_count]);
178 printf(
"Not all slaves reached safe operational state.\n");
180 for(i = 1; i <= *(ctx[ctx_count].
slavecount) ; i++)
184 printf(
"Slave %d State=%2x StatusCode=%4x : %s\n",
185 i, ctx[ctx_count].slavelist[i].state, ctx[ctx_count].slavelist[i].ALstatuscode,
ec_ALstatuscode2string(ctx[ctx_count].slavelist[i].ALstatuscode));
191 for( cnt = 1 ; cnt <= *(ctx[ctx_count].
slavecount) ; cnt++)
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);
235 if((
ecx_siigetbyte(&ctx[ctx_count], cnt, ssigen + 0x0d) & 0x02) > 0)
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++)
315 if(wkc[ctx_count] >= expectedWKC[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");
static ec_PDOassignt ec_PDOassign2
int ecx_send_processdata(ecx_contextt *context)
char * ec_ALstatuscode2string(uint16 ALstatuscode)
static uint32 esimap[EC_MAXEEPBITMAP]
static ec_SMcommtypet ec_SMcommtype2
uint8 ecx_siigetbyte(ecx_contextt *context, uint16 slave, uint16 address)
static ecx_portt ecx_port2
void ecx_close(ecx_contextt *context)
static ec_idxstackT ec_idxstack2
uint16 ecx_statecheck(ecx_contextt *context, uint16 slave, uint16 reqstate, int timeout)
void slaveinfo(char *ifname)
Headerfile for all ethercat headers.
static ec_eepromFMMUt ec_FMMU2
PACKED_BEGIN struct PACKED ec_SMcommtype ec_SMcommtypet
static ec_eepromSMt ec_SM
void main(int argc, char *argv[])
static ec_eepromSMt ec_SM2
PACKED_END struct ec_idxstack ec_idxstackT
int ecx_config_init(ecx_contextt *context, uint8 usetable)
static ec_PDOdesct ec_PDOdesc2
int ecx_init(ecx_contextt *context, const char *ifname)
PACKED_END PACKED_BEGIN struct PACKED ec_PDOassign ec_PDOassignt
int ecx_writestate(ecx_contextt *context, uint16 slave)
static ec_eringt ec_elist2
static ec_PDOassignt ec_PDOassign
static ec_eepromFMMUt ec_FMMU
char * ecx_elist2string(ecx_contextt *context)
static ec_SMcommtypet ec_SMcommtype
int ecx_config_map_group(ecx_contextt *context, void *pIOmap, uint8 group)
static ec_eringt ec_elist
PACKED_END PACKED_BEGIN struct PACKED ec_PDOdesc ec_PDOdesct
boolean ecx_configdc(ecx_contextt *context)
ec_groupt ec_groups2[EC_MAXGROUP]
static ec_PDOdesct ec_PDOdesc
static ec_idxstackT ec_idxstack
int ecx_readstate(ecx_contextt *context)
static boolean EcatError2
static ecx_portt ecx_port
int16 ecx_siifind(ecx_contextt *context, uint16 slave, uint16 cat)
static uint32 esimap2[EC_MAXEEPBITMAP]
ec_groupt ec_groups[EC_MAXGROUP]
int ecx_receive_processdata(ecx_contextt *context, int timeout)
static uint8 esibuf[EC_MAXEEPBUF]
static uint8 esibuf2[EC_MAXEEPBUF]
ec_slavet ec_slave2[EC_MAXSLAVE]
static ecx_contextt ctx[]