Tektronix WFM 601M Wheelchair User Manual


 
Remote Command Processing Code
C–58
WFM 601A, WFM 601E & WFM 601M User Manual
register char sendChar; /* Char to send to the instrument */
char recvChar; /* Char received from the instrument */
unsigned int portStatus; /* Status of the serial port */
int isQuery = 0; /* Set if portMsg is a query */
char *baseUnexp; /* The base unexpected response */
register int libError; /* Error code returned from library */
int iq_size; /* Unused return arg required by lib */
int iSendAttempt; /* Counter to halt pgm after x retries */
/* Return invalid port when port has not been initialized */
if ( comPort == 0 )
return INV_PORT;
/* Set the base unexpected response pointer */
baseUnexp = unexpectedResp;
/* Initialize the send attempt counter */
iSendAttempt = 0;
/* Loop until we reach the end of string */
while ((sendChar = *portMsg) != '\0')
{
/* Force character to be lower case */
if ( isupper(sendChar) )
sendChar = tolower(sendChar);
/* Send the current character to the instrument */
if ((libError = wrtch_a1 (comPort, sendChar)) != A_OK)
return libError;
/* Wait (up to 10 seconds) for char to be sent */
libError = drain_a1(2, 10 * 19, 0);
/* Complain if char was not sent (bad cable?) */
if (libError != A_OK && libError != TIMEOUT)
return libError;
/* Record whether this is a query command */
if ( sendChar == '?' )
isQuery = 1;
/* Loop until all characters are sent */
for(;;)
{
/* Wait up to 30 seconds for instrument response */
iwait_a1 (comPort, 30 * 19L, &portStatus, cancelFunc);
/* Get the instrument echo character */
libError = rdch_a1(comPort, &recvChar, &iq_size, &portStatus);
/* On any error (bad cable) return error */
if (libError != A_OK)
{