Skip to content

Commit

Permalink
Merge pull request OpenEtherCATsociety#256 from claudioscordino/upstr…
Browse files Browse the repository at this point in the history
…eam-new

Clean up comments, EC_PRINT and thread usage.
  • Loading branch information
ArthurKetels authored Feb 14, 2019
2 parents 037a629 + e0d880d commit 8832ef0
Show file tree
Hide file tree
Showing 38 changed files with 184 additions and 130 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ install
*~
/doc/latex
/doc/html
tags
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ Linux
* `cmake ..`
* `make`

Documentation
-------------

See https://openethercatsociety.github.io/doc/soem/


Want to contribute to SOEM or SOES?
-----------------------------------

Expand Down
8 changes: 4 additions & 4 deletions doc/soem.dox
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down
9 changes: 9 additions & 0 deletions osal/intime/osal_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion osal/linux/osal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
9 changes: 9 additions & 0 deletions osal/linux/osal_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__))
Expand Down
2 changes: 1 addition & 1 deletion osal/rtems/osal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
9 changes: 9 additions & 0 deletions osal/rtems/osal_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__))
Expand Down
9 changes: 9 additions & 0 deletions osal/rtk/osal_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__))
Expand Down
9 changes: 9 additions & 0 deletions osal/vxworks/osal_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__))
Expand Down
9 changes: 9 additions & 0 deletions osal/win32/osal_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions oshw/intime/nicdrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -46,7 +46,7 @@ enum
{
/** No redundancy, single NIC mode */
ECT_RED_NONE,
/** Double redundant NIC connecetion */
/** Double redundant NIC connection */
ECT_RED_DOUBLE
};

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) */
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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];

Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion oshw/intime/nicdrv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 9 additions & 9 deletions oshw/linux/nicdrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ enum
{
/** No redundancy, single NIC mode */
ECT_RED_NONE,
/** Double redundant NIC connecetion */
/** Double redundant NIC connection */
ECT_RED_DOUBLE
};

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) */
Expand All @@ -439,7 +439,7 @@ int ecx_inframe(ecx_portt *port, int idx, int stacknumber)
}
else
{
/* strange things happend */
/* strange things happened */
}
}
}
Expand All @@ -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;
}

Expand Down Expand Up @@ -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];

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion oshw/linux/nicdrv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions oshw/linux/oshw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Loading

0 comments on commit 8832ef0

Please sign in to comment.