1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define STR_SIZE 10
char s[STR_SIZE]; /* received string */
char s2[STR_SIZE]; /* string converted to upper case */
int i;
int main(void)
{
printf("Running\n");
while(1) {
printf("mydevice> ");
scanf("%s",s);
for (i=0 ; i<STR_SIZE ; ++i)
{
s2[i]=toupper(s[i]);
}
if ( strcmp(s2, "*IDN?")==0 ) {
printf("*IDN? = device identification\n");
} else {
fprintf(stderr,"Error ! this firmware doesn't understand this command\n");
}
}
printf("Stopping\n"); /* it should never happen */
return 0;
} |