63 #define EC_LOCALDELAY 200 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++)
700 while (c < PDO->Length);
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))
948 if ((wkc > 0) && ((mbxh->mbxtype & 0x0f) == 0x00))
954 else if ((wkc > 0) && ((mbxh->mbxtype & 0x0f) == 0x03))
957 if ((
etohs(EMp->CANOpen) >> 12) == 0x01)
969 SMstat =
htoes(SMstat);
971 SMstat =
etohs(SMstat);
979 SMstat =
etohs(SMstat);
1080 int wkc = 1, cnt = 0;
1113 int wkc = 1, cnt = 0;
1134 int wkc, cnt = 0, retval = 0;
1145 *estat =
etohs(*estat);
1148 if ((*estat & EC_ESTAT_BUSY) == 0)
1169 int wkc, cnt, nackcnt = 0;
1184 ed.addr =
htoes(eeproma);
1229 while ((nackcnt > 0) && (nackcnt < 3));
1247 int wkc, rval = 0, cnt = 0, nackcnt = 0;
1294 while ((nackcnt > 0) && (nackcnt < 3));
1302 int wkc, cnt = 0, retval = 0;
1313 *estat =
etohs(*estat);
1316 if ((*estat & EC_ESTAT_BUSY) == 0)
1337 int wkc, cnt, nackcnt = 0;
1352 ed.addr =
htoes(eeproma);
1397 while ((nackcnt > 0) && (nackcnt < 3));
1415 int wkc, rval = 0, cnt = 0, nackcnt = 0;
1460 while ((nackcnt > 0) && (nackcnt < 3));
1488 ed.addr =
htoes(eeproma);
1579 boolean first=
FALSE;
1580 uint16 currentsegment = 0;
1625 context->
DCl = sublength;
1636 length -= sublength;
1637 LogAdr += sublength;
1639 }
while (length && (currentsegment < context->grouplist[group].nsegments));
1652 if((length - sublength) < 0)
1663 context->
DCl = sublength;
1674 length -= sublength;
1675 LogAdr += sublength;
1677 }
while (length && (currentsegment < context->grouplist[group].nsegments));
1702 context->
DCl = sublength;
1713 length -= sublength;
1714 LogAdr += sublength;
1716 }
while (length && (currentsegment < context->grouplist[group].nsegments));
1738 boolean first =
FALSE;
1760 wkc =
etohs(le_wkc);
1761 memcpy(&le_DCtime, &(context->
port->
rxbuf[idx][context->
DCtO]),
sizeof(le_DCtime));
1778 wkc =
etohs(le_wkc) * 2;
1779 memcpy(&le_DCtime, &(context->
port->
rxbuf[idx][context->
DCtO]),
sizeof(le_DCtime));
1844 return ecx_init(&ecx_context, ifname);
1879 return ecx_siiSM (&ecx_context, slave, SM);
1889 return ecx_siiPDO (&ecx_context, slave, PDO, t);
1914 return ecx_mbxsend (&ecx_context, slave, mbx, timeout);
int ecx_send_processdata(ecx_contextt *context)
int ecx_adddatagram(ecx_portt *port, void *frame, uint8 com, uint8 idx, boolean more, uint16 ADP, uint16 ADO, uint16 length, void *data)
ec_groupt ec_group[EC_MAXGROUP]
int ecx_getindex(ecx_portt *port)
int ecx_mbxempty(ecx_contextt *context, uint16 slave, int timeout)
uint16 BitSize[EC_MAXEEPDO]
void osal_timer_start(osal_timert *self, uint32 timeout_usec)
int ec_writeeepromAP(uint16 aiadr, uint16 eeproma, uint16 data, int timeout)
uint64 ec_readeepromFP(uint16 configadr, uint16 eeproma, int timeout)
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)
static ec_PDOdesct ec_PDOdesc
PACKED_END ec_slavet ec_slave[EC_MAXSLAVE]
int ecx_init(ecx_contextt *context, char *ifname)
void ecx_close(ecx_contextt *context)
int ecx_setupnic(ecx_portt *port, const char *ifname, int secondary)
uint16 ecx_statecheck(ecx_contextt *context, uint16 slave, uint16 reqstate, int timeout)
void ecx_pusherror(ecx_contextt *context, const ec_errort *Ec)
int ec_init_redundant(char *ifname, char *if2name)
int ec_receive_processdata(int timeout)
int ecx_FPWRw(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 data, int timeout)
ec_adaptert * oshw_find_adapters(void)
PACKED_BEGIN struct PACKED ec_etherheadert
static void ec_mbxemergencyerror(uint16 Slave, uint16 ErrorCode, uint16 ErrorReg, uint8 b1, uint16 w1, uint16 w2)
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)
void oshw_free_adapters(ec_adaptert *adapter)
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)
static ec_SMcommtypet ec_SMcommtype
uint16 SyncM[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)
General typedefs and defines for EtherCAT.
ec_timet osal_current_time(void)
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 void ec_mbxerror(uint16 Slave, uint16 Detail)
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_PDOassignt ec_PDOassign
static ec_eepromFMMUt ec_FMMU
uint16 ec_siiFMMU(uint16 slave, ec_eepromFMMUt *FMMU)
static void ecx_mbxerror(ecx_contextt *context, uint16 Slave, uint16 Detail)
uint16 ecx_siiSMnext(ecx_contextt *context, uint16 slave, ec_eepromSMt *SM, uint16 n)
int ec_eeprom2pdi(uint16 slave)
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_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
int ecx_BRD(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
uint32 IOsegment[EC_MAXIOSEGMENTS]
int ecx_writeeepromAP(ecx_contextt *context, uint16 aiadr, uint16 eeproma, uint16 data, int timeout)
#define put_unaligned32(val, ptr)
static uint8 esibuf[EC_MAXEEPBUF]
int ec_init(char *ifname)
uint32 ecx_readeeprom2(ecx_contextt *context, uint16 slave, int timeout)
uint16 SMbitsize[EC_MAXSM]
void ec_pusherror(const ec_errort *Ec)
int ec_eeprom2master(uint16 slave)
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 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)
ec_errort Error[EC_MAXELIST+1]
int ecx_waitinframe(ecx_portt *port, int idx, int timeout)
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)
int16 ec_siifind(uint16 slave, uint16 cat)
int ecx_APRD(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data, int timeout)
PACKED_END PACKED_BEGIN struct PACKED ec_PDOdesct
static uint32 esimap[EC_MAXEEPBITMAP]
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
uint16 oshw_htons(uint16 host)
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)
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)
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)
uint64 ec_readeepromAP(uint16 aiadr, uint16 eeproma, int timeout)
Headerfile for ethercatmain.c.
int ecx_closenic(ecx_portt *port)
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)
int ecx_outframe_red(ecx_portt *port, int idx)
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)
static void ecx_pushindex(ecx_contextt *context, uint8 idx, void *data, uint16 length)
int osal_usleep(uint32 usec)
boolean osal_timer_is_expired(const osal_timert *self)
int ecx_receive_processdata(ecx_contextt *context, int timeout)
uint16 ecx_siiSM(ecx_contextt *context, uint16 slave, ec_eepromSMt *SM)
uint16 ec_statecheck(uint16 slave, uint16 reqstate, int timeout)
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)
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)
PACKED_BEGIN struct PACKED ec_SMcommtypet
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)