22 #define EC_MAXFOEDATA 512 76 int32 buffersize, packetnumber, prevpacket = 0;
77 uint16 fnsize, maxdata, segmentdata;
89 fnsize = (
uint16)strlen(filename);
95 FOEp->MbxHeader.length =
htoes(0x0006 + fnsize);
96 FOEp->MbxHeader.address =
htoes(0x0000);
97 FOEp->MbxHeader.priority = 0x00;
103 FOEp->Password =
htoel(password);
105 memcpy(&FOEp->FileName[0], filename, fnsize);
124 segmentdata =
etohs(aFOEp->MbxHeader.length) - 0x0006;
125 packetnumber =
etohl(aFOEp->PacketNumber);
126 if ((packetnumber == ++prevpacket) && (dataread + segmentdata <= buffersize))
128 memcpy(p, &aFOEp->Data[0], segmentdata);
129 dataread += segmentdata;
130 p = (
uint8 *)p + segmentdata;
131 if (segmentdata == maxdata)
135 FOEp->MbxHeader.length =
htoes(0x0006);
136 FOEp->MbxHeader.address =
htoes(0x0000);
137 FOEp->MbxHeader.priority = 0x00;
143 FOEp->PacketNumber =
htoel(packetnumber);
152 context->
FOEhook(slave, packetnumber, dataread);
203 int32 packetnumber, sendpacket = 0;
208 boolean worktodo, dofinalzero;
218 fnsize = (
uint16)strlen(filename);
220 if (fnsize > maxdata)
224 FOEp->MbxHeader.length =
htoes(0x0006 + fnsize);
225 FOEp->MbxHeader.address =
htoes(0x0000);
226 FOEp->MbxHeader.priority = 0x00;
232 FOEp->Password =
htoel(password);
234 memcpy(&FOEp->FileName[0], filename, fnsize);
251 switch (aFOEp->OpCode)
255 packetnumber =
etohl(aFOEp->PacketNumber);
256 if (packetnumber == sendpacket)
260 context->
FOEhook(slave, packetnumber, psize);
267 if(tsize || dofinalzero)
272 psize -= segmentdata;
275 if (!psize && (segmentdata == maxdata))
279 FOEp->MbxHeader.length =
htoes(0x0006 + segmentdata);
280 FOEp->MbxHeader.address =
htoes(0x0000);
281 FOEp->MbxHeader.priority = 0x00;
288 FOEp->PacketNumber =
htoel(sendpacket);
289 memcpy(&FOEp->Data[0], p, segmentdata);
290 p = (
uint8 *)p + segmentdata;
316 psize += segmentdata;
317 p = (
uint8 *)p - segmentdata;
325 if (aFOEp->ErrorCode == 0x8001)
char ErrorText[EC_MAXFOEDATA]
PACKED_END int ecx_FOEdefinehook(ecx_contextt *context, void *hook)
int ec_FOEwrite(uint16 slave, char *filename, uint32 password, int psize, void *p, int timeout)
int(* FOEhook)(uint16 slave, int packetnumber, int datasize)
int ec_FOEread(uint16 slave, char *filename, uint32 password, int *psize, void *p, int timeout)
char FileName[EC_MAXFOEDATA]
General typedefs and defines for EtherCAT.
void ec_clearmbx(ec_mbxbuft *Mbx)
int ecx_mbxsend(ecx_contextt *context, uint16 slave, ec_mbxbuft *mbx, int timeout)
int ec_FOEdefinehook(void *hook)
Headerfile for ethercatfoe.c.
int ecx_mbxreceive(ecx_contextt *context, uint16 slave, ec_mbxbuft *mbx, int timeout)
PACKED_BEGIN struct PACKED ec_FOEt
Headerfile for ethercatbase.c.
PACKED_BEGIN struct PACKED ec_mbxheader ec_mbxheadert
Headerfile for ethercatmain.c.
int ecx_FOEwrite(ecx_contextt *context, uint16 slave, char *filename, uint32 password, int psize, void *p, int timeout)
uint8 Data[EC_MAXFOEDATA]
int ecx_FOEread(ecx_contextt *context, uint16 slave, char *filename, uint32 password, int *psize, void *p, int timeout)
uint8 ec_mbxbuft[EC_MAXMBX+1]
uint8 ec_nextmbxcnt(uint8 cnt)