Merge pull request #256 from claudioscordino/upstream-new
Clean up comments, EC_PRINT and thread usage.
This commit is contained in:
commit
8832ef0f2f
|
@ -3,3 +3,4 @@ install
|
|||
*~
|
||||
/doc/latex
|
||||
/doc/html
|
||||
tags
|
||||
|
|
|
@ -29,6 +29,12 @@ Linux
|
|||
* `cmake ..`
|
||||
* `make`
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
See https://openethercatsociety.github.io/doc/soem/
|
||||
|
||||
|
||||
Want to contribute to SOEM or SOES?
|
||||
-----------------------------------
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
* how an EtherCAT master functions and how it interacts with EtherCAT slaves.
|
||||
*
|
||||
* As all applications are different SOEM tries to not impose any design architecture.
|
||||
* Under Linux it can be used in generic user mode, PREEMPT_RT or Xenomai. under Windows
|
||||
* Under Linux it can be used in generic user mode, PREEMPT_RT or Xenomai. Under Windows
|
||||
* it can be used as user mode program.
|
||||
*
|
||||
* Preconditions Linux:
|
||||
|
@ -45,7 +45,7 @@
|
|||
* - Distributed Clock (DC) support.
|
||||
* - Automatic configuration of DC slaves.
|
||||
* - Automatic sync of clocks with process data exchange.
|
||||
* - Flexible settting of sync0 and sync1 firing per slave.
|
||||
* - Flexible setting of sync0 and sync1 firing per slave.
|
||||
* - Access to slave functions through one slave structure.
|
||||
* - EEPROM read / write.
|
||||
* - Local cache for EEPROM access with automatic 4/8 byte reading.
|
||||
|
@ -63,7 +63,7 @@
|
|||
* - SYNC1 generation supported.
|
||||
*
|
||||
* Features as of 1.2.0 :
|
||||
* - Changed license to GPLv2 only. Adresses leagal concerns about master licensing.
|
||||
* - Changed license to GPLv2 only. Addresses legal concerns about master licensing.
|
||||
* - Slave init and process data mapping is split in two functions. This allows
|
||||
* dynamic user reconfiguration of PDO mapping.
|
||||
* - Eeprom transfer to and from PDI
|
||||
|
@ -93,7 +93,7 @@
|
|||
* Features as of 1.2.8 :
|
||||
* - Changed directory structure.
|
||||
* - Changed make file.
|
||||
* - Moved hardware / OS dependend part in separate directories.
|
||||
* - Moved hardware / OS dependent part in separate directories.
|
||||
* - Added firm_update tool to upload firmware to slaves in Boot state, use with care.
|
||||
* - Added DC for LRD/LWR case.
|
||||
* - Separated expectedWKC to inputsWKC and outputsWKC.
|
||||
|
|
|
@ -11,6 +11,15 @@ extern "C"
|
|||
{
|
||||
#endif
|
||||
|
||||
// define if debug printf is needed
|
||||
//#define EC_DEBUG
|
||||
|
||||
#ifdef EC_DEBUG
|
||||
#define EC_PRINT printf
|
||||
#else
|
||||
#define EC_PRINT(...) do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifndef PACKED
|
||||
#ifdef _MSC_VER
|
||||
#define PACKED_BEGIN __pragma(pack(push, 1))
|
||||
|
|
|
@ -17,7 +17,7 @@ int osal_usleep (uint32 usec)
|
|||
struct timespec ts;
|
||||
ts.tv_sec = usec / USECS_PER_SEC;
|
||||
ts.tv_nsec = (usec % USECS_PER_SEC) * 1000;
|
||||
/* usleep is depricated, use nanosleep instead */
|
||||
/* usleep is deprecated, use nanosleep instead */
|
||||
return nanosleep(&ts, NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,15 @@ extern "C"
|
|||
{
|
||||
#endif
|
||||
|
||||
// define if debug printf is needed
|
||||
//#define EC_DEBUG
|
||||
|
||||
#ifdef EC_DEBUG
|
||||
#define EC_PRINT printf
|
||||
#else
|
||||
#define EC_PRINT(...) do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifndef PACKED
|
||||
#define PACKED_BEGIN
|
||||
#define PACKED __attribute__((__packed__))
|
||||
|
|
|
@ -17,7 +17,7 @@ int osal_usleep (uint32 usec)
|
|||
struct timespec ts;
|
||||
ts.tv_sec = usec / USECS_PER_SEC;
|
||||
ts.tv_nsec = (usec % USECS_PER_SEC) * 1000;
|
||||
/* usleep is depricated, use nanosleep instead */
|
||||
/* usleep is deprecated, use nanosleep instead */
|
||||
return nanosleep(&ts, NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,15 @@ extern "C"
|
|||
{
|
||||
#endif
|
||||
|
||||
// define if debug printf is needed
|
||||
//#define EC_DEBUG
|
||||
|
||||
#ifdef EC_DEBUG
|
||||
#define EC_PRINT printf
|
||||
#else
|
||||
#define EC_PRINT(...) do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifndef PACKED
|
||||
#define PACKED_BEGIN
|
||||
#define PACKED __attribute__((__packed__))
|
||||
|
|
|
@ -11,6 +11,15 @@ extern "C"
|
|||
{
|
||||
#endif
|
||||
|
||||
// define if debug printf is needed
|
||||
//#define EC_DEBUG
|
||||
|
||||
#ifdef EC_DEBUG
|
||||
#define EC_PRINT printf
|
||||
#else
|
||||
#define EC_PRINT(...) do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifndef PACKED
|
||||
#define PACKED_BEGIN
|
||||
#define PACKED __attribute__((__packed__))
|
||||
|
|
|
@ -6,6 +6,15 @@
|
|||
#ifndef _osal_defs_
|
||||
#define _osal_defs_
|
||||
|
||||
// define if debug printf is needed
|
||||
//#define EC_DEBUG
|
||||
|
||||
#ifdef EC_DEBUG
|
||||
#define EC_PRINT printf
|
||||
#else
|
||||
#define EC_PRINT(...) do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifndef PACKED
|
||||
#define PACKED_BEGIN
|
||||
#define PACKED __attribute__((__packed__))
|
||||
|
|
|
@ -11,6 +11,15 @@ extern "C"
|
|||
{
|
||||
#endif
|
||||
|
||||
// define if debug printf is needed
|
||||
//#define EC_DEBUG
|
||||
|
||||
#ifdef EC_DEBUG
|
||||
#define EC_PRINT printf
|
||||
#else
|
||||
#define EC_PRINT(...) do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifndef PACKED
|
||||
#define PACKED_BEGIN __pragma(pack(push, 1))
|
||||
#define PACKED
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
* EtherCAT RAW socket driver.
|
||||
*
|
||||
* Low level interface functions to send and receive EtherCAT packets.
|
||||
* EtherCAT has the property that packets are only send by the master,
|
||||
* and the send packets always return in the receive buffer.
|
||||
* EtherCAT has the property that packets are only sent by the master,
|
||||
* and the sent packets always return in the receive buffer.
|
||||
* There can be multiple packets "on the wire" before they return.
|
||||
* To combine the received packets with the original send packets a buffer
|
||||
* To combine the received packets with the original sent packets a buffer
|
||||
* system is installed. The identifier is put in the index item of the
|
||||
* EtherCAT header. The index is stored and compared when a frame is received.
|
||||
* If there is a match the packet can be combined with the transmit packet
|
||||
|
@ -46,7 +46,7 @@ enum
|
|||
{
|
||||
/** No redundancy, single NIC mode */
|
||||
ECT_RED_NONE,
|
||||
/** Double redundant NIC connecetion */
|
||||
/** Double redundant NIC connection */
|
||||
ECT_RED_DOUBLE
|
||||
};
|
||||
|
||||
|
@ -246,7 +246,7 @@ int ecx_closenic(ecx_portt *port)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/** Fill buffer with ethernet header structure.
|
||||
/** Fill buffer with Ethernet header structure.
|
||||
* Destination MAC is always broadcast.
|
||||
* Ethertype is always ETH_P_ECAT.
|
||||
* @param[out] p = buffer
|
||||
|
@ -459,7 +459,7 @@ static int ecx_recvpkt(ecx_portt *port, int stacknumber)
|
|||
/** Non blocking receive frame function. Uses RX buffer and index to combine
|
||||
* read frame with transmitted frame. To compensate for received frames that
|
||||
* are out-of-order all frames are stored in their respective indexed buffer.
|
||||
* If a frame was placed in the buffer previously, the function retreives it
|
||||
* If a frame was placed in the buffer previously, the function retrieves it
|
||||
* from that buffer index without calling ec_recvpkt. If the requested index
|
||||
* is not already in the buffer it calls ec_recvpkt to fetch it. There are
|
||||
* three options now, 1 no frame read, so exit. 2 frame read but other
|
||||
|
@ -515,7 +515,7 @@ int ecx_inframe(ecx_portt *port, int idx, int stacknumber)
|
|||
ecp =(ec_comt*)(&(*stack->tempbuf)[ETH_HEADERSIZE]);
|
||||
l = etohs(ecp->elength) & 0x0fff;
|
||||
idxf = ecp->index;
|
||||
/* found index equals reqested index ? */
|
||||
/* found index equals requested index ? */
|
||||
if (idxf == idx)
|
||||
{
|
||||
/* yes, put it in the buffer array (strip ethernet header) */
|
||||
|
@ -545,7 +545,7 @@ int ecx_inframe(ecx_portt *port, int idx, int stacknumber)
|
|||
ReleaseRtControl();
|
||||
}
|
||||
|
||||
/* WKC if mathing frame found */
|
||||
/* WKC if matching frame found */
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
@ -591,10 +591,10 @@ static int ecx_waitinframe_red(ecx_portt *port, int idx, osal_timert *timer)
|
|||
/* only do redundant functions when in redundant mode */
|
||||
if (port->redstate != ECT_RED_NONE)
|
||||
{
|
||||
/* primrx if the reveived MAC source on primary socket */
|
||||
/* primrx if the received MAC source on primary socket */
|
||||
primrx = 0;
|
||||
if (wkc > EC_NOFRAME) primrx = port->rxsa[idx];
|
||||
/* secrx if the reveived MAC source on psecondary socket */
|
||||
/* secrx if the received MAC source on psecondary socket */
|
||||
secrx = 0;
|
||||
if (wkc2 > EC_NOFRAME) secrx = port->redport->rxsa[idx];
|
||||
|
||||
|
@ -670,7 +670,7 @@ int ecx_waitinframe(ecx_portt *port, int idx, int timeout)
|
|||
return wkc;
|
||||
}
|
||||
|
||||
/** Blocking send and recieve frame function. Used for non processdata frames.
|
||||
/** Blocking send and receive frame function. Used for non processdata frames.
|
||||
* A datagram is build into a frame and transmitted via this function. It waits
|
||||
* for an answer and returns the workcounter. The function retries if time is
|
||||
* left and the result is WKC=0 or no frame received.
|
||||
|
|
|
@ -67,7 +67,7 @@ typedef struct
|
|||
int tempinbufs;
|
||||
/** transmit buffers */
|
||||
ec_bufT txbuf[EC_MAXBUF];
|
||||
/** transmit buffer lenghts */
|
||||
/** transmit buffer lengths */
|
||||
int txbuflength[EC_MAXBUF];
|
||||
/** temporary tx buffer */
|
||||
ec_bufT txbuf2;
|
||||
|
|
|
@ -52,7 +52,7 @@ enum
|
|||
{
|
||||
/** No redundancy, single NIC mode */
|
||||
ECT_RED_NONE,
|
||||
/** Double redundant NIC connecetion */
|
||||
/** Double redundant NIC connection */
|
||||
ECT_RED_DOUBLE
|
||||
};
|
||||
|
||||
|
@ -357,7 +357,7 @@ static int ecx_recvpkt(ecx_portt *port, int stacknumber)
|
|||
/** Non blocking receive frame function. Uses RX buffer and index to combine
|
||||
* read frame with transmitted frame. To compensate for received frames that
|
||||
* are out-of-order all frames are stored in their respective indexed buffer.
|
||||
* If a frame was placed in the buffer previously, the function retreives it
|
||||
* If a frame was placed in the buffer previously, the function retrieves it
|
||||
* from that buffer index without calling ec_recvpkt. If the requested index
|
||||
* is not already in the buffer it calls ec_recvpkt to fetch it. There are
|
||||
* three options now, 1 no frame read, so exit. 2 frame read but other
|
||||
|
@ -413,7 +413,7 @@ int ecx_inframe(ecx_portt *port, int idx, int stacknumber)
|
|||
ecp =(ec_comt*)(&(*stack->tempbuf)[ETH_HEADERSIZE]);
|
||||
l = etohs(ecp->elength) & 0x0fff;
|
||||
idxf = ecp->index;
|
||||
/* found index equals reqested index ? */
|
||||
/* found index equals requested index ? */
|
||||
if (idxf == idx)
|
||||
{
|
||||
/* yes, put it in the buffer array (strip ethernet header) */
|
||||
|
@ -439,7 +439,7 @@ int ecx_inframe(ecx_portt *port, int idx, int stacknumber)
|
|||
}
|
||||
else
|
||||
{
|
||||
/* strange things happend */
|
||||
/* strange things happened */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -448,7 +448,7 @@ int ecx_inframe(ecx_portt *port, int idx, int stacknumber)
|
|||
|
||||
}
|
||||
|
||||
/* WKC if mathing frame found */
|
||||
/* WKC if matching frame found */
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
@ -491,10 +491,10 @@ static int ecx_waitinframe_red(ecx_portt *port, int idx, osal_timert *timer)
|
|||
/* only do redundant functions when in redundant mode */
|
||||
if (port->redstate != ECT_RED_NONE)
|
||||
{
|
||||
/* primrx if the reveived MAC source on primary socket */
|
||||
/* primrx if the received MAC source on primary socket */
|
||||
primrx = 0;
|
||||
if (wkc > EC_NOFRAME) primrx = port->rxsa[idx];
|
||||
/* secrx if the reveived MAC source on psecondary socket */
|
||||
/* secrx if the received MAC source on psecondary socket */
|
||||
secrx = 0;
|
||||
if (wkc2 > EC_NOFRAME) secrx = port->redport->rxsa[idx];
|
||||
|
||||
|
@ -563,7 +563,7 @@ int ecx_waitinframe(ecx_portt *port, int idx, int timeout)
|
|||
return wkc;
|
||||
}
|
||||
|
||||
/** Blocking send and recieve frame function. Used for non processdata frames.
|
||||
/** Blocking send and receive frame function. Used for non processdata frames.
|
||||
* A datagram is build into a frame and transmitted via this function. It waits
|
||||
* for an answer and returns the workcounter. The function retries if time is
|
||||
* left and the result is WKC=0 or no frame received.
|
||||
|
@ -591,7 +591,7 @@ int ecx_srconfirm(ecx_portt *port, int idx, int timeout)
|
|||
}
|
||||
else
|
||||
{
|
||||
/* normally use partial timout for rx */
|
||||
/* normally use partial timeout for rx */
|
||||
osal_timer_start (&timer2, EC_TIMEOUTRET);
|
||||
}
|
||||
/* get frame from primary or if in redundant mode possibly from secondary */
|
||||
|
|
|
@ -69,7 +69,7 @@ typedef struct
|
|||
int tempinbufs;
|
||||
/** transmit buffers */
|
||||
ec_bufT txbuf[EC_MAXBUF];
|
||||
/** transmit buffer lenghts */
|
||||
/** transmit buffer lengths */
|
||||
int txbuflength[EC_MAXBUF];
|
||||
/** temporary tx buffer */
|
||||
ec_bufT txbuf2;
|
||||
|
|
|
@ -50,7 +50,7 @@ ec_adaptert * oshw_find_adapters(void)
|
|||
|
||||
|
||||
/* Iterate all devices and create a local copy holding the name and
|
||||
* decsription.
|
||||
* description.
|
||||
*/
|
||||
|
||||
ids = if_nameindex ();
|
||||
|
@ -70,7 +70,7 @@ ec_adaptert * oshw_find_adapters(void)
|
|||
ret_adapter = adapter;
|
||||
}
|
||||
|
||||
/* fetch description and name, in linux we use the same on both */
|
||||
/* fetch description and name, in Linux we use the same on both */
|
||||
adapter->next = NULL;
|
||||
|
||||
if (ids[i].if_name)
|
||||
|
@ -106,7 +106,7 @@ ec_adaptert * oshw_find_adapters(void)
|
|||
void oshw_free_adapters(ec_adaptert * adapter)
|
||||
{
|
||||
ec_adaptert * next_adapter;
|
||||
/* Iterate the linked list and free all elemnts holding
|
||||
/* Iterate the linked list and free all elements holding
|
||||
* adapter information
|
||||
*/
|
||||
if(adapter)
|
||||
|
|
|
@ -53,7 +53,7 @@ enum
|
|||
{
|
||||
/** No redundancy, single NIC mode */
|
||||
ECT_RED_NONE,
|
||||
/** Double redundant NIC connecetion */
|
||||
/** Double redundant NIC connection */
|
||||
ECT_RED_DOUBLE
|
||||
};
|
||||
|
||||
|
@ -405,7 +405,7 @@ static int ecx_recvpkt(ecx_portt *port, int stacknumber)
|
|||
/** Non blocking receive frame function. Uses RX buffer and index to combine
|
||||
* read frame with transmitted frame. To compensate for received frames that
|
||||
* are out-of-order all frames are stored in their respective indexed buffer.
|
||||
* If a frame was placed in the buffer previously, the function retreives it
|
||||
* If a frame was placed in the buffer previously, the function retrieves it
|
||||
* from that buffer index without calling ec_recvpkt. If the requested index
|
||||
* is not already in the buffer it calls ec_recvpkt to fetch it. There are
|
||||
* three options now, 1 no frame read, so exit. 2 frame read but other
|
||||
|
@ -464,7 +464,7 @@ int ecx_inframe(ecx_portt *port, int idx, int stacknumber)
|
|||
ecp =(ec_comt*)(&ehp[1]);
|
||||
l = etohs(ecp->elength) & 0x0fff;
|
||||
idxf = ecp->index;
|
||||
/* found index equals reqested index ? */
|
||||
/* found index equals requested index ? */
|
||||
if (idxf == idx)
|
||||
{
|
||||
/* yes, put it in the buffer array (strip headers) */
|
||||
|
@ -490,7 +490,7 @@ int ecx_inframe(ecx_portt *port, int idx, int stacknumber)
|
|||
}
|
||||
else
|
||||
{
|
||||
/* strange things happend */
|
||||
/* strange things happened */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -499,7 +499,7 @@ int ecx_inframe(ecx_portt *port, int idx, int stacknumber)
|
|||
|
||||
}
|
||||
|
||||
/* WKC if mathing frame found */
|
||||
/* WKC if matching frame found */
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
@ -542,10 +542,10 @@ static int ecx_waitinframe_red(ecx_portt *port, int idx, osal_timert *timer)
|
|||
/* only do redundant functions when in redundant mode */
|
||||
if (port->redstate != ECT_RED_NONE)
|
||||
{
|
||||
/* primrx if the reveived MAC source on primary socket */
|
||||
/* primrx if the received MAC source on primary socket */
|
||||
primrx = 0;
|
||||
if (wkc > EC_NOFRAME) primrx = port->rxsa[idx];
|
||||
/* secrx if the reveived MAC source on psecondary socket */
|
||||
/* secrx if the received MAC source on psecondary socket */
|
||||
secrx = 0;
|
||||
if (wkc2 > EC_NOFRAME) secrx = port->redport->rxsa[idx];
|
||||
|
||||
|
@ -614,7 +614,7 @@ int ecx_waitinframe(ecx_portt *port, int idx, int timeout)
|
|||
return wkc;
|
||||
}
|
||||
|
||||
/** Blocking send and recieve frame function. Used for non processdata frames.
|
||||
/** Blocking send and receive frame function. Used for non processdata frames.
|
||||
* A datagram is build into a frame and transmitted via this function. It waits
|
||||
* for an answer and returns the workcounter. The function retries if time is
|
||||
* left and the result is WKC=0 or no frame received.
|
||||
|
@ -642,7 +642,7 @@ int ecx_srconfirm(ecx_portt *port, int idx, int timeout)
|
|||
}
|
||||
else
|
||||
{
|
||||
/* normally use partial timout for rx */
|
||||
/* normally use partial timeout for rx */
|
||||
osal_timer_start (&timer2, EC_TIMEOUTRET);
|
||||
}
|
||||
/* get frame from primary or if in redundant mode possibly from secondary */
|
||||
|
|
|
@ -69,7 +69,7 @@ typedef struct
|
|||
int tempinbufs;
|
||||
/** transmit buffers */
|
||||
ec_bufT txbuf[EC_MAXBUF];
|
||||
/** transmit buffer lenghts */
|
||||
/** transmit buffer lengths */
|
||||
int txbuflength[EC_MAXBUF];
|
||||
/** temporary tx buffer */
|
||||
ec_bufT txbuf2;
|
||||
|
|
|
@ -50,7 +50,7 @@ ec_adaptert * oshw_find_adapters(void)
|
|||
|
||||
|
||||
/* Iterate all devices and create a local copy holding the name and
|
||||
* decsription.
|
||||
* description.
|
||||
*/
|
||||
|
||||
ids = if_nameindex ();
|
||||
|
@ -70,7 +70,7 @@ ec_adaptert * oshw_find_adapters(void)
|
|||
ret_adapter = adapter;
|
||||
}
|
||||
|
||||
/* fetch description and name, in linux we use the same on both */
|
||||
/* fetch description and name, in Linux we use the same on both */
|
||||
adapter->next = NULL;
|
||||
|
||||
if (ids[i].if_name)
|
||||
|
@ -106,7 +106,7 @@ ec_adaptert * oshw_find_adapters(void)
|
|||
void oshw_free_adapters(ec_adaptert * adapter)
|
||||
{
|
||||
ec_adaptert * next_adapter;
|
||||
/* Iterate the linked list and free all elemnts holding
|
||||
/* Iterate the linked list and free all elements holding
|
||||
* adapter information
|
||||
*/
|
||||
if(adapter)
|
||||
|
|
|
@ -51,7 +51,7 @@ enum
|
|||
{
|
||||
/** No redundancy, single NIC mode */
|
||||
ECT_RED_NONE,
|
||||
/** Double redundant NIC connecetion */
|
||||
/** Double redundant NIC connection */
|
||||
ECT_RED_DOUBLE
|
||||
};
|
||||
|
||||
|
@ -334,7 +334,7 @@ static int ecx_recvpkt(ecx_portt *port, int stacknumber)
|
|||
/** Non blocking receive frame function. Uses RX buffer and index to combine
|
||||
* read frame with transmitted frame. To compensate for received frames that
|
||||
* are out-of-order all frames are stored in their respective indexed buffer.
|
||||
* If a frame was placed in the buffer previously, the function retreives it
|
||||
* If a frame was placed in the buffer previously, the function retrieves it
|
||||
* from that buffer index without calling ec_recvpkt. If the requested index
|
||||
* is not already in the buffer it calls ec_recvpkt to fetch it. There are
|
||||
* three options now, 1 no frame read, so exit. 2 frame read but other
|
||||
|
@ -390,7 +390,7 @@ int ecx_inframe(ecx_portt *port, int idx, int stacknumber)
|
|||
ecp =(ec_comt*)(&(*stack->tempbuf)[ETH_HEADERSIZE]);
|
||||
l = etohs(ecp->elength) & 0x0fff;
|
||||
idxf = ecp->index;
|
||||
/* found index equals reqested index ? */
|
||||
/* found index equals requested index ? */
|
||||
if (idxf == idx)
|
||||
{
|
||||
/* yes, put it in the buffer array (strip ethernet header) */
|
||||
|
@ -416,7 +416,7 @@ int ecx_inframe(ecx_portt *port, int idx, int stacknumber)
|
|||
}
|
||||
else
|
||||
{
|
||||
/* strange things happend */
|
||||
/* strange things happened */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -425,7 +425,7 @@ int ecx_inframe(ecx_portt *port, int idx, int stacknumber)
|
|||
|
||||
}
|
||||
|
||||
/* WKC if mathing frame found */
|
||||
/* WKC if matching frame found */
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
@ -471,13 +471,13 @@ static int ecx_waitinframe_red(ecx_portt *port, int idx, osal_timert timer)
|
|||
/* only do redundant functions when in redundant mode */
|
||||
if (port->redstate != ECT_RED_NONE)
|
||||
{
|
||||
/* primrx if the reveived MAC source on primary socket */
|
||||
/* primrx if the received MAC source on primary socket */
|
||||
primrx = 0;
|
||||
if (wkc > EC_NOFRAME)
|
||||
{
|
||||
primrx = port->rxsa[idx];
|
||||
}
|
||||
/* secrx if the reveived MAC source on psecondary socket */
|
||||
/* secrx if the received MAC source on psecondary socket */
|
||||
secrx = 0;
|
||||
if (wkc2 > EC_NOFRAME)
|
||||
{
|
||||
|
@ -550,7 +550,7 @@ int ecx_waitinframe(ecx_portt *port, int idx, int timeout)
|
|||
return wkc;
|
||||
}
|
||||
|
||||
/** Blocking send and recieve frame function. Used for non processdata frames.
|
||||
/** Blocking send and receive frame function. Used for non processdata frames.
|
||||
* A datagram is build into a frame and transmitted via this function. It waits
|
||||
* for an answer and returns the workcounter. The function retries if time is
|
||||
* left and the result is WKC=0 or no frame received.
|
||||
|
|
|
@ -62,7 +62,7 @@ typedef struct
|
|||
int tempinbufs;
|
||||
/** transmit buffers */
|
||||
ec_bufT txbuf[EC_MAXBUF];
|
||||
/** transmit buffer lenghts */
|
||||
/** transmit buffer lengths */
|
||||
int txbuflength[EC_MAXBUF];
|
||||
/** temporary tx buffer */
|
||||
ec_bufT txbuf2;
|
||||
|
|
|
@ -13,14 +13,14 @@
|
|||
* There can be multiple packets "on the wire" before they return.
|
||||
* To combine the received packets with the original send packets a buffer
|
||||
* system is installed. The identifier is put in the index item of the
|
||||
* EtherCAT header. The index is stored and compared when a frame is recieved.
|
||||
* EtherCAT header. The index is stored and compared when a frame is received.
|
||||
* If there is a match the packet can be combined with the transmit packet
|
||||
* and returned to the higher level function.
|
||||
*
|
||||
* If EtherCAT is run in parallel with normal IP traffic and EtherCAT have a
|
||||
* dedicated NIC, instatiate an extra tNetX task and redirect the NIC workQ
|
||||
* dedicated NIC, instantiate an extra tNetX task and redirect the NIC workQ
|
||||
* to be handle by the extra tNetX task, if needed raise the tNetX task prio.
|
||||
* This prevents from having tNet0 becoming a bootleneck.
|
||||
* This prevents from having tNet0 becoming a bottleneck.
|
||||
*
|
||||
* The "redundant" option will configure two Mux drivers and two NIC interfaces.
|
||||
* Slaves are connected to both interfaces, one on the IN port and one on the
|
||||
|
@ -76,7 +76,7 @@ enum
|
|||
{
|
||||
/** No redundancy, single NIC mode */
|
||||
ECT_RED_NONE,
|
||||
/** Double redundant NIC connecetion */
|
||||
/** Double redundant NIC connection */
|
||||
ECT_RED_DOUBLE
|
||||
};
|
||||
|
||||
|
@ -126,7 +126,7 @@ int ecx_setupnic(ecx_portt *port, const char *ifname, int secondary)
|
|||
int unit_no = -1;
|
||||
ETHERCAT_PKT_DEV * pPktDev;
|
||||
|
||||
/* Make refrerece to packet device struct, keep track if the packet
|
||||
/* Make reference to packet device struct, keep track if the packet
|
||||
* device is the redundant or not.
|
||||
*/
|
||||
if (secondary)
|
||||
|
@ -308,8 +308,8 @@ int ecx_closenic(ecx_portt *port)
|
|||
}
|
||||
|
||||
/** Fill buffer with ethernet header structure.
|
||||
* Destination MAC is allways broadcast.
|
||||
* Ethertype is allways ETH_P_ECAT.
|
||||
* Destination MAC is always broadcast.
|
||||
* Ethertype is always ETH_P_ECAT.
|
||||
* @param[out] p = buffer
|
||||
*/
|
||||
void ec_setupheader(void *p)
|
||||
|
@ -529,11 +529,11 @@ int ecx_outframe_red(ecx_portt *port, int idx)
|
|||
|
||||
/** Call back routine registered as hook with mux layer 2 driver
|
||||
* @param[in] pCookie = Mux cookie
|
||||
* @param[in] type = recived type
|
||||
* @param[in] type = received type
|
||||
* @param[in] pMblk = the received packet reference
|
||||
* @param[in] llHdrInfo = header info
|
||||
* @param[in] muxUserArg = assigned reference to packet device when init called
|
||||
* @return TRUE if frame was succesfully read and passed to MsgQ
|
||||
* @return TRUE if frame was successfully read and passed to MsgQ
|
||||
*/
|
||||
static int mux_rx_callback(void* pCookie, long type, M_BLK_ID pMblk, LL_HDR_INFO *llHdrInfo, void *muxUserArg)
|
||||
{
|
||||
|
@ -668,7 +668,7 @@ static int ecx_recvpkt(ecx_portt *port, int idx, int stacknumber, M_BLK_ID * pMb
|
|||
* task tNet0 (default), tNet0 fetch what frame index and store a reference to the
|
||||
* received frame in matching MsgQ. The stack user tasks fetch the frame
|
||||
* reference and copies the frame the the RX buffer, when done it free
|
||||
* the frame buffer alloctaed by the Mux.
|
||||
* the frame buffer allocated by the Mux.
|
||||
*
|
||||
* @param[in] port = port context struct
|
||||
* @param[in] idx = requested index of frame
|
||||
|
@ -774,10 +774,10 @@ static int ecx_waitinframe_red(ecx_portt *port, int idx, osal_timert *timer, int
|
|||
/* only do redundant functions when in redundant mode */
|
||||
if (port->redstate != ECT_RED_NONE)
|
||||
{
|
||||
/* primrx if the reveived MAC source on primary socket */
|
||||
/* primrx if the received MAC source on primary socket */
|
||||
primrx = 0;
|
||||
if (wkc > EC_NOFRAME) primrx = port->rxsa[idx];
|
||||
/* secrx if the reveived MAC source on psecondary socket */
|
||||
/* secrx if the received MAC source on psecondary socket */
|
||||
secrx = 0;
|
||||
if (wkc2 > EC_NOFRAME) secrx = port->redport->rxsa[idx];
|
||||
|
||||
|
@ -841,7 +841,7 @@ int ecx_waitinframe(ecx_portt *port, int idx, int timeout)
|
|||
return wkc;
|
||||
}
|
||||
|
||||
/** Blocking send and recieve frame function. Used for non processdata frames.
|
||||
/** Blocking send and receive frame function. Used for non processdata frames.
|
||||
* A datagram is build into a frame and transmitted via this function. It waits
|
||||
* for an answer and returns the workcounter. The function retries if time is
|
||||
* left and the result is WKC=0 or no frame received.
|
||||
|
@ -869,7 +869,7 @@ int ecx_srconfirm(ecx_portt *port, int idx, int timeout)
|
|||
}
|
||||
else
|
||||
{
|
||||
/* normally use partial timout for rx */
|
||||
/* normally use partial timeout for rx */
|
||||
osal_timer_start (&timer2, EC_TIMEOUTRET);
|
||||
}
|
||||
/* get frame from primary or if in redundant mode possibly from secondary */
|
||||
|
|
|
@ -78,7 +78,7 @@ typedef struct ecx_port
|
|||
int rxsa[EC_MAXBUF];
|
||||
/** transmit buffers */
|
||||
ec_bufT txbuf[EC_MAXBUF];
|
||||
/** transmit buffer lenghts */
|
||||
/** transmit buffer lengths */
|
||||
int txbuflength[EC_MAXBUF];
|
||||
/** temporary tx buffer */
|
||||
ec_bufT txbuf2;
|
||||
|
|
|
@ -51,7 +51,7 @@ enum
|
|||
{
|
||||
/** No redundancy, single NIC mode */
|
||||
ECT_RED_NONE,
|
||||
/** Double redundant NIC connecetion */
|
||||
/** Double redundant NIC connection */
|
||||
ECT_RED_DOUBLE
|
||||
};
|
||||
|
||||
|
@ -60,7 +60,7 @@ enum
|
|||
* EtherCAT does not care about MAC addressing, but it is used here to
|
||||
* differentiate the route the packet traverses through the EtherCAT
|
||||
* segment. This is needed to fund out the packet flow in redundant
|
||||
* confihurations. */
|
||||
* configurations. */
|
||||
const uint16 priMAC[3] = { 0x0101, 0x0101, 0x0101 };
|
||||
/** Secondary source MAC address used for EtherCAT. */
|
||||
const uint16 secMAC[3] = { 0x0404, 0x0404, 0x0404 };
|
||||
|
@ -358,7 +358,7 @@ static int ecx_recvpkt(ecx_portt *port, int stacknumber)
|
|||
/** Non blocking receive frame function. Uses RX buffer and index to combine
|
||||
* read frame with transmitted frame. To compensate for received frames that
|
||||
* are out-of-order all frames are stored in their respective indexed buffer.
|
||||
* If a frame was placed in the buffer previously, the function retreives it
|
||||
* If a frame was placed in the buffer previously, the function retrieves it
|
||||
* from that buffer index without calling ec_recvpkt. If the requested index
|
||||
* is not already in the buffer it calls ec_recvpkt to fetch it. There are
|
||||
* three options now, 1 no frame read, so exit. 2 frame read but other
|
||||
|
@ -414,7 +414,7 @@ int ecx_inframe(ecx_portt *port, int idx, int stacknumber)
|
|||
ecp =(ec_comt*)(&(*stack->tempbuf)[ETH_HEADERSIZE]);
|
||||
l = etohs(ecp->elength) & 0x0fff;
|
||||
idxf = ecp->index;
|
||||
/* found index equals reqested index ? */
|
||||
/* found index equals requested index ? */
|
||||
if (idxf == idx)
|
||||
{
|
||||
/* yes, put it in the buffer array (strip ethernet header) */
|
||||
|
@ -440,7 +440,7 @@ int ecx_inframe(ecx_portt *port, int idx, int stacknumber)
|
|||
}
|
||||
else
|
||||
{
|
||||
/* strange things happend */
|
||||
/* strange things happened */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -449,7 +449,7 @@ int ecx_inframe(ecx_portt *port, int idx, int stacknumber)
|
|||
|
||||
}
|
||||
|
||||
/* WKC if mathing frame found */
|
||||
/* WKC if matching frame found */
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
@ -492,10 +492,10 @@ static int ecx_waitinframe_red(ecx_portt *port, int idx, osal_timert *timer)
|
|||
/* only do redundant functions when in redundant mode */
|
||||
if (port->redstate != ECT_RED_NONE)
|
||||
{
|
||||
/* primrx if the reveived MAC source on primary socket */
|
||||
/* primrx if the received MAC source on primary socket */
|
||||
primrx = 0;
|
||||
if (wkc > EC_NOFRAME) primrx = port->rxsa[idx];
|
||||
/* secrx if the reveived MAC source on psecondary socket */
|
||||
/* secrx if the received MAC source on psecondary socket */
|
||||
secrx = 0;
|
||||
if (wkc2 > EC_NOFRAME) secrx = port->redport->rxsa[idx];
|
||||
|
||||
|
@ -559,7 +559,7 @@ int ecx_waitinframe(ecx_portt *port, int idx, int timeout)
|
|||
return wkc;
|
||||
}
|
||||
|
||||
/** Blocking send and recieve frame function. Used for non processdata frames.
|
||||
/** Blocking send and receive frame function. Used for non processdata frames.
|
||||
* A datagram is build into a frame and transmitted via this function. It waits
|
||||
* for an answer and returns the workcounter. The function retries if time is
|
||||
* left and the result is WKC=0 or no frame received.
|
||||
|
@ -587,7 +587,7 @@ int ecx_srconfirm(ecx_portt *port, int idx, int timeout)
|
|||
}
|
||||
else
|
||||
{
|
||||
/* normally use partial timout for rx */
|
||||
/* normally use partial timeout for rx */
|
||||
osal_timer_start (&timer2, EC_TIMEOUTRET);
|
||||
}
|
||||
/* get frame from primary or if in redundant mode possibly from secondary */
|
||||
|
|
|
@ -72,7 +72,7 @@ typedef struct
|
|||
int tempinbufs;
|
||||
/** transmit buffers */
|
||||
ec_bufT txbuf[EC_MAXBUF];
|
||||
/** transmit buffer lenghts */
|
||||
/** transmit buffer lengths */
|
||||
int txbuflength[EC_MAXBUF];
|
||||
/** temporary tx buffer */
|
||||
ec_bufT txbuf2;
|
||||
|
|
|
@ -51,7 +51,7 @@ ec_adaptert * oshw_find_adapters (void)
|
|||
return (NULL);
|
||||
}
|
||||
/* Iterate all devices and create a local copy holding the name and
|
||||
* decsription.
|
||||
* description.
|
||||
*/
|
||||
for(d= alldevs; d != NULL; d= d->next)
|
||||
{
|
||||
|
@ -69,7 +69,7 @@ ec_adaptert * oshw_find_adapters (void)
|
|||
ret_adapter = adapter;
|
||||
}
|
||||
|
||||
/* fetch description and name of the divice from libpcap */
|
||||
/* fetch description and name of the device from libpcap */
|
||||
adapter->next = NULL;
|
||||
if (d->name)
|
||||
{
|
||||
|
@ -115,7 +115,7 @@ ec_adaptert * oshw_find_adapters (void)
|
|||
void oshw_free_adapters (ec_adaptert * adapter)
|
||||
{
|
||||
ec_adaptert * next_adapter;
|
||||
/* Iterate the linked list and free all elemnts holding
|
||||
/* Iterate the linked list and free all elements holding
|
||||
* adapter information
|
||||
*/
|
||||
if(adapter)
|
||||
|
|
|
@ -284,7 +284,7 @@ struct _PACKET_OID_DATA {
|
|||
ULONG Oid; ///< OID code. See the Microsoft DDK documentation or the file ntddndis.h
|
||||
///< for a complete list of valid codes.
|
||||
ULONG Length; ///< Length of the data field
|
||||
UCHAR Data[1]; ///< variable-lenght field that contains the information passed to or received
|
||||
UCHAR Data[1]; ///< variable-length field that contains the information passed to or received
|
||||
///< from the adapter.
|
||||
};
|
||||
typedef struct _PACKET_OID_DATA PACKET_OID_DATA, *PPACKET_OID_DATA;
|
||||
|
|
|
@ -395,7 +395,7 @@ struct pcap_samp
|
|||
|
||||
|
||||
|
||||
//! Maximum lenght of an host name (needed for the RPCAP active mode)
|
||||
//! Maximum length of an host name (needed for the RPCAP active mode)
|
||||
#define RPCAP_HOSTLIST_SIZE 1024
|
||||
|
||||
|
||||
|
|
|
@ -207,7 +207,7 @@ int ecx_BRD(ecx_portt *port, uint16 ADP, uint16 ADO, uint16 length, void *data,
|
|||
/** APRD "auto increment address read" primitive. Blocking.
|
||||
*
|
||||
* @param[in] port = port context struct
|
||||
* @param[in] ADP = Address Position, each slave ++, slave that has 0 excecutes
|
||||
* @param[in] ADP = Address Position, each slave ++, slave that has 0 executes
|
||||
* @param[in] ADO = Address Offset, slave memory address
|
||||
* @param[in] length = length of databuffer
|
||||
* @param[out] data = databuffer to put slave data in
|
||||
|
|
|
@ -131,7 +131,7 @@ int ecx_SDOread(ecx_contextt *context, uint16 slave, uint16 index, uint8 subinde
|
|||
boolean NotLast;
|
||||
|
||||
ec_clearmbx(&MbxIn);
|
||||
/* Empty slave out mailbox if something is in. Timout set to 0 */
|
||||
/* Empty slave out mailbox if something is in. Timeout set to 0 */
|
||||
wkc = ecx_mbxreceive(context, slave, (ec_mbxbuft *)&MbxIn, 0);
|
||||
ec_clearmbx(&MbxOut);
|
||||
aSDOp = (ec_SDOt *)&MbxIn;
|
||||
|
@ -226,7 +226,7 @@ int ecx_SDOread(ecx_contextt *context, uint16 slave, uint16 index, uint8 subinde
|
|||
SDOp->ldata[0] = 0;
|
||||
/* send segmented upload request to slave */
|
||||
wkc = ecx_mbxsend(context, slave, (ec_mbxbuft *)&MbxOut, EC_TIMEOUTTXM);
|
||||
/* is mailbox transfered to slave ? */
|
||||
/* is mailbox transferred to slave ? */
|
||||
if (wkc > 0)
|
||||
{
|
||||
ec_clearmbx(&MbxIn);
|
||||
|
@ -246,7 +246,7 @@ int ecx_SDOread(ecx_contextt *context, uint16 slave, uint16 index, uint8 subinde
|
|||
{ /* last segment */
|
||||
NotLast = FALSE;
|
||||
if (Framedatasize == 7)
|
||||
/* substract unused bytes from frame */
|
||||
/* subtract unused bytes from frame */
|
||||
Framedatasize = Framedatasize - ((aSDOp->Command & 0x0e) >> 1);
|
||||
/* copy to parameter buffer */
|
||||
memcpy(hp, &(aSDOp->Index), Framedatasize);
|
||||
|
@ -258,7 +258,7 @@ int ecx_SDOread(ecx_contextt *context, uint16 slave, uint16 index, uint8 subinde
|
|||
/* increment buffer pointer */
|
||||
hp += Framedatasize;
|
||||
}
|
||||
/* update parametersize */
|
||||
/* update parameter size */
|
||||
*psize += Framedatasize;
|
||||
}
|
||||
/* unexpected frame returned from slave */
|
||||
|
@ -339,7 +339,7 @@ int ecx_SDOwrite(ecx_contextt *context, uint16 Slave, uint16 Index, uint8 SubInd
|
|||
uint8 *hp;
|
||||
|
||||
ec_clearmbx(&MbxIn);
|
||||
/* Empty slave out mailbox if something is in. Timout set to 0 */
|
||||
/* Empty slave out mailbox if something is in. Timeout set to 0 */
|
||||
wkc = ecx_mbxreceive(context, Slave, (ec_mbxbuft *)&MbxIn, 0);
|
||||
ec_clearmbx(&MbxOut);
|
||||
aSDOp = (ec_SDOt *)&MbxIn;
|
||||
|
@ -558,7 +558,7 @@ int ecx_RxPDO(ecx_contextt *context, uint16 Slave, uint16 RxPDOnumber, int psize
|
|||
uint16 framedatasize;
|
||||
|
||||
ec_clearmbx(&MbxIn);
|
||||
/* Empty slave out mailbox if something is in. Timout set to 0 */
|
||||
/* Empty slave out mailbox if something is in. Timeout set to 0 */
|
||||
wkc = ecx_mbxreceive(context, Slave, (ec_mbxbuft *)&MbxIn, 0);
|
||||
ec_clearmbx(&MbxOut);
|
||||
SDOp = (ec_SDOt *)&MbxOut;
|
||||
|
@ -605,7 +605,7 @@ int ecx_TxPDO(ecx_contextt *context, uint16 slave, uint16 TxPDOnumber , int *psi
|
|||
uint16 framedatasize;
|
||||
|
||||
ec_clearmbx(&MbxIn);
|
||||
/* Empty slave out mailbox if something is in. Timout set to 0 */
|
||||
/* Empty slave out mailbox if something is in. Timeout set to 0 */
|
||||
wkc = ecx_mbxreceive(context, slave, (ec_mbxbuft *)&MbxIn, 0);
|
||||
ec_clearmbx(&MbxOut);
|
||||
aSDOp = (ec_SDOt *)&MbxIn;
|
||||
|
@ -805,7 +805,7 @@ int ecx_readPDOassignCA(ecx_contextt *context, uint16 Slave, int Thread_n,
|
|||
* @param[in] Slave = Slave number
|
||||
* @param[out] Osize = Size in bits of output mapping (rxPDO) found
|
||||
* @param[out] Isize = Size in bits of input mapping (txPDO) found
|
||||
* @return >0 if mapping succesful.
|
||||
* @return >0 if mapping successful.
|
||||
*/
|
||||
int ecx_readPDOmap(ecx_contextt *context, uint16 Slave, int *Osize, int *Isize)
|
||||
{
|
||||
|
@ -905,7 +905,7 @@ int ecx_readPDOmap(ecx_contextt *context, uint16 Slave, int *Osize, int *Isize)
|
|||
* @param[in] Thread_n = Calling thread index
|
||||
* @param[out] Osize = Size in bits of output mapping (rxPDO) found
|
||||
* @param[out] Isize = Size in bits of input mapping (txPDO) found
|
||||
* @return >0 if mapping succesful.
|
||||
* @return >0 if mapping successful.
|
||||
*/
|
||||
int ecx_readPDOmapCA(ecx_contextt *context, uint16 Slave, int Thread_n, int *Osize, int *Isize)
|
||||
{
|
||||
|
|
|
@ -22,14 +22,6 @@
|
|||
#include "ethercatsoe.h"
|
||||
#include "ethercatconfig.h"
|
||||
|
||||
// define if debug printf is needed
|
||||
//#define EC_DEBUG
|
||||
|
||||
#ifdef EC_DEBUG
|
||||
#define EC_PRINT printf
|
||||
#else
|
||||
#define EC_PRINT(...) do {} while (0)
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -40,7 +32,9 @@ typedef struct
|
|||
} ecx_mapt_t;
|
||||
|
||||
ecx_mapt_t ecx_mapt[EC_MAX_MAPT];
|
||||
#if EC_MAX_MAPT > 1
|
||||
OSAL_THREAD_HANDLE ecx_threadh[EC_MAX_MAPT];
|
||||
#endif
|
||||
|
||||
#ifdef EC_VER1
|
||||
/** Slave configuration structure */
|
||||
|
@ -330,7 +324,7 @@ int ecx_config_init(ecx_contextt *context, uint8 usetable)
|
|||
ADPh = (uint16)(1 - slave);
|
||||
val16 = ecx_APRDw(context->port, ADPh, ECT_REG_PDICTL, EC_TIMEOUTRET3); /* read interface type of slave */
|
||||
context->slavelist[slave].Itype = etohs(val16);
|
||||
/* a node offset is used to improve readibility of network frames */
|
||||
/* a node offset is used to improve readability of network frames */
|
||||
/* this has no impact on the number of addressable slaves (auto wrap around) */
|
||||
ecx_APWRw(context->port, ADPh, ECT_REG_STADR, htoes(slave + EC_NODEOFFSET) , EC_TIMEOUTRET3); /* set node address of slave */
|
||||
if (slave == 1)
|
||||
|
@ -793,6 +787,7 @@ static int ecx_map_sm(ecx_contextt *context, uint16 slave)
|
|||
return 1;
|
||||
}
|
||||
|
||||
#if EC_MAX_MAPT > 1
|
||||
OSAL_THREAD_FUNC ecx_mapper_thread(void *param)
|
||||
{
|
||||
ecx_mapt_t *maptp;
|
||||
|
@ -818,6 +813,7 @@ static int ecx_find_mapt(void)
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static int ecx_get_threadcount(void)
|
||||
{
|
||||
|
@ -844,13 +840,7 @@ static void ecx_config_find_mappings(ecx_contextt *context, uint8 group)
|
|||
{
|
||||
if (!group || (group == context->slavelist[slave].group))
|
||||
{
|
||||
if (EC_MAX_MAPT <= 1)
|
||||
{
|
||||
/* serialised version */
|
||||
ecx_map_coe_soe(context, slave, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if EC_MAX_MAPT > 1
|
||||
/* multi-threaded version */
|
||||
while ((thrn = ecx_find_mapt()) < 0)
|
||||
{
|
||||
|
@ -862,7 +852,10 @@ static void ecx_config_find_mappings(ecx_contextt *context, uint8 group)
|
|||
ecx_mapt[thrn].running = 1;
|
||||
osal_thread_create(&(ecx_threadh[thrn]), 128000,
|
||||
&ecx_mapper_thread, &(ecx_mapt[thrn]));
|
||||
}
|
||||
#else
|
||||
/* serialised version */
|
||||
ecx_map_coe_soe(context, slave, 0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
/* wait for all threads to finish */
|
||||
|
@ -931,7 +924,7 @@ static void ecx_config_create_input_mappings(ecx_contextt *context, void *pIOmap
|
|||
{
|
||||
SMc++;
|
||||
}
|
||||
/* if addresses from more SM connect use one FMMU otherwise break up in mutiple FMMU */
|
||||
/* if addresses from more SM connect use one FMMU otherwise break up in multiple FMMU */
|
||||
if (etohs(context->slavelist[slave].SM[SMc].StartAddr) > EndAddr)
|
||||
{
|
||||
break;
|
||||
|
@ -1052,7 +1045,7 @@ static void ecx_config_create_output_mappings(ecx_contextt *context, void *pIOma
|
|||
{
|
||||
SMc++;
|
||||
}
|
||||
/* if addresses from more SM connect use one FMMU otherwise break up in mutiple FMMU */
|
||||
/* if addresses from more SM connect use one FMMU otherwise break up in multiple FMMU */
|
||||
if (etohs(context->slavelist[slave].SM[SMc].StartAddr) > EndAddr)
|
||||
{
|
||||
break;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
/** \file
|
||||
* \brief
|
||||
* DEPRICATED Configuration list of known EtherCAT slave devices.
|
||||
* DEPRECATED Configuration list of known EtherCAT slave devices.
|
||||
*
|
||||
* If a slave is found in this list it is configured according to the parameters
|
||||
* in the list. Otherwise the configuration info is read directly from the slave
|
||||
|
|
|
@ -56,7 +56,7 @@ void ecx_dcsync0(ecx_contextt *context, uint16 slave, boolean act, uint32 CyclTi
|
|||
|
||||
/* Calculate first trigger time, always a whole multiple of CyclTime rounded up
|
||||
plus the shifttime (can be negative)
|
||||
This insures best sychronisation between slaves, slaves with the same CyclTime
|
||||
This insures best synchronization between slaves, slaves with the same CyclTime
|
||||
will sync at the same moment (you can use CyclShift to shift the sync) */
|
||||
if (CyclTime > 0)
|
||||
{
|
||||
|
@ -119,7 +119,7 @@ void ecx_dcsync01(ecx_contextt *context, uint16 slave, boolean act, uint32 CyclT
|
|||
|
||||
/* Calculate first trigger time, always a whole multiple of TrueCyclTime rounded up
|
||||
plus the shifttime (can be negative)
|
||||
This insures best sychronisation between slaves, slaves with the same CyclTime
|
||||
This insures best synchronization between slaves, slaves with the same CyclTime
|
||||
will sync at the same moment (you can use CyclShift to shift the sync) */
|
||||
if (CyclTime0 > 0)
|
||||
{
|
||||
|
|
|
@ -81,7 +81,7 @@ int ecx_FOEread(ecx_contextt *context, uint16 slave, char *filename, uint32 pass
|
|||
|
||||
buffersize = *psize;
|
||||
ec_clearmbx(&MbxIn);
|
||||
/* Empty slave out mailbox if something is in. Timout set to 0 */
|
||||
/* Empty slave out mailbox if something is in. Timeout set to 0 */
|
||||
wkc = ecx_mbxreceive(context, slave, (ec_mbxbuft *)&MbxIn, 0);
|
||||
ec_clearmbx(&MbxOut);
|
||||
aFOEp = (ec_FOEt *)&MbxIn;
|
||||
|
@ -209,7 +209,7 @@ int ecx_FOEwrite(ecx_contextt *context, uint16 slave, char *filename, uint32 pas
|
|||
int tsize;
|
||||
|
||||
ec_clearmbx(&MbxIn);
|
||||
/* Empty slave out mailbox if something is in. Timout set to 0 */
|
||||
/* Empty slave out mailbox if something is in. Timeout set to 0 */
|
||||
wkc = ecx_mbxreceive(context, slave, (ec_mbxbuft *)&MbxIn, 0);
|
||||
ec_clearmbx(&MbxOut);
|
||||
aFOEp = (ec_FOEt *)&MbxIn;
|
||||
|
|
|
@ -324,7 +324,7 @@ void ecx_close(ecx_contextt *context)
|
|||
|
||||
/** Read one byte from slave EEPROM via cache.
|
||||
* If the cache location is empty then a read request is made to the slave.
|
||||
* Depending on the slave capabillities the request is 4 or 8 bytes.
|
||||
* Depending on the slave capabilities the request is 4 or 8 bytes.
|
||||
* @param[in] context = context struct
|
||||
* @param[in] slave = slave number
|
||||
* @param[in] address = eeprom address in bytes (slave uses words)
|
||||
|
@ -728,7 +728,7 @@ int ecx_readstate(ecx_contextt *context)
|
|||
boolean allslavespresent = FALSE;
|
||||
int wkc;
|
||||
|
||||
/* Try to establish the state of all slaves sending only one broadcast datargam.
|
||||
/* Try to establish the state of all slaves sending only one broadcast datagram.
|
||||
* This way a number of datagrams equal to the number of slaves will be sent only if needed.*/
|
||||
rval = 0;
|
||||
wkc = ecx_BRD(context->port, 0, ECT_REG_ALSTAT, sizeof(rval), &rval, EC_TIMEOUTRET);
|
||||
|
@ -855,7 +855,7 @@ int ecx_writestate(ecx_contextt *context, uint16 slave)
|
|||
* @param[in] context = context struct
|
||||
* @param[in] slave = Slave number, 0 = all slaves (only the "slavelist[0].state" is refreshed)
|
||||
* @param[in] reqstate = Requested state
|
||||
* @param[in] timeout = Timout value in us
|
||||
* @param[in] timeout = Timeout value in us
|
||||
* @return Requested state, or found state after timeout.
|
||||
*/
|
||||
uint16 ecx_statecheck(ecx_contextt *context, uint16 slave, uint16 reqstate, int timeout)
|
||||
|
@ -2152,7 +2152,7 @@ int ec_writestate(uint16 slave)
|
|||
* This is a blocking function.
|
||||
* @param[in] slave = Slave number, 0 = all slaves
|
||||
* @param[in] reqstate = Requested state
|
||||
* @param[in] timeout = Timout value in us
|
||||
* @param[in] timeout = Timeout value in us
|
||||
* @return Requested state, or found state after timeout.
|
||||
* @see ecx_statecheck
|
||||
*/
|
||||
|
|
|
@ -252,7 +252,7 @@ typedef struct ec_group
|
|||
int16 Ebuscurrent;
|
||||
/** if >0 block use of LRW in processdata */
|
||||
uint8 blockLRW;
|
||||
/** IO segegments used */
|
||||
/** IO segments used */
|
||||
uint16 nsegments;
|
||||
/** 1st input segment */
|
||||
uint16 Isegment;
|
||||
|
@ -287,9 +287,9 @@ typedef struct ec_eepromSM
|
|||
uint16 PhStart;
|
||||
uint16 Plength;
|
||||
uint8 Creg;
|
||||
uint8 Sreg; /* dont care */
|
||||
uint8 Sreg; /* don't care */
|
||||
uint8 Activate;
|
||||
uint8 PDIctrl; /* dont care */
|
||||
uint8 PDIctrl; /* don't care */
|
||||
} ec_eepromSMt;
|
||||
|
||||
/** record to store rxPDO and txPDO table from eeprom */
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
* Module to convert EtherCAT errors to readable messages.
|
||||
*
|
||||
* SDO abort messages and AL status codes are used to relay slave errors to
|
||||
* the user application. This module converts the binary codes to readble text.
|
||||
* the user application. This module converts the binary codes to readable text.
|
||||
* For the defined error codes see the EtherCAT protocol documentation.
|
||||
*/
|
||||
|
||||
|
@ -215,7 +215,7 @@ const ec_mbxerrorlist_t ec_mbxerrorlist[] = {
|
|||
{0x0005, "Invalid mailbox header"},
|
||||
{0x0006, "Length of received mailbox data is too short"},
|
||||
{0x0007, "No more memory in slave"},
|
||||
{0x0008, "The lenght of data is inconsistent"},
|
||||
{0x0008, "The length of data is inconsistent"},
|
||||
{0xffff, "Unknown"}
|
||||
};
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ void ecx_SoEerror(ecx_contextt *context, uint16 Slave, uint16 idn, uint16 Error)
|
|||
* @param[in] context = context struct
|
||||
* @param[in] slave = Slave number
|
||||
* @param[in] driveNo = Drive number in slave
|
||||
* @param[in] elementflags = Flags to select what properties of IDN are to be transfered.
|
||||
* @param[in] elementflags = Flags to select what properties of IDN are to be transferred.
|
||||
* @param[in] idn = IDN.
|
||||
* @param[in,out] psize = Size in bytes of parameter buffer, returns bytes read from SoE.
|
||||
* @param[out] p = Pointer to parameter buffer
|
||||
|
@ -190,7 +190,7 @@ int ecx_SoEread(ecx_contextt *context, uint16 slave, uint8 driveNo, uint8 elemen
|
|||
* @param[in] context = context struct
|
||||
* @param[in] slave = Slave number
|
||||
* @param[in] driveNo = Drive number in slave
|
||||
* @param[in] elementflags = Flags to select what properties of IDN are to be transfered.
|
||||
* @param[in] elementflags = Flags to select what properties of IDN are to be transferred.
|
||||
* @param[in] idn = IDN.
|
||||
* @param[in] psize = Size in bytes of parameter buffer.
|
||||
* @param[out] p = Pointer to parameter buffer
|
||||
|
@ -307,7 +307,7 @@ int ecx_SoEwrite(ecx_contextt *context, uint16 slave, uint8 driveNo, uint8 eleme
|
|||
* @param[in] slave = Slave number
|
||||
* @param[out] Osize = Size in bits of output mapping (MTD) found
|
||||
* @param[out] Isize = Size in bits of input mapping (AT) found
|
||||
* @return >0 if mapping succesful.
|
||||
* @return >0 if mapping successful.
|
||||
*/
|
||||
int ecx_readIDNmap(ecx_contextt *context, uint16 slave, int *Osize, int *Isize)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue