I am pressing a button which has a command built in to turn a servo on an arduino 90 degrees. It works no problem but after it moves on the console it still trys to send the command again and again and uses up its number of retries.
Code:
private void btnTurnServo0_Click_1(object sender, EventArgs e)
{
Cancel = false;
if (DiscoverDevice(false) == false)
{
MessageBox.Show("Error, device is not responding");
return;
}
string servo = "";
MyModemSerialInterfaceLayer.WriteTextAndWaitForResponse("TL,S," + txtToolID.Text + ",30", "\r\n", 4, ref servo, 500);
string Settings = "";
MyModemSerialInterfaceLayer.WriteTextAndWaitForResponse("TL,T," + txtToolID.Text + "\r\n", "\r\n", 4, ref Settings, 500);
ReleaseDevice();//release the config tool after config is completed
}
Code:
while (true)
{
//looking for the RX Response from the UUT, indicating that the message was successfully received
System.Threading.Thread.Sleep(1);
if (Timer-- <= 0)//timed out, see if we can retry of simply fail
{
Parent.UpdateConsole("Retry Command\r\n");
if (NumberRetries-- > 0)
{
ReturnString = "";
TesterComPort.WriteLine(Command);//write command to UUT
Timer = TimeToWait;//reset counter
}
else
{
Parent.UpdateConsole("Used up Retries\r\n");
return false;//timed out
}
}