59 #define EC_MAXFOEDATA 512 113 int32 buffersize, packetnumber, prevpacket = 0;
114 uint16 fnsize, maxdata, segmentdata;
126 fnsize = strlen(filename);
128 if (fnsize > maxdata)
132 FOEp->MbxHeader.length =
htoes(0x0006 + fnsize);
133 FOEp->MbxHeader.address =
htoes(0x0000);
134 FOEp->MbxHeader.priority = 0x00;
140 FOEp->Password =
htoel(password);
142 memcpy(&FOEp->FileName[0], filename, fnsize);
161 segmentdata =
etohs(aFOEp->MbxHeader.length) - 0x0006;
162 packetnumber =
etohl(aFOEp->PacketNumber);
163 if ((packetnumber == ++prevpacket) && (dataread + segmentdata <= buffersize))
165 memcpy(p, &aFOEp->Data[0], segmentdata);
166 dataread += segmentdata;
167 p = (
uint8 *)p + segmentdata;
168 if (segmentdata == maxdata)
172 FOEp->MbxHeader.length =
htoes(0x0006);
173 FOEp->MbxHeader.address =
htoes(0x0000);
174 FOEp->MbxHeader.priority = 0x00;
180 FOEp->PacketNumber =
htoel(packetnumber);
189 context->
FOEhook(slave, packetnumber, dataread);
240 int32 packetnumber, sendpacket = 0;
245 boolean worktodo, dofinalzero;
255 fnsize = strlen(filename);
257 if (fnsize > maxdata)
261 FOEp->MbxHeader.length =
htoes(0x0006 + fnsize);
262 FOEp->MbxHeader.address =
htoes(0x0000);
263 FOEp->MbxHeader.priority = 0x00;
269 FOEp->Password =
htoel(password);
271 memcpy(&FOEp->FileName[0], filename, fnsize);
288 switch (aFOEp->OpCode)
292 packetnumber =
etohl(aFOEp->PacketNumber);
293 if (packetnumber == sendpacket)
297 context->
FOEhook(slave, packetnumber, psize);
304 if(tsize || dofinalzero)
309 psize -= segmentdata;
312 if (!psize && (segmentdata == maxdata))
316 FOEp->MbxHeader.length =
htoes(0x0006 + segmentdata);
317 FOEp->MbxHeader.address =
htoes(0x0000);
318 FOEp->MbxHeader.priority = 0x00;
325 FOEp->PacketNumber =
htoel(sendpacket);
326 memcpy(&FOEp->Data[0], p, segmentdata);
327 p = (
uint8 *)p + segmentdata;
353 psize += segmentdata;
354 p = (
uint8 *)p - segmentdata;
385 int ec_FOEdefinehook(
void *hook)
390 int ec_FOEread(
uint16 slave,
char *filename,
uint32 password,
int *psize,
void *p,
int timeout)
392 return ecx_FOEread(&ecx_context, slave, filename, password, psize, p, timeout);
395 int ec_FOEwrite(
uint16 slave,
char *filename,
uint32 password,
int psize,
void *p,
int timeout)
397 return ecx_FOEwrite(&ecx_context, slave, filename, password, psize, p, timeout);
char ErrorText[EC_MAXFOEDATA]
PACKED_END int ecx_FOEdefinehook(ecx_contextt *context, void *hook)
void ec_clearmbx(ec_mbxbuft *Mbx)
char FileName[EC_MAXFOEDATA]
General typedefs and defines for EtherCAT.
PACKED_BEGIN struct PACKED ec_mbxheadert
Headerfile for ethercatfoe.c.
uint8 ec_nextmbxcnt(uint8 cnt)
int(* FOEhook)(uint16 slave, int packetnumber, int datasize)
PACKED_BEGIN struct PACKED ec_FOEt
int ecx_mbxsend(ecx_contextt *context, uint16 slave, ec_mbxbuft *mbx, int timeout)
Headerfile for ethercatbase.c.
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_mbxreceive(ecx_contextt *context, uint16 slave, ec_mbxbuft *mbx, int timeout)
int ecx_FOEread(ecx_contextt *context, uint16 slave, char *filename, uint32 password, int *psize, void *p, int timeout)
uint8 ec_mbxbuft[EC_MAXMBX+1]