ncDeviceClose()

Info Value
Header mvnc.h
Library libmvnc.so
Version 2.0
See also struct ncDeviceHandle_t, ncDeviceCreate(), ncDeviceOpen(), ncDeviceDestroy()

Overview

This function closes communication with a neural compute device that has been opened with ncDeviceOpen().

Before calling this function, you must destroy all ncFifoHandle_t structs and ncGraphHandle_t structs that were allocated to this device.

Prototype

ncStatus_t ncDeviceClose(struct ncDeviceHandle_t* deviceHandle);

Parameters

Name Type Description
deviceHandle struct ncDeviceHandle_t* A pointer to an initialized and opened ncDeviceHandle_t struct for the device that will be closed. The device state must be NC_DEVICE_OPENED.

Return

An appropriate value from the ncStatus_t enumeration.

Notes

  • When the device has been successfully closed the device state will be NC_DEVICE_CLOSED.

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);
    ncDeviceOpen(deviceHandlePtr);  
    
    // Device handle is ready to use now, pass it to other API calls as needed...

    // Close the device
    retCode = ncDeviceClose(deviceHandlePtr);
    if (retCode != NC_OK)
    {
        // Failed to close the device
        printf("ncDeviceClose Failed [%d]: Could not close the device.\n", retCode);
    }

    ncDeviceDestroy(&deviceHandlePtr);
}