| KINOVAAPIUSBCOMMANDLAYER_API int CloseAPI | ( | void | ) |
This function must called when your application stop using the API. It closes the USB link and the library properly.
#include <iostream> #include <dlfcn.h> //Ubuntu //Note that under windows, you may/will have to perform other #include using namespace std; int main() { int result; cout << "CloseAPI function example" << endl; //Handle for the library's command layer. void * commandLayer_handle; //Function pointers to the functions we need int (*MyInitAPI)(); int (*MyCloseAPI)(); //We load the library (Under Windows, use the function LoadLibrary) commandLayer_handle = dlopen("Kinova.API.USBCommandLayerUbuntu.so",RTLD_NOW|RTLD_GLOBAL); //We load the functions from the library (Under Windows, use GetProcAddress) MyInitAPI = (int (*)()) dlsym(commandLayer_handle,"InitAPI"); MyCloseAPI = (int (*)()) dlsym(commandLayer_handle,"CloseAPI"); //If the was loaded correctly if((MyInitAPI == NULL) || (MyCloseAPI == NULL)) { cout << "Unable to initialize the command layer." << endl; } else { cout << "CloseAPI() is initialized correctly." << endl; cout << "Calling the method InitAPI()" << endl; result = (*MyInitAPI)(); cout << "result of InitAPI() = " << result << endl; cout << "Calling the method CloseAPI()" << endl; result = (*MyCloseAPI)(); cout << "result of CloseAPI() = " << result << endl; } return 0; }