Remote Command Processing Code
C–60 WFM 601A, WFM 601E & WFM 601M User Manual
/* Break out of this loop and halt the program if
* the max number of retries has been exceeded.
*/
if (iSendAttempt++ > NUMBER_OF_RETRIES)
{
strcpy(expectedResp, "NADA");
printf("\nUnrelated character returned");
getch();
return libError;
}
} /* end for(;;) character sending loop */
} /* end while() port message sending loop */
/*
* If this is a query, read the next line.
* Wait forever until we get it.
*/
if ( isQuery )
{
for (;;)
{
/* Wait up to 20 seconds for instrument response */
if ( (libError = iwait_a1 (comPort, 20 * 19L,
&portStatus, cancelFunc)) != A_OK)
return libError;
/* Get the instrument echo character */
if ( (libError =
rdch_a1(comPort, expectedResp, &iq_size, &portStatus)) != A_OK)
return libError;
/* Advance if character read wasn't a return */
if ( *expectedResp != '\n' )
expectedResp++;
else
{
/* It was... expect a trailing '\r' */
if ((libError =iwait_a1(comPort, 20 * 19L,
&portStatus, cancelFunc)) != A_OK)
return libError;
/* Get the instrument echo character */
if ((libError =
rdch_a1(comPort, &recvChar, &iq_size, &portStatus)) != A_OK)
return libError;
/* Check if we failed to get a trailing return */
if ( recvChar != '\r' )
return W_INVALID_RESP;
break;
}
}
}