Skip to content

Commit

Permalink
Fix return value of ecx_writestate
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikael Heden committed Feb 17, 2016
1 parent d5fa116 commit 59e2164
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions soem/ethercatmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -800,26 +800,29 @@ int ecx_readstate(ecx_contextt *context)

/** Write slave state, if slave = 0 then write to all slaves.
* The function does not check if the actual state is changed.
* @param[in] context = context struct
* @param[in] context = context struct
* @param[in] slave = Slave number, 0 = master
* @return 0
* @return Workcounter or EC_NOFRAME
*/
int ecx_writestate(ecx_contextt *context, uint16 slave)
{
int ret;
uint16 configadr, slstate;

if (slave == 0)
{
slstate = htoes(context->slavelist[slave].state);
ecx_BWR(context->port, 0, ECT_REG_ALCTL, sizeof(slstate), &slstate, EC_TIMEOUTRET3); /* write slave status */
ret = ecx_BWR(context->port, 0, ECT_REG_ALCTL, sizeof(slstate),
&slstate, EC_TIMEOUTRET3);
}
else
{
configadr = context->slavelist[slave].configadr;

ecx_FPWRw(context->port, configadr, ECT_REG_ALCTL, htoes(context->slavelist[slave].state), EC_TIMEOUTRET3); /* write slave status */
ret = ecx_FPWRw(context->port, configadr, ECT_REG_ALCTL,
htoes(context->slavelist[slave].state), EC_TIMEOUTRET3);
}
return 0;
return ret;
}

/** Check actual slave state.
Expand Down

0 comments on commit 59e2164

Please sign in to comment.