Instead of copying code, I would like to call to another function.
There are two functions, the one function, GetSlaves() returns with a number of slaves found during a scan.
Thing is, I suspect sometimes the returned value is incorrect, while a slave is down or stuck. Therefore I would like to run the GetSlaves function again if I am not happy with the number of slaves found. Please see the code below, questions follow.
SetSlaves(slaves)
{
if (slaves<3 || slaves>6) // I expect 4 or 6 to be found
{
for (tmp2 = 0; tmp2<3; tmp2++) // Try 3 times
{
GetSlaves(); // This function will scan for new slaves and then call SetSlaves(slaves);
}
}
else
{
WriteFlash(VMSSlaves,slaves); // I am happy with what was found, Sets the number of slaves found
}
}
My Question is, when the primary function is called again from the For statement, will it update the slaves variable (for instance a 4 is returned) and exit the IF and thus also the FOR..
Or, will the loop be endless if a slave is down and the two functions will call each other endlessly?
Aucun commentaire:
Enregistrer un commentaire