
SC5305A Operating & Programming Manual
Rev 2.1.0
33
Function:
sc5305a_OpenDevice
Definition:
int sc5305a_OpenDevice(char *visaResource, unsigned int *deviceHandle)
Return:
Error code
Output:
char *visaResource
(char pointer to the resource ID)
unsigned int deviceHandle
(device handle return)
Description:
sc5305a_OpenDevice
opens the device and turns on the front panel “active” LED if
successful. This function returns a handle to the device for other function calls.
Function:
sc5305a_CloseDevice
Definition:
int sc5305a_CloseDevice(unsigned int *deviceHandle)
Return:
The status of the function
Input:
unsigned int *deviceHandle
(handle to the device to be closed)
Description:
sc5305a_CloseDevice
closes the device associated with the device handle and turns off
the “active” LED of the front panel if it is successful.
Example:
To exercise the functions that open and close the device:
// Declaring
char
** visaResource;
unsigned int
deviceHandle;
int
devicesFound;
int
i, status;
// Allocate memory for possible 100 devices with 1000 char description
char **visaResource = (char**)malloc(sizeof(char*)* MAXDEVICES);
for(i = 0; i< MAXDEVICES; i++) visaResource[i] = (char*)malloc(sizeof(char)*1000);
status = sc5305a_ListResources(visaResource, &devicesFound);
if(devicesFound == 0)
{
for(i = 0; i< MAXDEVICES;i++) free(visaResource[i]);
free(visaResource);
}
printf(
"There are %d SignalCore SC5305A devices found. \n"
, devicesFound);
for (i = 0;i<devicesFound;i++) printf("%d. %s \n",i + 1,visaResource[i]);
status = sc5305a_OpenDevice(visaResource[0], deviceHandle);
// get handle to the first listed device
// Free memory
for(i = 0; i< MAXDEVICES;i++) free(visaResource[i]);
free(visaResource);
//
// Do something with the device
//
//Close the device
int
status = sc5305a_CloseDevice(deviceHandle);