39 sprintf(
hstr,
"BOOLEAN");
42 sprintf(
hstr,
"INTEGER8");
45 sprintf(
hstr,
"INTEGER16");
48 sprintf(
hstr,
"INTEGER32");
51 sprintf(
hstr,
"INTEGER24");
54 sprintf(
hstr,
"INTEGER64");
57 sprintf(
hstr,
"UNSIGNED8");
60 sprintf(
hstr,
"UNSIGNED16");
63 sprintf(
hstr,
"UNSIGNED32");
66 sprintf(
hstr,
"UNSIGNED24");
69 sprintf(
hstr,
"UNSIGNED64");
72 sprintf(
hstr,
"REAL32");
75 sprintf(
hstr,
"REAL64");
78 sprintf(
hstr,
"BIT1");
81 sprintf(
hstr,
"BIT2");
84 sprintf(
hstr,
"BIT3");
87 sprintf(
hstr,
"BIT4");
90 sprintf(
hstr,
"BIT5");
93 sprintf(
hstr,
"BIT6");
96 sprintf(
hstr,
"BIT7");
99 sprintf(
hstr,
"BIT8");
102 sprintf(
hstr,
"VISIBLE_STRING");
105 sprintf(
hstr,
"OCTET_STRING");
108 sprintf(
hstr,
"Type 0x%4.4X", dtype);
115 int l =
sizeof(
usdo) - 1, i;
128 memset(&
usdo, 0, 128);
140 if (*u8) sprintf(
hstr,
"TRUE");
141 else sprintf(
hstr,
"FALSE");
145 sprintf(
hstr,
"0x%2.2x %d", *i8, *i8);
149 sprintf(
hstr,
"0x%4.4x %d", *i16, *i16);
154 sprintf(
hstr,
"0x%8.8x %d", *i32, *i32);
158 sprintf(
hstr,
"0x%16.16llx %lld", *i64, *i64);
162 sprintf(
hstr,
"0x%2.2x %u", *u8, *u8);
166 sprintf(
hstr,
"0x%4.4x %u", *u16, *u16);
171 sprintf(
hstr,
"0x%8.8x %u", *u32, *u32);
175 sprintf(
hstr,
"0x%16.16llx %llu", *u64, *u64);
178 sr = (
float*) &
usdo[0];
179 sprintf(
hstr,
"%f", *sr);
182 dr = (
double*) &
usdo[0];
183 sprintf(
hstr,
"%f", *dr);
194 sprintf(
hstr,
"0x%x", *u8);
201 for (i = 0 ; i < l ; i++)
203 sprintf(es,
"0x%2.2x ",
usdo[i]);
208 sprintf(
hstr,
"Unknown type");
217 uint16 idxloop, nidx, subidxloop, rdat, idx, subidx;
219 int wkc, bsize = 0, rdl;
221 uint8 bitlen, obj_subidx;
223 int abs_offset, abs_bit;
225 rdl =
sizeof(rdat); rdat = 0;
230 if ((wkc > 0) && (rdat > 0))
236 for (idxloop = 1; idxloop <= nidx; idxloop++)
238 rdl =
sizeof(rdat); rdat = 0;
245 rdl =
sizeof(subcnt); subcnt = 0;
250 for (subidxloop = 1; subidxloop <= subidx; subidxloop++)
252 rdl =
sizeof(rdat2); rdat2 = 0;
255 rdat2 =
etohl(rdat2);
259 obj_idx = (
uint16)(rdat2 >> 16);
260 obj_subidx = (
uint8)((rdat2 >> 8) & 0x000000ff);
261 abs_offset = mapoffset + (bitoffset / 8);
262 abs_bit = bitoffset % 8;
264 ODlist.
Index[0] = obj_idx;
268 if(obj_idx || obj_subidx)
270 printf(
" [0x%4.4X.%1d] 0x%4.4X:0x%2.2X 0x%2.2X", abs_offset, abs_bit, obj_idx, obj_subidx, bitlen);
271 if((wkc > 0) && OElist.
Entries)
291 int Tsize, outputs_bo, inputs_bo;
294 printf(
"PDO mapping according to CoE :\n");
298 rdl =
sizeof(nSM); nSM = 0;
302 if ((wkc > 0) && (nSM > 2))
310 for (iSM = 2 ; iSM <= nSM ; iSM++)
312 rdl =
sizeof(tSM); tSM = 0;
317 if((iSM == 2) && (tSM == 2))
320 printf(
"Activated SM type workaround, possible incorrect mapping.\n");
328 printf(
" SM%1d outputs\n addr b index: sub bitl data_type name\n", iSM);
335 printf(
" SM%1d inputs\n addr b index: sub bitl data_type name\n", iSM);
344 if ((outputs_bo > 0) || (inputs_bo > 0))
351 uint16 a , w, c, e, er, Size;
361 int abs_offset, abs_bit;
403 printf(
" SM%1d RXPDO 0x%4.4X %s\n", PDO->
SyncM[PDO->
nPDO], PDO->
Index[PDO->
nPDO], str_name);
405 printf(
" SM%1d TXPDO 0x%4.4X %s\n", PDO->
SyncM[PDO->
nPDO], PDO->
Index[PDO->
nPDO], str_name);
406 printf(
" addr b index: sub bitl data_type name\n");
408 for (er = 1; er <= e; er++)
417 abs_offset = mapoffset + (bitoffset / 8);
418 abs_bit = bitoffset % 8;
427 printf(
" [0x%4.4X.%1d] 0x%4.4X:0x%2.2X 0x%2.2X", abs_offset, abs_bit, obj_idx, obj_subidx, bitlen);
428 printf(
" %-12s %s\n",
dtype2string(obj_datatype), str_name);
444 while (c < PDO->Length);
454 int Tsize, outputs_bo, inputs_bo;
456 printf(
"PDO mapping according to SII :\n");
467 if ((outputs_bo > 0) || (inputs_bo > 0))
477 memset(&ODlist, 0,
sizeof(ODlist));
480 printf(
" CoE Object Description found, %d entries.\n",ODlist.
Entries);
481 for( i = 0 ; i < ODlist.
Entries ; i++)
485 printf(
" Index: %4.4x Datatype: %4.4x Objectcode: %2.2x Name: %s\n",
487 memset(&OElist, 0,
sizeof(OElist));
490 for( j = 0 ; j < ODlist.
MaxSub[i]+1 ; j++)
494 printf(
" Sub: %2.2x Datatype: %4.4x Bitlength: %4.4x Obj.access: %4.4x Name: %s\n",
516 printf(
"Starting slaveinfo\n");
521 printf(
"ec_init on %s succeeded.\n",ifname);
529 printf(
"Calculated workcounter %d\n", expectedWKC);
534 printf(
"Not all slaves reached safe operational state.\n");
540 printf(
"Slave %d State=%2x StatusCode=%4x : %s\n",
550 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",
553 if (
ec_slave[cnt].hasdc) printf(
" DCParentport:%d\n",
ec_slave[cnt].parentport);
554 printf(
" Activeports:%d.%d.%d.%d\n", (
ec_slave[cnt].activeports & 0x01) > 0 ,
555 (
ec_slave[cnt].activeports & 0x02) > 0 ,
556 (
ec_slave[cnt].activeports & 0x04) > 0 ,
557 (
ec_slave[cnt].activeports & 0x08) > 0 );
558 printf(
" Configured address: %4.4x\n",
ec_slave[cnt].configadr);
559 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);
560 for(nSM = 0 ; nSM <
EC_MAXSM ; nSM++)
562 if(
ec_slave[cnt].SM[nSM].StartAddr > 0)
563 printf(
" SM%1d A:%4.4x L:%4d F:%8.8x Type:%d\n",nSM,
ec_slave[cnt].SM[nSM].StartAddr,
ec_slave[cnt].SM[nSM].SMlength,
568 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,
573 printf(
" FMMUfunc 0:%d 1:%d 2:%d 3:%d\n",
575 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);
593 printf(
" CoE details: %2.2x FoE details: %2.2x EoE details: %2.2x SoE details: %2.2x\n",
595 printf(
" Ebus current: %d[mA]\n only LRD/LWR:%d\n",
610 printf(
"No slaves found!\n");
612 printf(
"End slaveinfo, close socket\n");
618 printf(
"No socket connection on %s\nExcecute as root\n",ifname);
624 int main(
int argc,
char *argv[])
627 printf(
"SOEM (Simple Open EtherCAT Master)\nSlaveinfo\n");
631 if ((argc > 2) && (strncmp(argv[2],
"-sdo",
sizeof(
"-sdo")) == 0))
printSDO =
TRUE;
632 if ((argc > 2) && (strncmp(argv[2],
"-map",
sizeof(
"-map")) == 0))
printMAP =
TRUE;
634 strcpy(
ifbuf, argv[1]);
639 printf(
"Usage: slaveinfo ifname [options]\nifname = eth0 for example\nOptions :\n -sdo : print SDO info\n -map : print mapping\n");
641 printf (
"Available adapters\n");
643 while (adapter != NULL)
645 printf (
"Description : %s, Device to use for wpcap: %s\n", adapter->
desc,adapter->
name);
646 adapter = adapter->
next;
650 printf(
"End program\n");
ec_groupt ec_group[EC_MAXGROUP]
uint16 ObjAccess[EC_MAXOELIST]
uint16 BitSize[EC_MAXEEPDO]
char * ec_ALstatuscode2string(uint16 ALstatuscode)
Headerfile for ethercatdc.c.
uint8 ec_siigetbyte(uint16 slave, uint16 address)
PACKED_END ec_slavet ec_slave[EC_MAXSLAVE]
int si_map_sdo(int slave)
char name[EC_MAXLEN_ADAPTERNAME]
uint8 MaxSub[EC_MAXODLIST]
#define ECT_SDO_PDOASSIGN
char * SDO2string(uint16 slave, uint16 index, uint8 subidx, uint16 dtype)
int si_map_sii(int slave)
char * ec_elist2string(void)
uint16 SyncM[EC_MAXEEPDO]
General typedefs and defines for EtherCAT.
Headerfile for ethercatcoe.c.
void ec_siistring(char *str, uint16 slave, uint16 Sn)
int ec_readODlist(uint16 Slave, ec_ODlistt *pODlist)
char desc[EC_MAXLEN_ADAPTERNAME]
int ec_eeprom2pdi(uint16 slave)
int ec_readOE(uint16 Item, ec_ODlistt *pODlist, ec_OElistt *pOElist)
#define ECT_SDO_SMCOMMTYPE
int ec_readODdescription(uint16 Item, ec_ODlistt *pODlist)
uint16 Index[EC_MAXODLIST]
int ec_init(char *ifname)
uint16 SMbitsize[EC_MAXSM]
int main(int argc, char *argv[])
int16 ec_siifind(uint16 slave, uint16 cat)
uint16 BitLength[EC_MAXOELIST]
int si_siiPDO(uint16 slave, uint8 t, int mapoffset, int bitoffset)
char Name[EC_MAXOELIST][EC_MAXNAME+1]
uint16 DataType[EC_MAXODLIST]
Headerfile for ethercatbase.c.
int ec_config(uint8 usetable, void *pIOmap)
boolean ec_configdc(void)
Headerfile for ethercatmain.c.
uint8 ObjectCode[EC_MAXODLIST]
ec_adaptert * ec_find_adapters(void)
char Name[EC_MAXODLIST][EC_MAXNAME+1]
int ec_SDOread(uint16 slave, uint16 index, uint8 subindex, boolean CA, int *psize, void *p, int timeout)
uint16 ec_statecheck(uint16 slave, uint16 reqstate, int timeout)
int ec_readOEsingle(uint16 Item, uint8 SubI, ec_ODlistt *pODlist, ec_OElistt *pOElist)
Headerfile for ethercatconfig.c.
uint16 Index[EC_MAXEEPDO]
void slaveinfo(char *ifname)
int si_PDOassign(uint16 slave, uint16 PDOassign, int mapoffset, int bitoffset)
uint16 DataType[EC_MAXOELIST]
char * dtype2string(uint16 dtype)
Headerfile for ethercatprint.c.