HP (Hewlett-Packard) 16500C Sander User Manual


 
Example The following example in C opens the \system\program file and sends
several commands and queries. Responses to queries appear as text strings
in
\system\program. The HP 16500C has been NFS-mounted in the \users
directory.
#include <stdio.h>
#include <unistd.h>
#define STR_LEN 80
void putstr(FILE *file, char *str)
{
fwrite(str, strlen(str), 1, file);
}
int getstr(FILE *file, char* str)
{
return(fread(str, 1, STR_LEN, file));
}
void main()
{
FILE *file;
int num;
char receive_str[STR_LEN];
/* Send a query and retrieve and print the response*/
file = fopen("/users/system/program", "r");
while (getstr(file, receive_str) != 0);
fclose(file);
file = fopen("/users/system/program", "w");
putstr(file, "*idn?\n");
fclose(file);
sleep(1);
file = fopen("/users/system/program", "r");
while (getstr(file, receive_str) == 0);
fclose(file);
printf("%s\n", receive_str);
Programming Over LAN
Writing to \system\program from a Program
4–9