26 #define EC_LOCALDELAY 200 223 memset(&Ec, 0,
sizeof(Ec));
244 memset(&Ec, 0,
sizeof(Ec));
269 memset(&Ec, 0,
sizeof(Ec));
352 mapb = address - (mapw << 5);
356 retval = context->
esibuf[address];
380 mapb = (eadr << 1) - (mapw << 5);
381 for(lp = 0 ; lp < cnt ; lp++)
384 context->
esimap[mapw] |= (1 << mapb);
392 retval = context->
esibuf[address];
416 while ((p != cat) && (p != 0xffff))
459 for (i = 1; i <= Sn; i++)
469 for (j = 1; j <= l; j++)
616 uint16 a , w, c, e, er, Size;
649 for (er = 1; er <= e; er++)
671 while (c < PDO->Length);
681 #define MAX_FPRD_MULTI 64 691 port = context->
port;
697 while(++slcnt < (n - 1))
710 for(slcnt = 0 ; slcnt < n ; slcnt++)
712 memcpy(slstatlst + slcnt, &(port->
rxbuf[idx][sldatapos[slcnt]]),
sizeof(
ec_alstatust));
725 uint16 slave, fslave, lslave, configadr, lowest, rval, bitwisestate;
728 boolean noerrorflag, allslavessamestate;
729 boolean allslavespresent =
FALSE;
739 allslavespresent =
TRUE;
743 bitwisestate = (rval & 0x0f);
755 switch (bitwisestate)
762 allslavessamestate =
TRUE;
766 allslavessamestate =
FALSE;
770 if (noerrorflag && allslavessamestate && allslavespresent)
776 for (slave = 1; slave <= *(context->
slavecount); slave++)
781 lowest = bitwisestate;
797 for (slave = fslave; slave <= lslave; slave++)
802 slca[slave - fslave] = configadr;
803 sl[slave - fslave] = zero;
806 for (slave = fslave; slave <= lslave; slave++)
809 rval =
etohs(sl[slave - fslave].alstatus);
811 if ((rval & 0xf) < lowest)
813 lowest = (rval & 0xf);
835 uint16 configadr, slstate;
864 uint16 configadr, state, rval;
885 slstat.alstatuscode = 0;
887 rval =
etohs(slstat.alstatus);
890 state = rval & 0x000f;
891 if (state != reqstate)
945 SMstat =
etohs(SMstat);
953 if ((wkc > 0) && ((SMstat & 0x08) == 0))
970 uint16 mbxwo,mbxl,configadr;
1003 uint16 mbxro,mbxl,configadr;
1024 SMstat =
etohs(SMstat);
1032 if ((wkc > 0) && ((SMstat & 0x08) > 0))
1039 if ((wkc > 0) && ((mbxh->mbxtype & 0x0f) == 0x00))
1045 else if ((wkc > 0) && ((mbxh->mbxtype & 0x0f) ==
ECT_MBXT_COE))
1048 if ((
etohs(EMp->CANOpen) >> 12) == 0x01)
1055 else if ((wkc > 0) && ((mbxh->mbxtype & 0x0f) ==
ECT_MBXT_EOE))
1066 if (context->
EOEhook(context, slave, eoembx) > 0)
1079 SMstat =
htoes(SMstat);
1081 SMstat =
etohs(SMstat);
1089 SMstat =
etohs(SMstat);
1191 int wkc = 1, cnt = 0;
1224 int wkc = 1, cnt = 0;
1245 int wkc, cnt = 0, retval = 0;
1257 *estat =
etohs(*estat);
1260 if ((*estat & EC_ESTAT_BUSY) == 0)
1281 int wkc, cnt, nackcnt = 0;
1296 ed.addr =
htoes(eeproma);
1341 while ((nackcnt > 0) && (nackcnt < 3));
1359 int wkc, rval = 0, cnt = 0, nackcnt = 0;
1406 while ((nackcnt > 0) && (nackcnt < 3));
1414 int wkc, cnt = 0, retval = 0;
1426 *estat =
etohs(*estat);
1429 if ((*estat & EC_ESTAT_BUSY) == 0)
1450 int wkc, cnt, nackcnt = 0;
1465 ed.addr =
htoes(eeproma);
1510 while ((nackcnt > 0) && (nackcnt < 3));
1528 int wkc, rval = 0, cnt = 0, nackcnt = 0;
1573 while ((nackcnt > 0) && (nackcnt < 3));
1601 ed.addr =
htoes(eeproma);
1705 boolean first=
FALSE;
1706 uint16 currentsegment = 0;
1716 if(use_overlap_io ==
TRUE)
1727 iomapinputoffset = 0;
1763 context->
DCl = sublength;
1774 length -= sublength;
1775 LogAdr += sublength;
1777 }
while (length && (currentsegment < context->grouplist[group].nsegments));
1790 if((length - sublength) < 0)
1801 context->
DCl = sublength;
1812 length -= sublength;
1813 LogAdr += sublength;
1815 }
while (length && (currentsegment < context->grouplist[group].nsegments));
1829 iomapinputoffset = 0;
1842 context->
DCl = sublength;
1856 ecx_pushindex(context, idx, (data + iomapinputoffset), sublength);
1857 length -= sublength;
1858 LogAdr += sublength;
1860 }
while (length && (currentsegment < context->grouplist[group].nsegments));
1917 boolean first =
FALSE;
1939 wkc =
etohs(le_wkc);
1940 memcpy(&le_DCtime, &(context->
port->
rxbuf[idx][context->
DCtO]),
sizeof(le_DCtime));
1958 wkc =
etohs(le_wkc) * 2;
1959 memcpy(&le_DCtime, &(context->
port->
rxbuf[idx][context->
DCtO]),
sizeof(le_DCtime));
2031 return ecx_init(&ecx_context, ifname);
2107 return ecx_siiSM (&ecx_context, slave, SM);
2131 return ecx_siiPDO (&ecx_context, slave, PDO, t);
2187 return ecx_mbxsend (&ecx_context, slave, mbx, timeout);
int ecx_send_processdata(ecx_contextt *context)
int ecx_init_redundant(ecx_contextt *context, ecx_redportt *redport, const char *ifname, char *if2name)
int ecx_adddatagram(ecx_portt *port, void *frame, uint8 com, uint8 idx, boolean more, uint16 ADP, uint16 ADO, uint16 length, void *data)
int ecx_mbxempty(ecx_contextt *context, uint16 slave, int timeout)
static uint32 ec_esimap[EC_MAXEEPBITMAP]
int ec_writeeepromAP(uint16 aiadr, uint16 eeproma, uint16 data, int timeout)
uint64 ec_readeepromFP(uint16 configadr, uint16 eeproma, int timeout)
boolean osal_timer_is_expired(osal_timert *self)
uint16 ec_eeprom_waitnotbusyFP(uint16 configadr, uint16 *estat, int timeout)
uint8 ecx_siigetbyte(ecx_contextt *context, uint16 slave, uint16 address)
uint8 ec_siigetbyte(uint16 slave, uint16 address)
int ec_send_processdata(void)
void ec_free_adapters(ec_adaptert *adapter)
boolean ec_poperror(ec_errort *Ec)
void ecx_close(ecx_contextt *context)
void oshw_free_adapters(ec_adaptert *adapter)
uint16 ecx_statecheck(ecx_contextt *context, uint16 slave, uint16 reqstate, int timeout)
void ecx_pusherror(ecx_contextt *context, const ec_errort *Ec)
int ecx_send_overlap_processdata(ecx_contextt *context)
Headerfile for all ethercat headers.
int ec_receive_processdata(int timeout)
int ecx_FPWRw(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 data, int timeout)
PACKED_BEGIN struct PACKED ec_SMcommtype ec_SMcommtypet
PACKED_BEGIN struct PACKED ec_etherheadert
int ec_init(const char *ifname)
ec_adaptert * oshw_find_adapters(void)
void ecx_siistring(ecx_contextt *context, char *str, uint16 slave, uint16 Sn)
int ecx_FPWR(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
int ecx_closenic(ecx_portt *port)
int ecx_setupdatagram(ecx_portt *port, void *frame, uint8 com, uint8 idx, uint16 ADP, uint16 ADO, uint16 length, void *data)
PACKED_BEGIN struct PACKED ec_eepromt
void ecx_packeterror(ecx_contextt *context, uint16 Slave, uint16 Index, uint8 SubIdx, uint16 ErrorCode)
int(* EOEhook)(ecx_contextt *context, uint16 slave, void *eoembx)
uint16 Index[EC_MAXEEPDO]
int ecx_eeprom2master(ecx_contextt *context, uint16 slave)
int ecx_APWR(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
uint16 oshw_htons(uint16 host)
uint32 ec_readeeprom(uint16 slave, uint16 eeproma, int timeout)
uint16 ecx_siiFMMU(ecx_contextt *context, uint16 slave, ec_eepromFMMUt *FMMU)
uint32 ecx_readeeprom(ecx_contextt *context, uint16 slave, uint16 eeproma, int timeout)
void ec_siistring(char *str, uint16 slave, uint16 Sn)
static int ecx_main_send_processdata(ecx_contextt *context, uint8 group, boolean use_overlap_io)
int ecx_FPRD(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
void ecx_esidump(ecx_contextt *context, uint16 slave, uint8 *esibuf)
void ec_clearmbx(ec_mbxbuft *Mbx)
static ec_eepromFMMUt ec_FMMU
uint16 ec_siiFMMU(uint16 slave, ec_eepromFMMUt *FMMU)
int ecx_getindex(ecx_portt *port)
static void ecx_mbxerror(ecx_contextt *context, uint16 Slave, uint16 Detail)
PACKED_END struct ec_idxstack ec_idxstackT
int ec_init_redundant(const char *ifname, char *if2name)
uint32 IOsegment[EC_MAXIOSEGMENTS]
uint16 ecx_siiSMnext(ecx_contextt *context, uint16 slave, ec_eepromSMt *SM, uint16 n)
int ec_eeprom2pdi(uint16 slave)
int ecx_send_overlap_processdata_group(ecx_contextt *context, uint8 group)
int ecx_writeeeprom(ecx_contextt *context, uint16 slave, uint16 eeproma, uint16 data, int timeout)
int ecx_mbxsend(ecx_contextt *context, uint16 slave, ec_mbxbuft *mbx, int timeout)
PACKED_END PACKED_BEGIN struct PACKED ec_mbxerrort
int ec_send_overlap_processdata_group(uint8 group)
ec_timet osal_current_time(void)
int ecx_init(ecx_contextt *context, const char *ifname)
static void ecx_mbxemergencyerror(ecx_contextt *context, uint16 Slave, uint16 ErrorCode, uint16 ErrorReg, uint8 b1, uint16 w1, uint16 w2)
int ecx_BRD(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
int ecx_writeeepromAP(ecx_contextt *context, uint16 aiadr, uint16 eeproma, uint16 data, int timeout)
#define put_unaligned32(val, ptr)
uint16 SMbitsize[EC_MAXSM]
uint32 ecx_readeeprom2(ecx_contextt *context, uint16 slave, int timeout)
ec_errort Error[EC_MAXELIST+1]
void ec_pusherror(const ec_errort *Ec)
PACKED_END PACKED_BEGIN struct PACKED ec_PDOassign ec_PDOassignt
int ec_eeprom2master(uint16 slave)
int ec_send_overlap_processdata(void)
int ecx_writeeepromFP(ecx_contextt *context, uint16 configadr, uint16 eeproma, uint16 data, int timeout)
uint64 ecx_readeepromAP(ecx_contextt *context, uint16 aiadr, uint16 eeproma, int timeout)
int ec_siiPDO(uint16 slave, ec_eepromPDOt *PDO, uint8 t)
int osal_usleep(uint32 usec)
int ecx_writestate(ecx_contextt *context, uint16 slave)
PACKED_END PACKED_BEGIN struct PACKED ec_emcyt
void ec_packeterror(uint16 Slave, uint16 Index, uint8 SubIdx, uint16 ErrorCode)
int ecx_mbxreceive(ecx_contextt *context, uint16 slave, ec_mbxbuft *mbx, int timeout)
void ec_readeeprom1(uint16 slave, uint16 eeproma)
int ecx_receive_processdata_group(ecx_contextt *context, uint8 group, int timeout)
int ecx_waitinframe(ecx_portt *port, int idx, int timeout)
PACKED_BEGIN struct PACKED ec_EOEt
PACKED_END PACKED_BEGIN struct PACKED ec_alstatus ec_alstatust
uint16 ec_siiSM(uint16 slave, ec_eepromSMt *SM)
int ec_mbxsend(uint16 slave, ec_mbxbuft *mbx, int timeout)
uint32 ec_readeeprom2(uint16 slave, int timeout)
int ecx_BWR(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
int ecx_FPRD_multi(ecx_contextt *context, int n, uint16 *configlst, ec_alstatust *slstatlst, int timeout)
int16 ec_siifind(uint16 slave, uint16 cat)
int ecx_APRD(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
int ecx_send_processdata_group(ecx_contextt *context, uint8 group)
int ec_mbxempty(uint16 slave, int timeout)
int ec_send_processdata_group(uint8 group)
static ec_eepromSMt ec_SM
int ecx_outframe_red(ecx_portt *port, int idx)
void ecx_readeeprom1(ecx_contextt *context, uint16 slave, uint16 eeproma)
static void ecx_clearindex(ecx_contextt *context)
uint64 ecx_readeepromFP(ecx_contextt *context, uint16 configadr, uint16 eeproma, int timeout)
PACKED_END PACKED_BEGIN struct PACKED ec_PDOdesc ec_PDOdesct
static ec_idxstackT ec_idxstack
int ec_writestate(uint16 slave)
boolean ecx_iserror(ecx_contextt *context)
int ec_writeeeprom(uint16 slave, uint16 eeproma, uint16 data, int timeout)
int ecx_setupnic(ecx_portt *port, const char *ifname, int secondary)
#define EC_DEFAULTRETRIES
int ecx_siiPDO(ecx_contextt *context, uint16 slave, ec_eepromPDOt *PDO, uint8 t)
int ecx_eeprom2pdi(ecx_contextt *context, uint16 slave)
PACKED_BEGIN struct PACKED ec_mbxheader ec_mbxheadert
uint64 ec_readeepromAP(uint16 aiadr, uint16 eeproma, int timeout)
int ec_receive_processdata_group(uint8 group, int timeout)
boolean ecx_poperror(ecx_contextt *context, ec_errort *Ec)
uint16 ec_eeprom_waitnotbusyAP(uint16 aiadr, uint16 *estat, int timeout)
uint16 ec_siiSMnext(uint16 slave, ec_eepromSMt *SM, uint16 n)
static int ecx_pullindex(ecx_contextt *context)
void ec_esidump(uint16 slave, uint8 *esibuf)
int ecx_readstate(ecx_contextt *context)
ec_adaptert * ec_find_adapters(void)
int ec_writeeepromFP(uint16 configadr, uint16 eeproma, uint16 data, int timeout)
int16 ecx_siifind(ecx_contextt *context, uint16 slave, uint16 cat)
int ecx_srconfirm(ecx_portt *port, int idx, int timeout)
static void ecx_pushindex(ecx_contextt *context, uint8 idx, void *data, uint16 length)
void osal_timer_start(osal_timert *self, uint32 timeout_usec)
int ecx_receive_processdata(ecx_contextt *context, int timeout)
uint16 ecx_siiSM(ecx_contextt *context, uint16 slave, ec_eepromSMt *SM)
static uint8 esibuf[EC_MAXEEPBUF]
uint16 ec_statecheck(uint16 slave, uint16 reqstate, int timeout)
uint16 SyncM[EC_MAXEEPDO]
uint16 ecx_eeprom_waitnotbusyFP(ecx_contextt *context, uint16 configadr, uint16 *estat, int timeout)
static ec_eringt ec_elist
int ec_mbxreceive(uint16 slave, ec_mbxbuft *mbx, int timeout)
void ecx_setbufstat(ecx_portt *port, int idx, int bufstat)
uint16 BitSize[EC_MAXEEPDO]
#define EOE_HDR_FRAME_TYPE_GET(x)
uint8 ec_mbxbuft[EC_MAXMBX+1]
uint8 ec_nextmbxcnt(uint8 cnt)
#define put_unaligned64(val, ptr)
uint16 ecx_eeprom_waitnotbusyAP(ecx_contextt *context, uint16 aiadr, uint16 *estat, int timeout)
static uint8 ec_esibuf[EC_MAXEEPBUF]