63 #define EC_LOCALDELAY 200 130 boolean EcatError =
FALSE;
382 mapb = address - (mapw << 5);
409 mapb = (eadr << 1) - (mapw << 5);
410 for(lp = 0 ; lp < cnt ; lp++)
413 context->
esimap[mapw] |= (1 << mapb);
445 while ((p != cat) && (p != 0xffff))
488 for (i = 1; i <= Sn; i++)
498 for (j = 1; j <= l; j++)
645 uint16 a , w, c, e, er, Size;
678 for (er = 1; er <= e; er++)
716 uint16 slave, configadr, lowest, rval;
721 for (slave = 1; slave <= *(context->
slavecount); slave++)
725 slstat.alstatuscode = 0;
727 rval =
etohs(slstat.alstatus);
749 uint16 configadr, slstate;
775 uint16 configadr, state, rval;
796 slstat.alstatuscode = 0;
798 rval =
etohs(slstat.alstatus);
801 state = rval & 0x000f;
802 if (state != reqstate)
855 SMstat =
etohs(SMstat);
863 if ((wkc > 0) && ((SMstat & 0x08) == 0))
880 uint16 mbxwo,mbxl,configadr;
913 uint16 mbxro,mbxl,configadr;
933 SMstat =
etohs(SMstat);
941 if ((wkc > 0) && ((SMstat & 0x08) > 0))
973 SMstat =
htoes(SMstat);
975 SMstat =
etohs(SMstat);
983 SMstat =
etohs(SMstat);
1084 int wkc = 1, cnt = 0;
1117 int wkc = 1, cnt = 0;
1138 int wkc, cnt = 0, retval = 0;
1149 *estat =
etohs(*estat);
1152 if ((*estat & EC_ESTAT_BUSY) == 0)
1173 int wkc, cnt, nackcnt = 0;
1188 ed.addr =
htoes(eeproma);
1233 while ((nackcnt > 0) && (nackcnt < 3));
1251 int wkc, rval = 0, cnt = 0, nackcnt = 0;
1298 while ((nackcnt > 0) && (nackcnt < 3));
1306 int wkc, cnt = 0, retval = 0;
1317 *estat =
etohs(*estat);
1320 if ((*estat & EC_ESTAT_BUSY) == 0)
1341 int wkc, cnt, nackcnt = 0;
1356 ed.addr =
htoes(eeproma);
1401 while ((nackcnt > 0) && (nackcnt < 3));
1419 int wkc, rval = 0, cnt = 0, nackcnt = 0;
1464 while ((nackcnt > 0) && (nackcnt < 3));
1492 ed.addr =
htoes(eeproma);
1583 boolean first=
FALSE;
1584 uint16 currentsegment = 0;
1629 context->
DCl = sublength;
1640 length -= sublength;
1641 LogAdr += sublength;
1643 }
while (length && (currentsegment < context->grouplist[group].nsegments));
1656 if((length - sublength) < 0)
1667 context->
DCl = sublength;
1678 length -= sublength;
1679 LogAdr += sublength;
1681 }
while (length && (currentsegment < context->grouplist[group].nsegments));
1706 context->
DCl = sublength;
1717 length -= sublength;
1718 LogAdr += sublength;
1720 }
while (length && (currentsegment < context->grouplist[group].nsegments));
1742 boolean first =
FALSE;
1764 wkc =
etohs(le_wkc);
1765 memcpy(&le_DCtime, &(context->
port->
rxbuf[idx][context->
DCtO]),
sizeof(le_DCtime));
1782 wkc =
etohs(le_wkc) * 2;
1783 memcpy(&le_DCtime, &(context->
port->
rxbuf[idx][context->
DCtO]),
sizeof(le_DCtime));
1825 boolean ec_iserror(
void)
1846 int ec_init(
char * ifname)
1848 return ecx_init(&ecx_context, ifname);
1851 int ec_init_redundant(
char *ifname,
char *if2name)
1883 return ecx_siiSM (&ecx_context, slave, SM);
1893 return ecx_siiPDO (&ecx_context, slave, PDO, t);
1896 int ec_readstate(
void)
1901 int ec_writestate(
uint16 slave)
1911 int ec_mbxempty(
uint16 slave,
int timeout)
1918 return ecx_mbxsend (&ecx_context, slave, mbx, timeout);
1941 int ec_eeprom2master(
uint16 slave)
1946 int ec_eeprom2pdi(
uint16 slave)
1991 int ec_send_processdata_group(
uint8 group)
1996 int ec_receive_processdata_group(
uint8 group,
int timeout)
2001 int ec_send_processdata(
void)
2003 return ec_send_processdata_group(0);
2006 int ec_receive_processdata(
int timeout)
2008 return ec_receive_processdata_group(0, timeout);
int ecx_send_processdata(ecx_contextt *context)
PACKED_END ec_adaptert * ec_find_adapters(void)
int ecx_FPWR(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
int ecx_mbxempty(ecx_contextt *context, uint16 slave, int timeout)
uint16 BitSize[EC_MAXEEPDO]
void ecx_setbufstat(ecx_portt *port, int idx, int bufstat)
uint8 ecx_siigetbyte(ecx_contextt *context, uint16 slave, uint16 address)
void ec_free_adapters(ec_adaptert *adapter)
int ecx_APWR(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
int ecx_init(ecx_contextt *context, char *ifname)
void ecx_close(ecx_contextt *context)
uint16 ecx_statecheck(ecx_contextt *context, uint16 slave, uint16 reqstate, int timeout)
int ecx_BWR(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
void ecx_pusherror(ecx_contextt *context, const ec_errort *Ec)
int ecx_BRD(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
PACKED_BEGIN struct PACKED ec_etherheadert
void ecx_siistring(ecx_contextt *context, char *str, uint16 slave, uint16 Sn)
PACKED_BEGIN struct PACKED ec_eepromt
void ecx_packeterror(ecx_contextt *context, uint16 Slave, uint16 Index, uint8 SubIdx, uint16 ErrorCode)
uint16 SyncM[EC_MAXEEPDO]
int ecx_eeprom2master(ecx_contextt *context, uint16 slave)
boolean osal_timer_is_expired(osal_timert *self)
int ecx_waitinframe(ecx_portt *port, int idx, int timeout)
General typedefs and defines for EtherCAT.
uint16 ecx_siiFMMU(ecx_contextt *context, uint16 slave, ec_eepromFMMUt *FMMU)
uint32 ecx_readeeprom(ecx_contextt *context, uint16 slave, uint16 eeproma, int timeout)
void ecx_esidump(ecx_contextt *context, uint16 slave, uint8 *esibuf)
void ec_clearmbx(ec_mbxbuft *Mbx)
int ecx_closenic(ecx_portt *port)
int ecx_APRD(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
static void ecx_mbxerror(ecx_contextt *context, uint16 Slave, uint16 Detail)
int ecx_setupnic(ecx_portt *port, const char *ifname, int secondary)
uint16 ecx_siiSMnext(ecx_contextt *context, uint16 slave, ec_eepromSMt *SM, uint16 n)
int ecx_outframe_red(ecx_portt *port, int idx)
ec_timet osal_current_time(void)
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)
int ecx_adddatagram(ecx_portt *port, void *frame, uint8 com, uint8 idx, boolean more, uint16 ADP, uint16 ADO, uint16 length, void *data)
PACKED_END PACKED_BEGIN struct PACKED ec_PDOassignt
PACKED_END PACKED_BEGIN struct PACKED ec_mbxerrort
static void ecx_mbxemergencyerror(ecx_contextt *context, uint16 Slave, uint16 ErrorCode, uint16 ErrorReg, uint8 b1, uint16 w1, uint16 w2)
PACKED_BEGIN struct PACKED ec_mbxheadert
uint32 IOsegment[EC_MAXIOSEGMENTS]
int ecx_writeeepromAP(ecx_contextt *context, uint16 aiadr, uint16 eeproma, uint16 data, int timeout)
#define put_unaligned32(val, ptr)
uint32 ecx_readeeprom2(ecx_contextt *context, uint16 slave, int timeout)
uint16 SMbitsize[EC_MAXSM]
void oshw_free_adapters(ec_adaptert *adapter)
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 ecx_writestate(ecx_contextt *context, uint16 slave)
PACKED_END PACKED_BEGIN struct PACKED ec_emcyt
int ecx_mbxreceive(ecx_contextt *context, uint16 slave, ec_mbxbuft *mbx, int timeout)
int ecx_receive_processdata_group(ecx_contextt *context, uint8 group, int timeout)
int osal_usleep(uint32 usec)
ec_errort Error[EC_MAXELIST+1]
PACKED_END PACKED_BEGIN struct PACKED ec_PDOdesct
int ecx_send_processdata_group(ecx_contextt *context, uint8 group)
void osal_timer_start(osal_timert *self, uint32 timeout_us)
void ecx_readeeprom1(ecx_contextt *context, uint16 slave, uint16 eeproma)
uint64 ecx_readeepromFP(ecx_contextt *context, uint16 configadr, uint16 eeproma, int timeout)
int ecx_init_redundant(ecx_contextt *context, ecx_redportt *redport, char *ifname, char *if2name)
boolean ecx_iserror(ecx_contextt *context)
int ecx_setupdatagram(ecx_portt *port, void *frame, uint8 com, uint8 idx, uint16 ADP, uint16 ADO, uint16 length, void *data)
Headerfile for ethercatbase.c.
#define EC_DEFAULTRETRIES
int ecx_siiPDO(ecx_contextt *context, uint16 slave, ec_eepromPDOt *PDO, uint8 t)
int ecx_eeprom2pdi(ecx_contextt *context, uint16 slave)
Headerfile for ethercatmain.c.
boolean ecx_poperror(ecx_contextt *context, ec_errort *Ec)
static int ecx_pullindex(ecx_contextt *context)
int ecx_FPWRw(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 data, int timeout)
int ecx_readstate(ecx_contextt *context)
ec_adaptert * oshw_find_adapters(void)
int16 ecx_siifind(ecx_contextt *context, uint16 slave, uint16 cat)
static void ecx_pushindex(ecx_contextt *context, uint8 idx, void *data, uint16 length)
int ecx_receive_processdata(ecx_contextt *context, int timeout)
uint16 ecx_siiSM(ecx_contextt *context, uint16 slave, ec_eepromSMt *SM)
uint16 Index[EC_MAXEEPDO]
PACKED_END PACKED_BEGIN struct PACKED ec_alstatust
uint16 ecx_eeprom_waitnotbusyFP(ecx_contextt *context, uint16 configadr, uint16 *estat, int timeout)
uint16 oshw_htons(uint16 hostshort)
int ecx_FPRD(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
PACKED_BEGIN struct PACKED ec_SMcommtypet
int ecx_getindex(ecx_portt *port)
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)