minor_improvement/ ecx_statecheck() improved
ecx_statecheck() when called with the first argument set to 0 automatically updates the state of all the slaves in the slavelist structure when possible,
This commit is contained in:
parent
03601959b6
commit
28927aab87
|
@ -849,9 +849,39 @@ uint16 ecx_statecheck(ecx_contextt *context, uint16 slave, uint16 reqstate, int
|
||||||
{
|
{
|
||||||
if (slave < 1)
|
if (slave < 1)
|
||||||
{
|
{
|
||||||
|
uint16 bitWiseState;
|
||||||
|
uint16 slaveIndex;
|
||||||
|
|
||||||
rval = 0;
|
rval = 0;
|
||||||
ecx_BRD(context->port, 0, ECT_REG_ALSTAT, sizeof(rval), &rval , EC_TIMEOUTRET);
|
ecx_BRD(context->port, 0, ECT_REG_ALSTAT, sizeof(rval), &rval , EC_TIMEOUTRET);
|
||||||
rval = etohs(rval);
|
rval = etohs(rval);
|
||||||
|
bitWiseState = (rval & 0x0f);
|
||||||
|
|
||||||
|
if((rval & 0xf0) == 0)
|
||||||
|
{
|
||||||
|
/* No slave has toggled the error flag so the alstatuscode (even if different from 0) should be ignored */
|
||||||
|
for(slaveIndex = 0; slaveIndex < *(context->slavecount); slaveIndex++)
|
||||||
|
{
|
||||||
|
ec_slave[slaveIndex].ALstatuscode = 0x0000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(bitWiseState)
|
||||||
|
{
|
||||||
|
case EC_STATE_INIT:
|
||||||
|
case EC_STATE_PRE_OP:
|
||||||
|
case EC_STATE_BOOT:
|
||||||
|
case EC_STATE_SAFE_OP:
|
||||||
|
case EC_STATE_OPERATIONAL:
|
||||||
|
/* All the slaves have reached the same state so we can update the state of every slave */
|
||||||
|
for(slaveIndex = 0; slaveIndex < *(context->slavecount); slaveIndex++)
|
||||||
|
{
|
||||||
|
ec_slave[slaveIndex].state = bitWiseState;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue