Skip to content

Commit

Permalink
Merge pull request OpenEtherCATsociety#77 from alberth/improve_tutori…
Browse files Browse the repository at this point in the history
…al_and_documentation

Improve tutorial and documentation
  • Loading branch information
nakarlsson authored Feb 14, 2017
2 parents cfd5adf + 6c37e94 commit 712fac0
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 16 deletions.
12 changes: 7 additions & 5 deletions doc/tutorial.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ have a dedicated NIC selected in the nicdrv.c. It returns >0 if succeeded.
\code

/* initialise SOEM, bind socket to ifname */
if (ec_init(ifname))
if (ec_init(ifname) > 0)

\endcode

Expand Down Expand Up @@ -120,8 +120,10 @@ That is the primary key to detect errors.
\code

char IOmap[128];
int usedmem;
...
ec_config_map(&IOmap);
usedmem = ec_config_map(&IOmap);
if (usedmem <= sizeof(IOmap))
...
\endcode

Expand Down Expand Up @@ -258,7 +260,7 @@ if( inOP && ((wkc < expectedWKC) || ec_group[currentgroup].docheckstate))
ec_slave[slave].state = EC_STATE_OPERATIONAL;
ec_writestate(slave);
}
else if(ec_slave[slave].state > 0)
else if(ec_slave[slave].state > EC_STATE_NONE)
{
if (ec_reconfig_slave(slave, EC_TIMEOUTMON))
{
Expand All @@ -270,7 +272,7 @@ if( inOP && ((wkc < expectedWKC) || ec_group[currentgroup].docheckstate))
{
/* re-check state */
ec_statecheck(slave, EC_STATE_OPERATIONAL, EC_TIMEOUTRET);
if (!ec_slave[slave].state)
if (ec_slave[slave].state == EC_STATE_NONE)
{
ec_slave[slave].islost = TRUE;
printf("ERROR : slave %d lost\n",slave);
Expand All @@ -279,7 +281,7 @@ if( inOP && ((wkc < expectedWKC) || ec_group[currentgroup].docheckstate))
}
if (ec_slave[slave].islost)
{
if(!ec_slave[slave].state)
if(ec_slave[slave].state == EC_STATE_NONE)
{
if (ec_recover_slave(slave, EC_TIMEOUTMON))
{
Expand Down
2 changes: 1 addition & 1 deletion soem/ethercatmain.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ typedef struct
uint8 group;
/** first unused FMMU */
uint8 FMMUunused;
/** TRUE is slave is not responding at all */
/** Boolean for tracking whether the slave is (not) responding, not used/set by the SOEM library */
boolean islost;
/** registered configuration function PO->SO */
int (*PO2SOconfig)(uint16 slave);
Expand Down
4 changes: 3 additions & 1 deletion soem/ethercattype.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,14 @@ typedef enum
/** Possible EtherCAT slave states */
typedef enum
{
/** No valid state. */
EC_STATE_NONE = 0x00,
/** Init state*/
EC_STATE_INIT = 0x01,
/** Pre-operational. */
EC_STATE_PRE_OP = 0x02,
/** Boot state*/
EC_STATE_BOOT = 0x03,
EC_STATE_BOOT = 0x03,
/** Safe-operational. */
EC_STATE_SAFE_OP = 0x04,
/** Operational */
Expand Down
6 changes: 3 additions & 3 deletions test/linux/red_test/red_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ OSAL_THREAD_FUNC ecatcheck( void *ptr )
ec_slave[slave].state = EC_STATE_OPERATIONAL;
ec_writestate(slave);
}
else if(ec_slave[slave].state > 0)
else if(ec_slave[slave].state > EC_STATE_NONE)
{
if (ec_reconfig_slave(slave, EC_TIMEOUTMON))
{
Expand All @@ -269,7 +269,7 @@ OSAL_THREAD_FUNC ecatcheck( void *ptr )
{
/* re-check state */
ec_statecheck(slave, EC_STATE_OPERATIONAL, EC_TIMEOUTRET);
if (!ec_slave[slave].state)
if (ec_slave[slave].state == EC_STATE_NONE)
{
ec_slave[slave].islost = TRUE;
printf("ERROR : slave %d lost\n",slave);
Expand All @@ -278,7 +278,7 @@ OSAL_THREAD_FUNC ecatcheck( void *ptr )
}
if (ec_slave[slave].islost)
{
if(!ec_slave[slave].state)
if(ec_slave[slave].state == EC_STATE_NONE)
{
if (ec_recover_slave(slave, EC_TIMEOUTMON))
{
Expand Down
6 changes: 3 additions & 3 deletions test/linux/simple_test/simple_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ OSAL_THREAD_FUNC ecatcheck( void *ptr )
ec_slave[slave].state = EC_STATE_OPERATIONAL;
ec_writestate(slave);
}
else if(ec_slave[slave].state > 0)
else if(ec_slave[slave].state > EC_STATE_NONE)
{
if (ec_reconfig_slave(slave, EC_TIMEOUTMON))
{
Expand All @@ -188,7 +188,7 @@ OSAL_THREAD_FUNC ecatcheck( void *ptr )
{
/* re-check state */
ec_statecheck(slave, EC_STATE_OPERATIONAL, EC_TIMEOUTRET);
if (!ec_slave[slave].state)
if (ec_slave[slave].state == EC_STATE_NONE)
{
ec_slave[slave].islost = TRUE;
printf("ERROR : slave %d lost\n",slave);
Expand All @@ -197,7 +197,7 @@ OSAL_THREAD_FUNC ecatcheck( void *ptr )
}
if (ec_slave[slave].islost)
{
if(!ec_slave[slave].state)
if(ec_slave[slave].state == EC_STATE_NONE)
{
if (ec_recover_slave(slave, EC_TIMEOUTMON))
{
Expand Down
6 changes: 3 additions & 3 deletions test/win32/simple_test/simple_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ OSAL_THREAD_FUNC ecatcheck(void *lpParam)
ec_slave[slave].state = EC_STATE_OPERATIONAL;
ec_writestate(slave);
}
else if(ec_slave[slave].state > 0)
else if(ec_slave[slave].state > EC_STATE_NONE)
{
if (ec_reconfig_slave(slave, EC_TIMEOUTMON))
{
Expand All @@ -307,7 +307,7 @@ OSAL_THREAD_FUNC ecatcheck(void *lpParam)
{
/* re-check state */
ec_statecheck(slave, EC_STATE_OPERATIONAL, EC_TIMEOUTRET);
if (!ec_slave[slave].state)
if (ec_slave[slave].state == EC_STATE_NONE)
{
ec_slave[slave].islost = TRUE;
printf("ERROR : slave %d lost\n",slave);
Expand All @@ -316,7 +316,7 @@ OSAL_THREAD_FUNC ecatcheck(void *lpParam)
}
if (ec_slave[slave].islost)
{
if(!ec_slave[slave].state)
if(ec_slave[slave].state == EC_STATE_NONE)
{
if (ec_recover_slave(slave, EC_TIMEOUTMON))
{
Expand Down

0 comments on commit 712fac0

Please sign in to comment.