Go to the documentation of this file.
33 sprintf(
hstr,
"BOOLEAN");
36 sprintf(
hstr,
"INTEGER8");
39 sprintf(
hstr,
"INTEGER16");
42 sprintf(
hstr,
"INTEGER32");
45 sprintf(
hstr,
"INTEGER24");
48 sprintf(
hstr,
"INTEGER64");
51 sprintf(
hstr,
"UNSIGNED8");
54 sprintf(
hstr,
"UNSIGNED16");
57 sprintf(
hstr,
"UNSIGNED32");
60 sprintf(
hstr,
"UNSIGNED24");
63 sprintf(
hstr,
"UNSIGNED64");
66 sprintf(
hstr,
"REAL32");
69 sprintf(
hstr,
"REAL64");
72 sprintf(
hstr,
"BIT1");
75 sprintf(
hstr,
"BIT2");
78 sprintf(
hstr,
"BIT3");
81 sprintf(
hstr,
"BIT4");
84 sprintf(
hstr,
"BIT5");
87 sprintf(
hstr,
"BIT6");
90 sprintf(
hstr,
"BIT7");
93 sprintf(
hstr,
"BIT8");
96 sprintf(
hstr,
"VISIBLE_STRING");
99 sprintf(
hstr,
"OCTET_STRING");
102 sprintf(
hstr,
"Type 0x%4.4X", dtype);
109 int l =
sizeof(
usdo) - 1, i;
122 memset(&
usdo, 0, 128);
134 if (*u8) sprintf(
hstr,
"TRUE");
135 else sprintf(
hstr,
"FALSE");
139 sprintf(
hstr,
"0x%2.2x %d", *i8, *i8);
143 sprintf(
hstr,
"0x%4.4x %d", *i16, *i16);
148 sprintf(
hstr,
"0x%8.8x %d", *i32, *i32);
156 sprintf(
hstr,
"0x%2.2x %u", *u8, *u8);
160 sprintf(
hstr,
"0x%4.4x %u", *u16, *u16);
165 sprintf(
hstr,
"0x%8.8x %u", *u32, *u32);
172 sr = (
float*) &
usdo[0];
173 sprintf(
hstr,
"%f", *sr);
176 dr = (
double*) &
usdo[0];
177 sprintf(
hstr,
"%f", *dr);
188 sprintf(
hstr,
"0x%x", *u8);
195 for (i = 0 ; i < l ; i++)
197 sprintf(es,
"0x%2.2x ",
usdo[i]);
202 sprintf(
hstr,
"Unknown type");
211 uint16 idxloop, nidx, subidxloop, rdat, idx, subidx;
213 int wkc, bsize = 0, rdl;
215 uint8 bitlen, obj_subidx;
217 int abs_offset, abs_bit;
219 rdl =
sizeof(rdat); rdat = 0;
224 if ((
wkc > 0) && (rdat > 0))
230 for (idxloop = 1; idxloop <= nidx; idxloop++)
232 rdl =
sizeof(rdat); rdat = 0;
239 rdl =
sizeof(subcnt); subcnt = 0;
244 for (subidxloop = 1; subidxloop <= subidx; subidxloop++)
246 rdl =
sizeof(rdat2); rdat2 = 0;
249 rdat2 =
etohl(rdat2);
253 obj_idx = (
uint16)(rdat2 >> 16);
254 obj_subidx = (
uint8)((rdat2 >> 8) & 0x000000ff);
255 abs_offset = mapoffset + (bitoffset / 8);
256 abs_bit = bitoffset % 8;
262 if(obj_idx || obj_subidx)
264 printf(
" [0x%4.4X.%1d] 0x%4.4X:0x%2.2X 0x%2.2X", abs_offset, abs_bit, obj_idx, obj_subidx, bitlen);
285 int Tsize, outputs_bo, inputs_bo;
288 printf(
"PDO mapping according to CoE :\n");
292 rdl =
sizeof(nSM); nSM = 0;
296 if ((
wkc > 0) && (nSM > 2))
304 for (iSM = 2 ; iSM <= nSM ; iSM++)
306 rdl =
sizeof(tSM); tSM = 0;
311 if((iSM == 2) && (tSM == 2))
314 printf(
"Activated SM type workaround, possible incorrect mapping.\n");
322 printf(
" SM%1d outputs\n addr b index: sub bitl data_type name\n", iSM);
329 printf(
" SM%1d inputs\n addr b index: sub bitl data_type name\n", iSM);
338 if ((outputs_bo > 0) || (inputs_bo > 0))
345 uint16 a , w, c, e, er, Size;
355 int abs_offset, abs_bit;
397 printf(
" SM%1d RXPDO 0x%4.4X %s\n", PDO->
SyncM[PDO->
nPDO], PDO->
Index[PDO->
nPDO], str_name);
399 printf(
" SM%1d TXPDO 0x%4.4X %s\n", PDO->
SyncM[PDO->
nPDO], PDO->
Index[PDO->
nPDO], str_name);
400 printf(
" addr b index: sub bitl data_type name\n");
402 for (er = 1; er <= e; er++)
411 abs_offset = mapoffset + (bitoffset / 8);
412 abs_bit = bitoffset % 8;
418 if(obj_idx || obj_subidx)
424 printf(
" [0x%4.4X.%1d] 0x%4.4X:0x%2.2X 0x%2.2X", abs_offset, abs_bit, obj_idx, obj_subidx, bitlen);
425 printf(
" %-12s %s\n",
dtype2string(obj_datatype), str_name);
442 while (c < PDO->Length);
452 int Tsize, outputs_bo, inputs_bo;
454 printf(
"PDO mapping according to SII :\n");
465 if ((outputs_bo > 0) || (inputs_bo > 0))
478 printf(
" CoE Object Description found, %d entries.\n",
ODlist.
Entries);
483 printf(
" Index: %4.4x Datatype: %4.4x Objectcode: %2.2x Name: %s\n",
492 printf(
" Sub: %2.2x Datatype: %4.4x Bitlength: %4.4x Obj.access: %4.4x Name: %s\n",
514 printf(
"Starting slaveinfo\n");
519 printf(
"ec_init on %s succeeded.\n",ifname);
527 printf(
"Calculated workcounter %d\n",
expectedWKC);
532 printf(
"Not all slaves reached safe operational state.\n");
538 printf(
"Slave %d State=%2x StatusCode=%4x : %s\n",
548 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",
551 if (
ec_slave[cnt].hasdc) printf(
" DCParentport:%d\n",
ec_slave[cnt].parentport);
552 printf(
" Activeports:%d.%d.%d.%d\n", (
ec_slave[cnt].activeports & 0x01) > 0 ,
553 (
ec_slave[cnt].activeports & 0x02) > 0 ,
554 (
ec_slave[cnt].activeports & 0x04) > 0 ,
555 (
ec_slave[cnt].activeports & 0x08) > 0 );
556 printf(
" Configured address: %4.4x\n",
ec_slave[cnt].configadr);
557 printf(
" Man: %8.8x ID: %8.8x Rev: %8.8x\n", (
int)
ec_slave[cnt].eep_man, (
int)
ec_slave[cnt].eep_id, (
int)
ec_slave[cnt].eep_rev);
558 for(nSM = 0 ; nSM <
EC_MAXSM ; nSM++)
560 if(
ec_slave[cnt].SM[nSM].StartAddr > 0)
561 printf(
" SM%1d A:%4.4x L:%4d F:%8.8x Type:%d\n",nSM,
etohs(
ec_slave[cnt].SM[nSM].StartAddr),
etohs(
ec_slave[cnt].SM[nSM].SMlength),
566 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,
571 printf(
" FMMUfunc 0:%d 1:%d 2:%d 3:%d\n",
573 printf(
" MBX length wr: %d rd: %d MBX protocols : %2.2x\n",
ec_slave[cnt].mbx_l,
ec_slave[cnt].mbx_rl,
ec_slave[cnt].mbx_proto);
591 printf(
" CoE details: %2.2x FoE details: %2.2x EoE details: %2.2x SoE details: %2.2x\n",
593 printf(
" Ebus current: %d[mA]\n only LRD/LWR:%d\n",
608 printf(
"No slaves found!\n");
610 printf(
"End slaveinfo, close socket\n");
616 printf(
"No socket connection on %s\nExcecute as root\n",ifname);
622 int main(
int argc,
char *argv[])
625 printf(
"SOEM (Simple Open EtherCAT Master)\nSlaveinfo\n");
629 if ((argc > 2) && (strncmp(argv[2],
"-sdo",
sizeof(
"-sdo")) == 0))
printSDO =
TRUE;
630 if ((argc > 2) && (strncmp(argv[2],
"-map",
sizeof(
"-map")) == 0))
printMAP =
TRUE;
632 strcpy(
ifbuf, argv[1]);
637 printf(
"Usage: slaveinfo ifname [options]\nifname = eth0 for example\nOptions :\n -sdo : print SDO info\n -map : print mapping\n");
639 printf (
"Available adapters\n");
641 while (adapter != NULL)
643 printf (
"Description : %s, Device to use for wpcap: %s\n", adapter->
desc,adapter->
name);
644 adapter = adapter->
next;
648 printf(
"End program\n");
boolean ec_configdc(void)
int si_map_sii(int slave)
char Name[EC_MAXOELIST][EC_MAXNAME+1]
uint16 DataType[EC_MAXOELIST]
char * SDO2string(uint16 slave, uint16 index, uint8 subidx, uint16 dtype)
uint16 ObjAccess[EC_MAXOELIST]
int ec_readOE(uint16 Item, ec_ODlistt *pODlist, ec_OElistt *pOElist)
int ec_readOEsingle(uint16 Item, uint8 SubI, ec_ODlistt *pODlist, ec_OElistt *pOElist)
Headerfile for all ethercat headers.
int ec_init(const char *ifname)
int si_PDOassign(uint16 slave, uint16 PDOassign, int mapoffset, int bitoffset)
char desc[EC_MAXLEN_ADAPTERNAME]
int ec_config(uint8 usetable, void *pIOmap)
int16 ec_siifind(uint16 slave, uint16 cat)
uint8 ec_siigetbyte(uint16 slave, uint16 address)
char Name[EC_MAXODLIST][EC_MAXNAME+1]
char * ec_elist2string(void)
uint16 BitLength[EC_MAXOELIST]
uint16 SyncM[EC_MAXEEPDO]
int si_map_sdo(int slave)
int main(int argc, char *argv[])
#define ECT_SDO_SMCOMMTYPE
uint8 MaxSub[EC_MAXODLIST]
uint8 ObjectCode[EC_MAXODLIST]
int ec_eeprom2pdi(uint16 slave)
char * dtype2string(uint16 dtype)
ec_adaptert * ec_find_adapters(void)
void ec_siistring(char *str, uint16 slave, uint16 Sn)
uint16 BitSize[EC_MAXEEPDO]
int ec_readODdescription(uint16 Item, ec_ODlistt *pODlist)
uint16 SMbitsize[EC_MAXSM]
void slaveinfo(char *ifname)
int si_siiPDO(uint16 slave, uint8 t, int mapoffset, int bitoffset)
#define ECT_SDO_PDOASSIGN
int ec_SDOread(uint16 slave, uint16 index, uint8 subindex, boolean CA, int *psize, void *p, int timeout)
uint16 DataType[EC_MAXODLIST]
uint16 ec_statecheck(uint16 slave, uint16 reqstate, int timeout)
char * ec_ALstatuscode2string(uint16 ALstatuscode)
uint16 Index[EC_MAXEEPDO]
uint16 Index[EC_MAXODLIST]
char name[EC_MAXLEN_ADAPTERNAME]
int ec_readODlist(uint16 Slave, ec_ODlistt *pODlist)
soem
Author(s): Arthur Ketels and M.J.G. van den Molengraft
autogenerated on Wed Mar 2 2022 01:01:49