Guardian Programmer's Guide

Table Of Contents
Communicating With Devices
Guardian Programmer’s Guide 421922-014
9 - 9
Additional Device Information (G-series Only)
The following C program shows how the CONFIG_GETINFO_BYNAME2_ procedure
can be used to obtain device information for an arbitrary process, in this case
"$EXMPL." This program assumes that the device $EXMPL provides a type for its
device-specific information in "example.h" called example_specific_info_type. Other
devices either return no device-specific information, or return device-specific
information in formats that the programmer specifies.
#include <cextdecs>
#include <stdio.h>
#include <string.h>
#include "zsysc"
#include “example.h”
int main()
{
char device_name[] = "$EXMPL";
zsys_ddl_config_getinfo2_def common_info; /* device-independent info */
example_specific_info_type specific_info; /* device-dependent info */
short common_len, specific_len; /* returned sizes of device *
* information */
long error, error_detail;
error = CONFIG_GETINFO_BYNAME2_
(device_name /* Name of device to query */
,strlen(device_name) /* .. and it's length */
,(short *)&common_info /* Buffer to hold device-independent info */
,sizeof(common_info) /* .. and it's size */
,&common_len /* .. actual size returned by device */
,(char *)&specific_info /* Buffer to hold $EXMPL-specific info */
,sizeof(specific_info) /* .. and it's size */
,&specific_len /* .. actual size returned by device */
,2000 /* Wait at most 20 seconds before timeout */
,&error_detail /* More error information */
);
if(error == 1)
printf("Filesystem error %d returned\n",error_detail);
else if(error == 2)
printf("Parameter %d was invalid\n",error_detail);
else if(error == 3)
printf("Parameter %d failed bounds check\n",error_detail);
else if(error == 4 && error_detail == -1)
printf("Device returned invalid data to getinfo request\n");
else if(error == 4)
printf("Device returned error %d to getinfo request\n",error_detail);
else {
/* No error, common_info and specific info now contain valid data
* of lengths common_len and specific_len */
. . . .
}