#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
static void confirm_close(void);
static void terminate(const char *format, ...);
int main(void)
{
char* ipaddress = "192.168.1.1";
unsigned short portno = 8006;
uint32_t serverAPIVersion;
double sampleRate = 0;
char *recorderType = NULL, *recorderName = NULL, *serialNumber = NULL, *firmwareVersion = NULL;
printf("Connecting to %s:%u\n", ipaddress, portno);
returnCode =
GHSConnect(ipaddress, portno, &connection, &serverAPIVersion);
{
terminate("Failed: client has API version %u, while mainframe has API version %u.\n",
}
{
terminate("Failed: return code is %d.\n", returnCode);
}
printf("Connected\n");
{
terminate("Failed on GHSGetRecorderInformation: return code is %d.\n", returnCode);
}
printf("\nRecorder slot: %c\n", slotID);
{
terminate("Failed on GHSGetSampleRate: return code is %d.\n", returnCode);
}
{
terminate("Failed on GHSSetSampleRate: return code is %d.\n", returnCode);
}
printf("\nSample-rate: %.2f\n", sampleRate);
printf("\nRecorder Information:\n");
printf("Type: %s\n", recorderType);
printf("Name: %s\n", recorderName);
printf("Serial number: %s\n", serialNumber);
printf("Firmware version: %s\n\n", firmwareVersion);
{
terminate("Failed on GHSDisconnect: return code is %d.\n", returnCode);
}
printf("Disconnected\n");
confirm_close();
return EXIT_SUCCESS;
}
void confirm_close(void)
{
printf("Press ENTER to close this example program.\n");
(void)getchar();
}
void terminate(const char *format, ...)
{
va_list args;
va_start(args, format);
vprintf(format, args);
va_end(args);
confirm_close();
exit(EXIT_FAILURE);
}