ncDeviceOpen()
Info | Value |
---|---|
Header | mvnc.h |
Library | libmvnc.so |
Version | 2.0 |
See also | struct ncDeviceHandle_t, ncDeviceCreate(), ncDeviceClose(), ncDeviceDestroy() |
Overview
This function initializes a neural compute device and opens communication.
Upon successful return from this function, the device will be ready for use.
ncDeviceClose() closes communication with devices opened with this function.
Prototype
ncStatus_t ncDeviceOpen(struct ncDeviceHandle_t* deviceHandle);
Parameters
Name | Type | Description |
---|---|---|
deviceHandle | struct ncDeviceHandle_t* | A pointer to an initialized ncDeviceHandle_t struct for the device that will be opened. The device state must be NC_DEVICE_CREATED. |
Return
An appropriate value from the ncStatus_t enumeration.
Notes
- The ncDeviceHandle_t struct must be passed to ncDeviceCreate() and then this function before being passed to any API functions other than ncDeviceGetOption() or ncDeviceSetOption(). When the device has been successfully opened, the device state will be NC_DEVICE_OPENED.
Example
#include <stdio.h>
#include <stdlib.h>
#include <mvnc.h>
int main(int argc, char** argv)
{
ncStatus_t retCode;
struct ncDeviceHandle_t* deviceHandlePtr;
ncDeviceCreate(0, &deviceHandlePtr);
// Open the device
retCode = ncDeviceOpen(deviceHandlePtr);
if (retCode != NC_OK)
{
// Failed to open the device
printf("ncDeviceOpen Failed [%d]: Could not open the device.\n", retCode);
}
else
{
// Device handle is ready to use now, pass it to other API calls as needed...
ncDeviceClose(deviceHandlePtr);
}
ncDeviceDestroy(&deviceHandlePtr);
}