This function gets a specific error from the robotical arm's error log.
#include <iostream>
#include <dlfcn.h>
#include <vector>
#include "KinovaTypes.h"
using namespace std;
int main()
{
int result;
unsigned int ErrorCount;
SystemError errorTemp;
cout << "GetSystemError function example" << endl;
void * commandLayer_handle;
int (*MyInitAPI)();
int (*MyCloseAPI)();
int (*MyGetSystemErrorCount)(unsigned int &);
int (*MyGetSystemError)(unsigned int, SystemError &);
commandLayer_handle = dlopen("Kinova.API.USBCommandLayerUbuntu.so",RTLD_NOW|RTLD_GLOBAL);
MyInitAPI = (int (*)()) dlsym(commandLayer_handle,"InitAPI");
MyCloseAPI = (int (*)()) dlsym(commandLayer_handle,"CloseAPI");
MyGetSystemErrorCount = (int (*)(unsigned int &)) dlsym(commandLayer_handle,"GetSystemErrorCount");
MyGetSystemError = (int (*)(unsigned int, SystemError &)) dlsym(commandLayer_handle,"GetSystemError");
if((MyInitAPI == NULL) || (MyCloseAPI == NULL) || (MyGetSystemErrorCount == NULL) || (MyGetSystemError == NULL))
{
cout << "Unable to initialize the command layer." << endl;
}
else
{
cout << "The command has been initialized correctly." << endl << endl;
cout << "Calling the method InitAPI()" << endl;
result = (*MyInitAPI)();
cout << "result of InitAPI() = " << result << endl;
result = (*MyGetSystemErrorCount)(ErrorCount);
cout << "System error count : " << ErrorCount << endl << endl << endl;
for(unsigned int i = 0; i < ErrorCount; i++)
{
result = (*MyGetSystemError)(i, errorTemp);
cout << "System error #" << i << " type : " << errorTemp.ErrorType << endl;
}
cout << endl << "Calling the method CloseAPI()" << endl;
result = (*MyCloseAPI)();
cout << "result of CloseAPI() = " << result << endl;
}
return 0;
}