154 boolean CA,
int *psize,
void *p,
int timeout)
157 uint16 bytesize, Framedatasize;
172 SDOp->MbxHeader.length =
htoes(0x000a);
173 SDOp->MbxHeader.address =
htoes(0x0000);
174 SDOp->MbxHeader.priority = 0x00;
188 SDOp->Index =
htoes(index);
189 if (CA && (subindex > 1))
193 SDOp->SubIndex = subindex;
206 if (((aSDOp->MbxHeader.mbxtype & 0x0f) ==
ECT_MBXT_COE) &&
208 (aSDOp->Index == SDOp->Index))
210 if ((aSDOp->Command & 0x02) > 0)
213 bytesize = 4 - ((aSDOp->Command >> 2) & 0x03);
214 if (*psize >= bytesize)
217 memcpy(p, &aSDOp->ldata[0], bytesize);
229 SDOlen =
etohl(aSDOp->ldata[0]);
231 if (SDOlen <= *psize)
236 Framedatasize = (
etohs(aSDOp->MbxHeader.length) - 10);
237 if (Framedatasize < SDOlen)
240 memcpy(hp, &aSDOp->ldata[1], Framedatasize);
243 *psize = Framedatasize;
249 SDOp->MbxHeader.length =
htoes(0x000a);
250 SDOp->MbxHeader.address =
htoes(0x0000);
251 SDOp->MbxHeader.priority = 0x00;
257 SDOp->Index =
htoes(index);
258 SDOp->SubIndex = subindex;
272 if ((((aSDOp->MbxHeader.mbxtype & 0x0f) ==
ECT_MBXT_COE) &&
274 ((aSDOp->Command & 0xe0) == 0x00)))
277 Framedatasize =
etohs(aSDOp->MbxHeader.length) - 3;
278 if ((aSDOp->Command & 0x01) > 0)
281 if (Framedatasize == 7)
283 Framedatasize = Framedatasize - ((aSDOp->Command & 0x0e) >> 1);
285 memcpy(hp, &(aSDOp->Index), Framedatasize);
290 memcpy(hp, &(aSDOp->Index), Framedatasize);
295 *psize += Framedatasize;
309 toggle = toggle ^ 0x10;
316 memcpy(bp, &aSDOp->ldata[1], SDOlen);
364 boolean CA,
int psize,
void *p,
int Timeout)
382 if ((psize <= 4) && !CA)
384 SDOp->MbxHeader.length =
htoes(0x000a);
385 SDOp->MbxHeader.address =
htoes(0x0000);
386 SDOp->MbxHeader.priority = 0x00;
393 SDOp->Index =
htoes(Index);
397 memcpy(&SDOp->ldata[0], hp, psize);
408 if (((aSDOp->MbxHeader.mbxtype & 0x0f) ==
ECT_MBXT_COE) &&
410 (aSDOp->Index == SDOp->Index) &&
411 (aSDOp->SubIndex == SDOp->SubIndex))
433 framedatasize = psize;
435 if (framedatasize > maxdata)
437 framedatasize = maxdata;
440 SDOp->MbxHeader.length =
htoes(0x0a + framedatasize);
441 SDOp->MbxHeader.address =
htoes(0x0000);
442 SDOp->MbxHeader.priority = 0x00;
456 SDOp->Index =
htoes(Index);
458 if (CA && (SubIndex > 1))
462 SDOp->ldata[0] =
htoel(psize);
465 memcpy(&SDOp->ldata[1], hp, framedatasize);
467 psize -= framedatasize;
478 if (((aSDOp->MbxHeader.mbxtype & 0x0f) ==
ECT_MBXT_COE) &&
480 (aSDOp->Index == SDOp->Index) &&
481 (aSDOp->SubIndex == SDOp->SubIndex))
490 framedatasize = psize;
492 SDOp->Command = 0x01;
493 if (framedatasize > maxdata)
495 framedatasize = maxdata;
497 SDOp->Command = 0x00;
499 if (!NotLast && (framedatasize < 7))
501 SDOp->MbxHeader.length =
htoes(0x0a);
502 SDOp->Command = 0x01 + ((7 - framedatasize) << 1);
506 SDOp->MbxHeader.length =
htoes(framedatasize + 3);
508 SDOp->MbxHeader.address =
htoes(0x0000);
509 SDOp->MbxHeader.priority = 0x00;
515 SDOp->Command = SDOp->Command + toggle;
517 memcpy(&SDOp->Index, hp, framedatasize);
520 psize -= framedatasize;
530 if (((aSDOp->MbxHeader.mbxtype & 0x0f) ==
ECT_MBXT_COE) &&
532 ((aSDOp->Command & 0xe0) == 0x20))
551 toggle = toggle ^ 0x10;
599 framedatasize = psize;
600 if (framedatasize > maxdata)
602 framedatasize = maxdata;
604 SDOp->MbxHeader.length =
htoes(0x02 + framedatasize);
605 SDOp->MbxHeader.address =
htoes(0x0000);
606 SDOp->MbxHeader.priority = 0x00;
613 memcpy(&SDOp->Command, p, framedatasize);
646 SDOp->MbxHeader.length =
htoes(0x02);
647 SDOp->MbxHeader.address =
htoes(0x0000);
648 SDOp->MbxHeader.priority = 0x00;
664 if (((aSDOp->MbxHeader.mbxtype & 0x0f) ==
ECT_MBXT_COE) &&
668 framedatasize = (aSDOp->MbxHeader.length - 2);
669 if (*psize >= framedatasize)
672 memcpy(p, &aSDOp->Command, framedatasize);
674 *psize = framedatasize;
710 uint16 idxloop, nidx, subidxloop, rdat, idx, subidx;
712 int wkc, bsize = 0, rdl;
715 rdl =
sizeof(rdat); rdat = 0;
720 if ((wkc > 0) && (rdat > 0))
726 for (idxloop = 1; idxloop <= nidx; idxloop++)
728 rdl =
sizeof(rdat); rdat = 0;
735 rdl =
sizeof(subcnt); subcnt = 0;
740 for (subidxloop = 1; subidxloop <= subidx; subidxloop++)
742 rdl =
sizeof(rdat2); rdat2 = 0;
745 rdat2 =
etohl(rdat2);
753 rdl =
sizeof(rdat); rdat =
htoes(0xff);
756 bsize +=
etohs(rdat);
774 uint16 idxloop, nidx, subidxloop, idx, subidx;
775 int wkc, bsize = 0, rdl;
783 if ((wkc > 0) && (context->
PDOassign->n > 0))
788 for (idxloop = 1; idxloop <= nidx; idxloop++)
799 for (subidxloop = 1; subidxloop <= subidx; subidxloop++)
850 rdl =
sizeof(nSM); nSM = 0;
854 if ((wkc > 0) && (nSM > 2))
862 for (iSM = 2 ; iSM <= nSM ; iSM++)
864 rdl =
sizeof(tSM); tSM = 0;
870 if((iSM == 2) && (tSM == 2))
878 if((iSM == 2) && (tSM == 0))
882 if((iSM == 3) && (tSM == 0))
895 if ((tSM == 3) || (tSM == 4))
920 if ((*Isize > 0) || (*Osize > 0))
956 if ((wkc > 0) && (context->
SMcommtype->n > 2))
967 for (iSM = 2 ; iSM <= nSM ; iSM++)
972 if((iSM == 2) && (tSM == 2))
989 if ((tSM == 3) || (tSM == 4))
1013 if ((*Isize > 0) || (*Osize > 0))
1037 pODlist->
Slave = Slave;
1045 SDOp->MbxHeader.length =
htoes(0x0008);
1046 SDOp->MbxHeader.address =
htoes(0x0000);
1047 SDOp->MbxHeader.priority = 0x00;
1055 SDOp->Fragments = 0;
1056 SDOp->wdata[0] =
htoes(0x01);
1076 if (((aSDOp->MbxHeader.mbxtype & 0x0f) ==
ECT_MBXT_COE) &&
1082 n = (
etohs(aSDOp->MbxHeader.length) - (6 + 2)) / 2;
1087 n = (
etohs(aSDOp->MbxHeader.length) - 6) / 2;
1103 for (i = 0; i <
n; i++)
1105 pODlist->
Index[sp + i] =
etohs(aSDOp->wdata[i + offset]);
1109 if (aSDOp->Fragments > 0)
1134 while ((x <= 128) && !stop);
1154 Slave = pODlist->
Slave;
1157 pODlist->
MaxSub[Item] = 0;
1158 pODlist->
Name[Item][0] = 0;
1165 SDOp->MbxHeader.length =
htoes(0x0008);
1166 SDOp->MbxHeader.address =
htoes(0x0000);
1167 SDOp->MbxHeader.priority = 0x00;
1175 SDOp->Fragments = 0;
1176 SDOp->wdata[0] =
htoes(pODlist->
Index[Item]);
1188 if (((aSDOp->MbxHeader.mbxtype & 0x0f) ==
ECT_MBXT_COE) &&
1191 n = (
etohs(aSDOp->MbxHeader.length) - 12);
1198 pODlist->
MaxSub[Item] = aSDOp->bdata[4];
1200 strncpy(pODlist->
Name[Item] , (
char *)&aSDOp->bdata[6], n);
1201 pODlist->
Name[Item][
n] = 0x00;
1241 Slave = pODlist->
Slave;
1242 Index = pODlist->
Index[Item];
1249 SDOp->MbxHeader.length =
htoes(0x000a);
1250 SDOp->MbxHeader.address =
htoes(0x0000);
1251 SDOp->MbxHeader.priority = 0x00;
1259 SDOp->Fragments = 0;
1260 SDOp->wdata[0] =
htoes(Index);
1261 SDOp->bdata[2] = SubI;
1262 SDOp->bdata[3] = 1 + 2 + 4;
1274 if (((aSDOp->MbxHeader.mbxtype & 0x0f) ==
ECT_MBXT_COE) &&
1278 n = (
etohs(aSDOp->MbxHeader.length) - 16);
1287 pOElist->
ValueInfo[SubI] = aSDOp->bdata[3];
1292 strncpy(pOElist->
Name[SubI] , (
char *)&aSDOp->wdata[5], n);
1293 pOElist->
Name[SubI][
n] = 0x00;
1330 SubI = pODlist->
MaxSub[Item];
1332 for (SubCount = 0; SubCount <= SubI; SubCount++)
1348 boolean CA,
int *psize,
void *p,
int timeout)
1350 return ecx_SDOread(&ecx_context, slave,
index, subindex, CA, psize, p, timeout);
1354 boolean CA,
int psize,
void *p,
int Timeout)
1359 int ec_RxPDO(
uint16 Slave,
uint16 RxPDOnumber,
int psize,
void *p)
1361 return ecx_RxPDO(&ecx_context, Slave, RxPDOnumber, psize, p);
1364 int ec_TxPDO(
uint16 slave,
uint16 TxPDOnumber ,
int *psize,
void *p,
int timeout)
1366 return ecx_TxPDO(&ecx_context, slave, TxPDOnumber, psize, p, timeout);
1381 int ec_readPDOmap(
uint16 Slave,
int *Osize,
int *Isize)
1386 int ec_readPDOmapCA(
uint16 Slave,
int *Osize,
int *Isize)
1408 return ecx_readOE(&ecx_context, Item, pODlist, pOElist);
uint16 ObjAccess[EC_MAXOELIST]
int ecx_readPDOmapCA(ecx_contextt *context, uint16 Slave, int *Osize, int *Isize)
int ecx_SDOread(ecx_contextt *context, uint16 slave, uint16 index, uint8 subindex, boolean CA, int *psize, void *p, int timeout)
uint8 MaxSub[EC_MAXODLIST]
int ecx_readODdescription(ecx_contextt *context, uint16 Item, ec_ODlistt *pODlist)
#define ECT_SDO_PDOASSIGN
int ecx_RxPDO(ecx_contextt *context, uint16 Slave, uint16 RxPDOnumber, int psize, void *p)
int ecx_readODlist(ecx_contextt *context, uint16 Slave, ec_ODlistt *pODlist)
uint8 ValueInfo[EC_MAXOELIST]
void ecx_pusherror(ecx_contextt *context, const ec_errort *Ec)
void ec_clearmbx(ec_mbxbuft *Mbx)
void ecx_packeterror(ecx_contextt *context, uint16 Slave, uint16 Index, uint8 SubIdx, uint16 ErrorCode)
PACKED_END PACKED_BEGIN struct PACKED ec_SDOservicet
int ecx_TxPDO(ecx_contextt *context, uint16 slave, uint16 TxPDOnumber, int *psize, void *p, int timeout)
int ecx_readOEsingle(ecx_contextt *context, uint16 Item, uint8 SubI, ec_ODlistt *pODlist, ec_OElistt *pOElist)
General typedefs and defines for EtherCAT.
Headerfile for ethercatcoe.c.
ec_timet osal_current_time(void)
#define ECT_SDO_SMCOMMTYPE
PACKED_END PACKED_BEGIN struct PACKED ec_PDOassignt
PACKED_BEGIN struct PACKED ec_mbxheadert
int ecx_SDOwrite(ecx_contextt *context, uint16 Slave, uint16 Index, uint8 SubIndex, boolean CA, int psize, void *p, int Timeout)
uint16 Index[EC_MAXODLIST]
PACKED_END void ecx_SDOerror(ecx_contextt *context, uint16 Slave, uint16 Index, uint8 SubIdx, int32 AbortCode)
uint8 ec_nextmbxcnt(uint8 cnt)
uint16 BitLength[EC_MAXOELIST]
PACKED_END PACKED_BEGIN struct PACKED ec_PDOdesct
static void ecx_SDOinfoerror(ecx_contextt *context, uint16 Slave, uint16 Index, uint8 SubIdx, int32 AbortCode)
char Name[EC_MAXOELIST][EC_MAXNAME+1]
int ecx_mbxsend(ecx_contextt *context, uint16 slave, ec_mbxbuft *mbx, int timeout)
uint16 DataType[EC_MAXODLIST]
ec_PDOassignt * PDOassign
Headerfile for ethercatbase.c.
int ecx_readPDOassignCA(ecx_contextt *context, uint16 Slave, uint16 PDOassign)
Headerfile for ethercatmain.c.
uint8 ObjectCode[EC_MAXODLIST]
int ecx_readPDOassign(ecx_contextt *context, uint16 Slave, uint16 PDOassign)
ec_SMcommtypet * SMcommtype
PACKED_BEGIN struct PACKED ec_SDOt
char Name[EC_MAXODLIST][EC_MAXNAME+1]
int ecx_mbxreceive(ecx_contextt *context, uint16 slave, ec_mbxbuft *mbx, int timeout)
int ecx_readOE(ecx_contextt *context, uint16 Item, ec_ODlistt *pODlist, ec_OElistt *pOElist)
int ecx_readPDOmap(ecx_contextt *context, uint16 Slave, int *Osize, int *Isize)
PACKED_BEGIN struct PACKED ec_SMcommtypet
uint16 DataType[EC_MAXOELIST]
uint8 ec_mbxbuft[EC_MAXMBX+1]