Computer Operations
Computer Interface Commands and Operation
4
4-63
asiputs( COM2, "ECHO 0", -2); /* Turn off command echo on Hydra */
checkResponse(); /* Get prompt */
/* Open data file TESTDATA.PRN */
if((testdata = fopen("testdata.prn","w")) == NULL)
{
perror("Cannot open testdata.prn");
exit(1);
}
/* Find out the number of channels the user wants to configure
NOTE: Channel 0 will not be used */
numChannels = 0;
while((numChannels < 1) || (numChannels > 20))
{
fprintf(stdout,"Enter the number of channels to be scanned (1-20):");
gets(response);
numChannels = atoi(response); /* convert ascii response to numeric */
}
/* Turn off unused channels */
fprintf(stdout,"\nWait....\n");
for(index = numChannels + 1; index < 21; ++index)
{
sprintf(sendbuff,"FUNC %d, OFF",index);
asiputs(COM2,sendbuff,-2);
checkResponse(); /* get prompt */
}
/* Print Header and Hydra identification header */
fprintf(stdout,"\n\nSample Program for Hydra\n");
asiputs(COM2,"*IDN?",-2); /* Ask for Hydra identification info */
checkResponse(); /* Get prompt */
asigets_timed(COM2,recvbuff,256,-2,TICKS_PER_SECOND*2); /* Receive Hydra
identification
header */
fprintf(stdout,"%s\n\n",recvbuff);
/*
* Configure channels and scan until user chooses to Quit
*/
while(1)
{
int func; /* Configuration setting */
char configStr[14]; /* channel function string */
/*
* Configure Hydra Channels
*/
op53_2f.eps

Figure 4-7. Sample Program (QuickC) (2 of 5)